diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-23 22:34:10 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-23 22:34:10 +0000 |
commit | 96855c4214715fe718c02a308ddd0e4a3265b5d1 (patch) | |
tree | 1dd318ede0a420effd7d0eb41a980c4adc24fae5 /spec/models/error_tracking | |
parent | 5248069bd6ee923a76047fa74dee46155c40fa2b (diff) | |
download | gitlab-ce-96855c4214715fe718c02a308ddd0e4a3265b5d1.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/error_tracking')
-rw-r--r-- | spec/models/error_tracking/project_error_tracking_setting_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/models/error_tracking/project_error_tracking_setting_spec.rb b/spec/models/error_tracking/project_error_tracking_setting_spec.rb index 29255e53fcf..d17541b4a6c 100644 --- a/spec/models/error_tracking/project_error_tracking_setting_spec.rb +++ b/spec/models/error_tracking/project_error_tracking_setting_spec.rb @@ -79,6 +79,46 @@ RSpec.describe ErrorTracking::ProjectErrorTrackingSetting do end end + describe 'Callbacks' do + describe 'after_save :create_client_key!' do + subject { build(:project_error_tracking_setting, :integrated, project: project) } + + context 'no client key yet' do + it 'creates a new client key' do + expect { subject.save! }.to change { ErrorTracking::ClientKey.count }.by(1) + end + + context 'sentry backend' do + before do + subject.integrated = false + end + + it 'does not create a new client key' do + expect { subject.save! }.not_to change { ErrorTracking::ClientKey.count } + end + end + + context 'feature disabled' do + before do + subject.enabled = false + end + + it 'does not create a new client key' do + expect { subject.save! }.not_to change { ErrorTracking::ClientKey.count } + end + end + end + + context 'client key already exists' do + let!(:client_key) { create(:error_tracking_client_key, project: project) } + + it 'does not create a new client key' do + expect { subject.save! }.not_to change { ErrorTracking::ClientKey.count } + end + end + end + end + describe '.extract_sentry_external_url' do subject { described_class.extract_sentry_external_url(sentry_url) } @@ -494,4 +534,10 @@ RSpec.describe ErrorTracking::ProjectErrorTrackingSetting do it { expect(subject.sentry_enabled).to eq(sentry_enabled) } end end + + describe '#gitlab_dsn' do + let!(:client_key) { create(:error_tracking_client_key, project: project) } + + it { expect(subject.gitlab_dsn).to eq(client_key.sentry_dsn) } + end end |