Disallow system notes for closed issuables
This commit is contained in:
parent
b0f5d1a9b9
commit
0771774480
|
@ -385,6 +385,7 @@ module SystemNoteService
|
||||||
# Returns Boolean
|
# Returns Boolean
|
||||||
def cross_reference_disallowed?(noteable, mentioner)
|
def cross_reference_disallowed?(noteable, mentioner)
|
||||||
return true if noteable.is_a?(ExternalIssue) && !noteable.project.jira_tracker_active?
|
return true if noteable.is_a?(ExternalIssue) && !noteable.project.jira_tracker_active?
|
||||||
|
return true if noteable.is_a?(Issuable) && (noteable.try(:closed?) || noteable.try(:merged?))
|
||||||
return false unless mentioner.is_a?(MergeRequest)
|
return false unless mentioner.is_a?(MergeRequest)
|
||||||
return false unless noteable.is_a?(Commit)
|
return false unless noteable.is_a?(Commit)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: Disallow system notes for closed issuables
|
||||||
|
merge_request:
|
||||||
|
author:
|
|
@ -418,6 +418,45 @@ describe SystemNoteService, services: true do
|
||||||
to be_truthy
|
to be_truthy
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
describe '.cross_reference_exists?' do
|
describe '.cross_reference_exists?' do
|
||||||
|
|
Loading…
Reference in New Issue