2019-07-25 01:21:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-17 13:08:35 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Gitlab::ClosingIssueExtractor do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:project2) { create(:project) }
|
2018-01-31 11:51:05 -05:00
|
|
|
let(:forked_project) { Projects::ForkService.new(project, project2.creator).execute }
|
2017-01-24 18:42:12 -05:00
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
let(:issue2) { create(:issue, project: project2) }
|
2015-05-21 16:35:15 -04:00
|
|
|
let(:reference) { issue.to_reference }
|
2015-12-02 12:48:39 -05:00
|
|
|
let(:cross_reference) { issue2.to_reference(project) }
|
2016-08-04 05:56:58 -04:00
|
|
|
let(:fork_cross_reference) { issue.to_reference(forked_project) }
|
2014-09-17 13:08:35 -04:00
|
|
|
|
2015-04-03 12:03:34 -04:00
|
|
|
subject { described_class.new(project, project.creator) }
|
|
|
|
|
2015-12-02 12:48:39 -05:00
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_developer(project.creator)
|
2018-01-31 11:51:05 -05:00
|
|
|
project.add_developer(project2.creator)
|
2018-07-11 10:36:08 -04:00
|
|
|
project2.add_maintainer(project.creator)
|
2015-12-02 12:48:39 -05:00
|
|
|
end
|
|
|
|
|
2015-04-03 12:03:34 -04:00
|
|
|
describe "#closed_by_message" do
|
2014-09-17 13:08:35 -04:00
|
|
|
context 'with a single reference' do
|
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Awesome commit (Closes #{reference})"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Awesome commit (Closes: #{reference})"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2014-09-17 13:08:35 -04:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Awesome commit (closes #{reference})"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Awesome commit (closes: #{reference})"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2014-09-17 13:08:35 -04:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Closed #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "closed #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "closed: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Closing #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Closing: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "closing #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "closing: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Close #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Close: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "close #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "close: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Awesome commit (Fixes #{reference})"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Awesome commit (Fixes: #{reference})"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2014-09-17 13:08:35 -04:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Awesome commit (fixes #{reference})"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Awesome commit (Fixes: #{reference})"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2014-09-17 13:08:35 -04:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Fixed #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Fixed: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "fixed #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "fixed: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Fixing #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Fixing: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "fixing #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "fixing: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Fix #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Fix: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "fix #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "fix: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Awesome commit (Resolves #{reference})"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Awesome commit (Resolves: #{reference})"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Awesome commit (resolves #{reference})"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Awesome commit (resolves: #{reference})"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Resolved #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Resolved: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "resolved #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "resolved: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Resolving #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Resolving: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "resolving #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "resolving: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Resolve #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2015-02-05 16:04:49 -05:00
|
|
|
end
|
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "Resolve: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2015-02-05 16:04:49 -05:00
|
|
|
it do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "resolve #{reference}"
|
2015-04-03 12:03:34 -04:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|
2016-01-25 11:27:03 -05:00
|
|
|
|
2016-04-07 08:47:29 -04:00
|
|
|
it do
|
|
|
|
message = "resolve: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2017-10-01 22:16:24 -04:00
|
|
|
it do
|
|
|
|
message = "Implement: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
|
|
|
it do
|
|
|
|
message = "Implements: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
|
|
|
it do
|
|
|
|
message = "Implemented: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
|
|
|
it do
|
|
|
|
message = "Implementing: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
|
|
|
it do
|
|
|
|
message = "implement: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
|
|
|
it do
|
|
|
|
message = "implements: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
|
|
|
it do
|
|
|
|
message = "implemented: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
|
|
|
it do
|
|
|
|
message = "implementing: #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue])
|
|
|
|
end
|
|
|
|
|
2016-01-25 11:27:03 -05:00
|
|
|
context 'with an external issue tracker reference' do
|
|
|
|
it 'extracts the referenced issue' do
|
|
|
|
jira_project = create(:jira_project, name: 'JIRA_EXT1')
|
2018-07-11 10:36:08 -04:00
|
|
|
jira_project.add_maintainer(jira_project.creator)
|
2016-01-25 11:27:03 -05:00
|
|
|
jira_issue = ExternalIssue.new("#{jira_project.name}-1", project: jira_project)
|
2016-11-01 16:18:51 -04:00
|
|
|
closing_issue_extractor = described_class.new(jira_project, jira_project.creator)
|
2016-01-25 11:27:03 -05:00
|
|
|
message = "Resolve #{jira_issue.to_reference}"
|
|
|
|
|
|
|
|
expect(closing_issue_extractor.closed_by_message(message)).to eq([jira_issue])
|
|
|
|
end
|
|
|
|
end
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|
|
|
|
|
2015-12-02 12:48:39 -05:00
|
|
|
context "with a cross-project reference" do
|
|
|
|
it do
|
|
|
|
message = "Closes #{cross_reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([issue2])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with a cross-project URL" do
|
|
|
|
it do
|
2017-06-29 13:06:35 -04:00
|
|
|
message = "Closes #{urls.project_issue_url(issue2.project, issue2)}"
|
2015-12-02 12:48:39 -05:00
|
|
|
expect(subject.closed_by_message(message)).to eq([issue2])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-04 05:56:58 -04:00
|
|
|
context "with a cross-project fork reference" do
|
|
|
|
subject { described_class.new(forked_project, forked_project.creator) }
|
|
|
|
|
|
|
|
it do
|
|
|
|
message = "Closes #{fork_cross_reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to be_empty
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-12-02 12:48:39 -05:00
|
|
|
context "with an invalid URL" do
|
|
|
|
it do
|
2017-06-29 13:06:35 -04:00
|
|
|
message = "Closes https://google.com#{urls.project_issue_path(issue2.project, issue2)}"
|
2015-12-02 12:48:39 -05:00
|
|
|
expect(subject.closed_by_message(message)).to eq([])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-09-05 10:17:13 -04:00
|
|
|
context "with an invalid keyword such as suffix insted of fix" do
|
|
|
|
it do
|
|
|
|
message = "suffix #{reference}"
|
|
|
|
expect(subject.closed_by_message(message)).to eq([])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-17 13:08:35 -04:00
|
|
|
context 'with multiple references' do
|
|
|
|
let(:other_issue) { create(:issue, project: project) }
|
|
|
|
let(:third_issue) { create(:issue, project: project) }
|
2015-05-21 16:35:15 -04:00
|
|
|
let(:reference2) { other_issue.to_reference }
|
|
|
|
let(:reference3) { third_issue.to_reference }
|
2014-09-17 13:08:35 -04:00
|
|
|
|
|
|
|
it 'fetches issues in single line message' do
|
2015-05-26 15:55:26 -04:00
|
|
|
message = "Closes #{reference} and fix #{reference2}"
|
2014-09-17 13:08:35 -04:00
|
|
|
|
2017-06-21 09:48:12 -04:00
|
|
|
expect(subject.closed_by_message(message))
|
|
|
|
.to match_array([issue, other_issue])
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'fetches comma-separated issues references in single line message' do
|
2015-05-26 15:55:26 -04:00
|
|
|
message = "Closes #{reference}, closes #{reference2}"
|
2014-09-17 13:08:35 -04:00
|
|
|
|
2017-06-21 09:48:12 -04:00
|
|
|
expect(subject.closed_by_message(message))
|
|
|
|
.to match_array([issue, other_issue])
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'fetches comma-separated issues numbers in single line message' do
|
2015-05-26 15:55:26 -04:00
|
|
|
message = "Closes #{reference}, #{reference2} and #{reference3}"
|
2014-09-17 13:08:35 -04:00
|
|
|
|
2017-06-21 09:48:12 -04:00
|
|
|
expect(subject.closed_by_message(message))
|
|
|
|
.to match_array([issue, other_issue, third_issue])
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|
|
|
|
|
2018-02-17 11:47:21 -05:00
|
|
|
it 'allows oxford commas (comma before and) when referencing multiple issues' do
|
|
|
|
message = "Closes #{reference}, #{reference2}, and #{reference3}"
|
|
|
|
|
|
|
|
expect(subject.closed_by_message(message))
|
|
|
|
.to match_array([issue, other_issue, third_issue])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows spaces before commas when referencing multiple issues' do
|
|
|
|
message = "Closes #{reference} , #{reference2} , and #{reference3}"
|
|
|
|
|
|
|
|
expect(subject.closed_by_message(message))
|
|
|
|
.to match_array([issue, other_issue, third_issue])
|
|
|
|
end
|
|
|
|
|
2018-07-11 09:28:53 -04:00
|
|
|
it 'allows non-comma-separated issue numbers in single line message' do
|
|
|
|
message = "Closes #{reference} #{reference2} #{reference3}"
|
|
|
|
|
|
|
|
expect(subject.closed_by_message(message))
|
|
|
|
.to match_array([issue, other_issue, third_issue])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows mixed comma-separated and non-comma-separated issue numbers in single line message' do
|
|
|
|
message = "Closes #{reference}, #{reference2} and #{reference3}"
|
|
|
|
|
|
|
|
expect(subject.closed_by_message(message))
|
|
|
|
.to match_array([issue, other_issue, third_issue])
|
|
|
|
end
|
|
|
|
|
2014-09-17 13:08:35 -04:00
|
|
|
it 'fetches issues in multi-line message' do
|
2015-05-26 15:55:26 -04:00
|
|
|
message = "Awesome commit (closes #{reference})\nAlso fixes #{reference2}"
|
2014-09-17 13:08:35 -04:00
|
|
|
|
2017-06-21 09:48:12 -04:00
|
|
|
expect(subject.closed_by_message(message))
|
|
|
|
.to match_array([issue, other_issue])
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'fetches issues in hybrid message' do
|
2015-05-21 16:35:15 -04:00
|
|
|
message = "Awesome commit (closes #{reference})\n"\
|
2015-05-26 15:55:26 -04:00
|
|
|
"Also fixing issues #{reference2}, #{reference3} and #4"
|
2014-09-17 13:08:35 -04:00
|
|
|
|
2017-06-21 09:48:12 -04:00
|
|
|
expect(subject.closed_by_message(message))
|
|
|
|
.to match_array([issue, other_issue, third_issue])
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|
2015-12-02 12:48:39 -05:00
|
|
|
|
|
|
|
it "fetches cross-project references" do
|
|
|
|
message = "Closes #{reference} and #{cross_reference}"
|
|
|
|
|
2017-06-21 09:48:12 -04:00
|
|
|
expect(subject.closed_by_message(message))
|
|
|
|
.to match_array([issue, issue2])
|
2015-12-02 12:48:39 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "fetches cross-project URL references" do
|
2017-09-21 06:42:16 -04:00
|
|
|
message = "Closes #{urls.project_issue_url(issue2.project, issue2)}, #{reference} and #{urls.project_issue_url(other_issue.project, other_issue)}"
|
2015-12-02 12:48:39 -05:00
|
|
|
|
2017-06-21 09:48:12 -04:00
|
|
|
expect(subject.closed_by_message(message))
|
2017-09-21 06:42:16 -04:00
|
|
|
.to match_array([issue, issue2, other_issue])
|
2015-12-02 12:48:39 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "ignores invalid cross-project URL references" do
|
2017-06-29 13:06:35 -04:00
|
|
|
message = "Closes https://google.com#{urls.project_issue_path(issue2.project, issue2)} and #{reference}"
|
2015-12-02 12:48:39 -05:00
|
|
|
|
2017-06-21 09:48:12 -04:00
|
|
|
expect(subject.closed_by_message(message))
|
|
|
|
.to match_array([issue])
|
2015-12-02 12:48:39 -05:00
|
|
|
end
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|
|
|
|
end
|
2015-12-03 08:00:00 -05:00
|
|
|
|
|
|
|
def urls
|
2016-03-24 12:00:26 -04:00
|
|
|
Gitlab::Routing.url_helpers
|
2015-12-03 08:00:00 -05:00
|
|
|
end
|
2014-09-17 13:08:35 -04:00
|
|
|
end
|