diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-02-07 13:56:38 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-02-07 13:56:38 +0300 |
commit | 55d55e3854e5e955e96b131c1350218a36e68b7b (patch) | |
tree | 930653e0cf748b9d9cabccfbd25f4f1e25dd9743 /spec | |
parent | 92b55fd00289de623737afdae0dcd99a90b0efad (diff) | |
parent | 0771774480ce1f46b27b629d3721917d6c1f1267 (diff) |
Merge branch 'issue_19262' into 'master'
Disallow system notes for closed issuables
Closes #19262
See merge request !8848
Diffstat (limited to 'spec')
-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 |