Commit eb7b03af authored by Sean McGivern's avatar Sean McGivern

Merge branch 'fix-mentioned-issues-for-external-trackers' into 'master'

Fix issues mentioned but not closed for JIRA

Closes #26028

See merge request !9687
parents 5fce538b 5ce3845f
...@@ -24,6 +24,11 @@ class ExternalIssue ...@@ -24,6 +24,11 @@ class ExternalIssue
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
end
def project def project
@project @project
......
---
title: Fix issues mentioned but not closed for external issue trackers
merge_request:
author:
...@@ -189,29 +189,10 @@ FactoryGirl.define do ...@@ -189,29 +189,10 @@ FactoryGirl.define do
factory :jira_project, parent: :project do factory :jira_project, parent: :project do
has_external_issue_tracker true has_external_issue_tracker true
jira_service
after :create do |project|
project.create_jira_service(
active: true,
properties: {
title: 'JIRA tracker',
url: 'http://jira.example.net',
project_key: 'JIRA'
}
)
end
end end
factory :kubernetes_project, parent: :empty_project do factory :kubernetes_project, parent: :empty_project do
after :create do |project| kubernetes_service
project.create_kubernetes_service(
active: true,
properties: {
namespace: project.path,
api_url: 'https://kubernetes.example.com',
token: 'a' * 40,
}
)
end
end end
end end
...@@ -12,4 +12,13 @@ FactoryGirl.define do ...@@ -12,4 +12,13 @@ FactoryGirl.define do
token: 'a' * 40, token: 'a' * 40,
}) })
end end
factory :jira_service do
project factory: :empty_project
active true
properties(
url: 'https://jira.example.com',
project_key: 'jira-key'
)
end
end end
...@@ -42,4 +42,12 @@ describe ExternalIssue, models: true do ...@@ -42,4 +42,12 @@ describe ExternalIssue, models: true do
expect(issue.project_id).to eq(project.id) expect(issue.project_id).to eq(project.id)
end end
end end
describe '#hash' do
it 'returns the hash of its [class, to_s] pair' do
issue_2 = described_class.new(issue.to_s, project)
expect(issue.hash).to eq(issue_2.hash)
end
end
end end
...@@ -346,6 +346,23 @@ describe MergeRequest, models: true do ...@@ -346,6 +346,23 @@ describe MergeRequest, models: true do
expect(subject.issues_mentioned_but_not_closing(subject.author)).to match_array([mentioned_issue]) expect(subject.issues_mentioned_but_not_closing(subject.author)).to match_array([mentioned_issue])
end end
context 'when the project has an external issue tracker' do
before do
subject.project.team << [subject.author, :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)
end
it 'detects issues mentioned in description but not closed' do
expect(subject.issues_mentioned_but_not_closing(subject.author).map(&:to_s)).to match_array(['TEST-2'])
end
end
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