diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-15 03:09:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-15 03:09:23 +0300 |
commit | 8aab944cc5e9b58ecc6f052db7cb8985a8a0ba51 (patch) | |
tree | 67f4c47cd3b3712daa0035bef27f04b04582e1b4 /spec/models/incident_management | |
parent | f9cda7671cfb07795d9ea01a7117f7d6c6511d0d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/incident_management')
-rw-r--r-- | spec/models/incident_management/project_incident_management_setting_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/models/incident_management/project_incident_management_setting_spec.rb b/spec/models/incident_management/project_incident_management_setting_spec.rb index aa85d7845c7..effd89e970c 100644 --- a/spec/models/incident_management/project_incident_management_setting_spec.rb +++ b/spec/models/incident_management/project_incident_management_setting_spec.rb @@ -108,4 +108,42 @@ RSpec.describe IncidentManagement::ProjectIncidentManagementSetting do it_behaves_like 'no content' end end + + describe '#pagerduty_token' do + let(:active) { true } + + subject do + create(:project_incident_management_setting, project: project, pagerduty_active: active, pagerduty_token: token) + end + + context 'when token already set' do + let(:token) { SecureRandom.hex } + + it 'reads the token' do + expect(subject.pagerduty_token).to eq(token) + expect(subject.encrypted_pagerduty_token).not_to be_nil + expect(subject.encrypted_pagerduty_token_iv).not_to be_nil + end + end + + context 'when not set' do + let(:token) { nil } + + context 'when PagerDuty webhook is active' do + it 'generates a token before validation' do + expect(subject).to be_valid + expect(subject.pagerduty_token).to match(/\A\h{32}\z/) + end + end + + context 'when PagerDuty webhook is not active' do + let(:active) { false } + + it 'does not generate a token before validation' do + expect(subject).to be_valid + expect(subject.pagerduty_token).to be_nil + end + end + end + end end |