diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/services/system_notes/issuables_service_spec.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/services/system_notes/issuables_service_spec.rb')
-rw-r--r-- | spec/services/system_notes/issuables_service_spec.rb | 64 |
1 files changed, 54 insertions, 10 deletions
diff --git a/spec/services/system_notes/issuables_service_spec.rb b/spec/services/system_notes/issuables_service_spec.rb index c3b3c877583..1b5b26d90da 100644 --- a/spec/services/system_notes/issuables_service_spec.rb +++ b/spec/services/system_notes/issuables_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ::SystemNotes::IssuablesService do +RSpec.describe ::SystemNotes::IssuablesService do include ProjectForksHelper let_it_be(:group) { create(:group) } @@ -161,7 +161,9 @@ describe ::SystemNotes::IssuablesService do let(:status) { 'reopened' } let(:source) { nil } - it { is_expected.to be_nil } + it 'does not change note count' do + expect { subject }.not_to change { Note.count } + end end context 'with status reopened' do @@ -660,25 +662,67 @@ describe ::SystemNotes::IssuablesService do describe '#close_after_error_tracking_resolve' do subject { service.close_after_error_tracking_resolve } - it_behaves_like 'a system note' do - let(:action) { 'closed' } + context 'when state tracking is enabled' do + before do + stub_feature_flags(track_resource_state_change_events: true) + end + + it 'creates the expected state event' do + subject + + event = ResourceStateEvent.last + + expect(event.close_after_error_tracking_resolve).to eq(true) + expect(event.state).to eq('closed') + end end - it 'creates the expected system note' do - expect(subject.note) + context 'when state tracking is disabled' do + before do + stub_feature_flags(track_resource_state_change_events: false) + end + + it_behaves_like 'a system note' do + let(:action) { 'closed' } + end + + it 'creates the expected system note' do + expect(subject.note) .to eq('resolved the corresponding error and closed the issue.') + end end end describe '#auto_resolve_prometheus_alert' do subject { service.auto_resolve_prometheus_alert } - it_behaves_like 'a system note' do - let(:action) { 'closed' } + context 'when state tracking is enabled' do + before do + stub_feature_flags(track_resource_state_change_events: true) + end + + it 'creates the expected state event' do + subject + + event = ResourceStateEvent.last + + expect(event.close_auto_resolve_prometheus_alert).to eq(true) + expect(event.state).to eq('closed') + end end - it 'creates the expected system note' do - expect(subject.note).to eq('automatically closed this issue because the alert resolved.') + context 'when state tracking is disabled' do + before do + stub_feature_flags(track_resource_state_change_events: false) + end + + it_behaves_like 'a system note' do + let(:action) { 'closed' } + end + + it 'creates the expected system note' do + expect(subject.note).to eq('automatically closed this issue because the alert resolved.') + end end end end |