diff options
Diffstat (limited to 'spec/services/system_note_service_spec.rb')
-rw-r--r-- | spec/services/system_note_service_spec.rb | 61 |
1 files changed, 51 insertions, 10 deletions
diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 3ec2c71b20c..a719487a219 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -77,6 +77,19 @@ RSpec.describe SystemNoteService do end end + describe '.change_issuable_contacts' do + let(:added_count) { 5 } + let(:removed_count) { 3 } + + it 'calls IssuableService' do + expect_next_instance_of(::SystemNotes::IssuablesService) do |service| + expect(service).to receive(:change_issuable_contacts).with(added_count, removed_count) + end + + described_class.change_issuable_contacts(noteable, project, author, added_count, removed_count) + end + end + describe '.close_after_error_tracking_resolve' do it 'calls IssuableService' do expect_next_instance_of(::SystemNotes::IssuablesService) do |service| @@ -572,12 +585,26 @@ RSpec.describe SystemNoteService do describe '.change_alert_status' do let(:alert) { build(:alert_management_alert) } - it 'calls AlertManagementService' do - expect_next_instance_of(SystemNotes::AlertManagementService) do |service| - expect(service).to receive(:change_alert_status).with(alert) + context 'with status change reason' do + let(:reason) { 'reason for status change' } + + it 'calls AlertManagementService' do + expect_next_instance_of(SystemNotes::AlertManagementService) do |service| + expect(service).to receive(:change_alert_status).with(reason) + end + + described_class.change_alert_status(alert, author, reason) end + end + + context 'without status change reason' do + it 'calls AlertManagementService' do + expect_next_instance_of(SystemNotes::AlertManagementService) do |service| + expect(service).to receive(:change_alert_status).with(nil) + end - described_class.change_alert_status(alert, author) + described_class.change_alert_status(alert, author) + end end end @@ -618,15 +645,29 @@ RSpec.describe SystemNoteService do end end - describe '.resolve_incident_status' do - let(:incident) { build(:incident, :closed) } + describe '.change_incident_status' do + let(:incident) { instance_double('Issue', project: project) } - it 'calls IncidentService' do - expect_next_instance_of(SystemNotes::IncidentService) do |service| - expect(service).to receive(:resolve_incident_status) + context 'with status change reason' do + let(:reason) { 'reason for status change' } + + it 'calls IncidentService' do + expect_next_instance_of(SystemNotes::IncidentService) do |service| + expect(service).to receive(:change_incident_status).with(reason) + end + + described_class.change_incident_status(incident, author, reason) end + end - described_class.resolve_incident_status(incident, author) + context 'without status change reason' do + it 'calls IncidentService' do + expect_next_instance_of(SystemNotes::IncidentService) do |service| + expect(service).to receive(:change_incident_status).with(nil) + end + + described_class.change_incident_status(incident, author) + end end end |