diff options
Diffstat (limited to 'spec/models/alerting')
-rw-r--r-- | spec/models/alerting/project_alerting_setting_spec.rb | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/spec/models/alerting/project_alerting_setting_spec.rb b/spec/models/alerting/project_alerting_setting_spec.rb index 90c5f8313b0..0424b94a1b7 100644 --- a/spec/models/alerting/project_alerting_setting_spec.rb +++ b/spec/models/alerting/project_alerting_setting_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Alerting::ProjectAlertingSetting do +RSpec.describe Alerting::ProjectAlertingSetting, feature_category: :incident_management do let_it_be(:project) { create(:project) } subject { create(:project_alerting_setting, project: project) } @@ -37,4 +37,31 @@ RSpec.describe Alerting::ProjectAlertingSetting do end end end + + describe '#sync_http_integration after_save callback' do + let_it_be_with_reload(:setting) { create(:project_alerting_setting, :with_http_integration, project: project) } + let_it_be_with_reload(:http_integration) { setting.project.alert_management_http_integrations.last! } + let_it_be(:new_token) { 'new_token' } + + context 'with corresponding HTTP integration' do + let_it_be(:original_token) { http_integration.token } + + it 'syncs the attribute' do + expect { setting.update!(token: new_token) } + .to change { http_integration.reload.token } + .from(original_token).to(new_token) + end + end + + context 'without corresponding HTTP integration' do + before do + http_integration.update_columns(endpoint_identifier: 'legacy') + end + + it 'does not sync the attribute or execute extra queries' do + expect { setting.update!(token: new_token) } + .not_to change { http_integration.reload.token } + end + end + end end |