diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-02-03 17:06:59 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-02-06 20:44:54 +0300 |
commit | 0771774480ce1f46b27b629d3721917d6c1f1267 (patch) | |
tree | b17a39148d32d9b67fdacb9ce62c591dd5802120 /spec/services/system_note_service_spec.rb | |
parent | b0f5d1a9b90645274f78c6d497871f382ed90eb0 (diff) |
Disallow system notes for closed issuables
Diffstat (limited to 'spec/services/system_note_service_spec.rb')
-rw-r--r-- | spec/services/system_note_service_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 7913a180f9b..7f027ae02a2 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -418,6 +418,45 @@ describe SystemNoteService, services: true do to be_truthy end end + + context 'when noteable is an Issue' do + let(:issue) { create(:issue, project: project) } + + it 'is truthy when issue is closed' do + issue.close + + expect(described_class.cross_reference_disallowed?(issue, project.commit)). + to be_truthy + end + + it 'is falsey when issue is open' do + expect(described_class.cross_reference_disallowed?(issue, project.commit)). + to be_falsy + end + end + + context 'when noteable is a Merge Request' do + let(:merge_request) { create(:merge_request, :simple, source_project: project) } + + it 'is truthy when merge request is closed' do + allow(merge_request).to receive(:closed?).and_return(:true) + + expect(described_class.cross_reference_disallowed?(merge_request, project.commit)). + to be_truthy + end + + it 'is truthy when merge request is merged' do + allow(merge_request).to receive(:closed?).and_return(:true) + + expect(described_class.cross_reference_disallowed?(merge_request, project.commit)). + to be_truthy + end + + it 'is falsey when merge request is open' do + expect(described_class.cross_reference_disallowed?(merge_request, project.commit)). + to be_falsy + end + end end describe '.cross_reference_exists?' do |