use MergeRequest#closes_issues instead of rewriting code to retrieve closing issues on MergeRequest#issues_mentioned_but_not_closing
This commit is contained in:
parent
d1debe18ae
commit
38dd9b545c
|
@ -576,11 +576,7 @@ class MergeRequest < ActiveRecord::Base
|
||||||
ext = Gitlab::ReferenceExtractor.new(project, current_user)
|
ext = Gitlab::ReferenceExtractor.new(project, current_user)
|
||||||
ext.analyze(description)
|
ext.analyze(description)
|
||||||
|
|
||||||
issues = ext.issues
|
ext.issues - closes_issues
|
||||||
closing_issues = Gitlab::ClosingIssueExtractor.new(project, current_user).
|
|
||||||
closed_by_message(description)
|
|
||||||
|
|
||||||
issues - closing_issues
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def target_project_path
|
def target_project_path
|
||||||
|
|
|
@ -283,12 +283,16 @@ describe MergeRequest, models: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#issues_mentioned_but_not_closing' do
|
describe '#issues_mentioned_but_not_closing' do
|
||||||
|
let(:closing_issue) { create :issue, project: subject.project }
|
||||||
|
let(:mentioned_issue) { create :issue, project: subject.project }
|
||||||
|
|
||||||
|
let(:commit) { double('commit', safe_message: "Fixes #{closing_issue.to_reference}") }
|
||||||
|
|
||||||
it 'detects issues mentioned in description but not closed' do
|
it 'detects issues mentioned in description but not closed' do
|
||||||
mentioned_issue = create(:issue, project: subject.project)
|
|
||||||
|
|
||||||
subject.project.team << [subject.author, :developer]
|
subject.project.team << [subject.author, :developer]
|
||||||
subject.description = "Is related to #{mentioned_issue.to_reference}"
|
subject.description = "Is related to #{mentioned_issue.to_reference} and #{closing_issue.to_reference}"
|
||||||
|
|
||||||
|
allow(subject).to receive(:commits).and_return([commit])
|
||||||
allow(subject.project).to receive(:default_branch).
|
allow(subject.project).to receive(:default_branch).
|
||||||
and_return(subject.target_branch)
|
and_return(subject.target_branch)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue