Commit 23e81bfd authored by Adam Niedzielski's avatar Adam Niedzielski

Ignore external issues when bulk assigning issues to author of merge request.

Fixes #23552
parent 2510345e
...@@ -4,7 +4,7 @@ module MergeRequests ...@@ -4,7 +4,7 @@ module MergeRequests
@assignable_issues ||= begin @assignable_issues ||= begin
if current_user == merge_request.author if current_user == merge_request.author
closes_issues.select do |issue| closes_issues.select do |issue|
!issue.assignee_id? && can?(current_user, :admin_issue, issue) !issue.is_a?(ExternalIssue) && !issue.assignee_id? && can?(current_user, :admin_issue, issue)
end end
else else
[] []
......
...@@ -46,4 +46,16 @@ describe MergeRequests::AssignIssuesService, services: true do ...@@ -46,4 +46,16 @@ describe MergeRequests::AssignIssuesService, services: true do
it 'assigns these to the merge request owner' do it 'assigns these to the merge request owner' do
expect { service.execute }.to change { issue.reload.assignee }.to(user) expect { service.execute }.to change { issue.reload.assignee }.to(user)
end end
it 'ignores external issues' do
external_issue = ExternalIssue.new('JIRA-123', project)
service = described_class.new(
project,
user,
merge_request: merge_request,
closes_issues: [external_issue]
)
expect(service.assignable_issues.count).to eq 0
end
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