Commit fed3f718 authored by Timothy Andrew's avatar Timothy Andrew

Fix `User#to_reference`

1. Changes in 8.13 require `Referable`s that don't have a project
   reference to accept two arguments - `from_project` and
   `target_project`.

2. `User#to_reference` was not changed to accept the
   `target_project` (even though it is not used). Moving an issue
   containing a user reference would throw a "invalid number of
   arguments" exception.

Fixes #23662
parent 132e3f54
...@@ -309,7 +309,7 @@ class User < ActiveRecord::Base ...@@ -309,7 +309,7 @@ class User < ActiveRecord::Base
username username
end end
def to_reference(_from_project = nil) def to_reference(_from_project = nil, _target_project = nil)
"#{self.class.reference_prefix}#{username}" "#{self.class.reference_prefix}#{username}"
end end
......
...@@ -207,10 +207,10 @@ describe Issues::MoveService, services: true do ...@@ -207,10 +207,10 @@ describe Issues::MoveService, services: true do
end end
end end
describe 'rewritting references' do describe 'rewriting references' do
include_context 'issue move executed' include_context 'issue move executed'
context 'issue reference' do context 'issue references' do
let(:another_issue) { create(:issue, project: old_project) } let(:another_issue) { create(:issue, project: old_project) }
let(:description) { "Some description #{another_issue.to_reference}" } let(:description) { "Some description #{another_issue.to_reference}" }
...@@ -219,6 +219,16 @@ describe Issues::MoveService, services: true do ...@@ -219,6 +219,16 @@ describe Issues::MoveService, services: true do
.to eq "Some description #{old_project.to_reference}#{another_issue.to_reference}" .to eq "Some description #{old_project.to_reference}#{another_issue.to_reference}"
end end
end end
context "user references" do
let(:another_issue) { create(:issue, project: old_project) }
let(:description) { "Some description #{user.to_reference}" }
it "doesn't throw any errors for issues containing user references" do
expect(new_issue.description)
.to eq "Some description #{user.to_reference}"
end
end
end end
context 'moving to same project' do context 'moving to same project' 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