GitLab steht aufgrund wichtiger Wartungsarbeiten am Montag, den 8. März, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Commit 9f612cc4 authored by Sean McGivern's avatar Sean McGivern

Fix issues mentioned but not closed for JIRA

The `ReferenceExtractor` would return an array of `ExternalIssue`
objects, and then perform `Array#-` to remove the issues
closed. `ExternalIssue`s had `==` defined, but not `hash` or `eql?`,
which are used by `Array#-`.
parent 86d1e42a
...@@ -24,6 +24,11 @@ def title ...@@ -24,6 +24,11 @@ def title
def ==(other) def ==(other)
other.is_a?(self.class) && (to_s == other.to_s) other.is_a?(self.class) && (to_s == other.to_s)
end end
alias_method :eql?, :==
def hash
[self.class, to_s].hash
def project def project
@project @project
title: Fix issues mentioned but not closed for external issue trackers
...@@ -12,4 +12,13 @@ ...@@ -12,4 +12,13 @@
token: 'a' * 40, token: 'a' * 40,
}) })
end end
factory :jira_service do
project factory: :empty_project
active true
url: '',
project_key: 'jira-key'
end end
...@@ -42,4 +42,12 @@ ...@@ -42,4 +42,12 @@
expect(issue.project_id).to eq( expect(issue.project_id).to eq(
end end
end end
describe '#hash' do
it 'returns the hash of its [class, to_s] pair' do
issue_2 =, project)
expect(issue.hash).to eq(issue_2.hash)
end end
...@@ -346,6 +346,23 @@ ...@@ -346,6 +346,23 @@
expect(subject.issues_mentioned_but_not_closing( match_array([mentioned_issue]) expect(subject.issues_mentioned_but_not_closing( match_array([mentioned_issue])
end end
context 'when the project has an external issue tracker' do
before do << [, :developer]
commit = double(:commit, safe_message: 'Fixes TEST-3')
create(:jira_service, project: subject.project)
allow(subject).to receive(:commits).and_return([commit])
allow(subject).to receive(:description).and_return('Is related to TEST-2 and TEST-3')
allow(subject.project).to receive(:default_branch).and_return(subject.target_branch)
it 'detects issues mentioned in description but not closed' do
expect(subject.issues_mentioned_but_not_closing( match_array(['TEST-2'])
end end
describe "#work_in_progress?" do describe "#work_in_progress?" do
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment