Commit 89d3f117 authored by Sean McGivern's avatar Sean McGivern Committed by Jose Ivan Vargas

Merge branch 'issue_36820' into 'master'

Remove closing external issues by reference error

Closes #36820

See merge request !13910
parent 7f2a49c5
...@@ -598,6 +598,8 @@ class MergeRequest < ActiveRecord::Base ...@@ -598,6 +598,8 @@ class MergeRequest < ActiveRecord::Base
self.merge_requests_closing_issues.delete_all self.merge_requests_closing_issues.delete_all
closes_issues(current_user).each do |issue| closes_issues(current_user).each do |issue|
next if issue.is_a?(ExternalIssue)
self.merge_requests_closing_issues.create!(issue: issue) self.merge_requests_closing_issues.create!(issue: issue)
end end
end end
......
---
title: Remove closing external issues by reference error
merge_request:
author:
type: fixed
...@@ -159,6 +159,7 @@ describe MergeRequest do ...@@ -159,6 +159,7 @@ describe MergeRequest do
before do before do
subject.project.has_external_issue_tracker = true subject.project.has_external_issue_tracker = true
subject.project.save! subject.project.save!
create(:jira_service, project: subject.project)
end end
it 'does not cache issues from external trackers' do it 'does not cache issues from external trackers' do
...@@ -166,6 +167,7 @@ describe MergeRequest do ...@@ -166,6 +167,7 @@ describe MergeRequest do
commit = double('commit1', safe_message: "Fixes #{issue.to_reference}") commit = double('commit1', safe_message: "Fixes #{issue.to_reference}")
allow(subject).to receive(:commits).and_return([commit]) allow(subject).to receive(:commits).and_return([commit])
expect { subject.cache_merge_request_closes_issues!(subject.author) }.not_to raise_error
expect { subject.cache_merge_request_closes_issues!(subject.author) }.not_to change(subject.merge_requests_closing_issues, :count) expect { subject.cache_merge_request_closes_issues!(subject.author) }.not_to change(subject.merge_requests_closing_issues, :count)
end end
......
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