diff options
Diffstat (limited to 'spec/services/incident_management/create_issue_service_spec.rb')
-rw-r--r-- | spec/services/incident_management/create_issue_service_spec.rb | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/spec/services/incident_management/create_issue_service_spec.rb b/spec/services/incident_management/create_issue_service_spec.rb index 4c7fb682193..5a3721f00b8 100644 --- a/spec/services/incident_management/create_issue_service_spec.rb +++ b/spec/services/incident_management/create_issue_service_spec.rb @@ -6,7 +6,7 @@ describe IncidentManagement::CreateIssueService do let(:project) { create(:project, :repository, :private) } let_it_be(:user) { User.alert_bot } let(:service) { described_class.new(project, alert_payload) } - let(:alert_starts_at) { Time.now } + let(:alert_starts_at) { Time.current } let(:alert_title) { 'TITLE' } let(:alert_annotations) { { title: alert_title } } @@ -281,18 +281,28 @@ describe IncidentManagement::CreateIssueService do setting.update!(create_issue: false) end - it 'returns an error' do - expect(service) - .to receive(:log_error) - .with(error_message('setting disabled')) + context 'when skip_settings_check is false (default)' do + it 'returns an error' do + expect(service) + .to receive(:log_error) + .with(error_message('setting disabled')) + + expect(subject).to eq(status: :error, message: 'setting disabled') + end + end + + context 'when skip_settings_check is true' do + subject { service.execute(skip_settings_check: true) } - expect(subject).to eq(status: :error, message: 'setting disabled') + it 'creates an issue' do + expect { subject }.to change(Issue, :count).by(1) + end end end private - def build_alert_payload(annotations: {}, starts_at: Time.now) + def build_alert_payload(annotations: {}, starts_at: Time.current) { 'annotations' => annotations.stringify_keys }.tap do |payload| |