Commit e6d6c415 authored by Douwe Maan's avatar Douwe Maan Committed by Rémy Coutable

Merge branch '23662-issue-move-user-reference-exception' into 'master'

Fix `User#to_reference`

Fix the method signature of `User#to_reference` so that moving an issue with a user reference does not throw a "invalid number of arguments" exception.

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.

3. The regression was introduced in [c8b2b3f7](https://gitlab.com/gitlab-org/gitlab-ce/commit/c8b2b3f7c32db873f1bebce3e3b1847ea24d235f#91fabb7ad88bd2fde6fef1c100a719c00e503047_75_79), which expects
   all `Referable`s that don't respond to `:project` to have a `to_reference`
   method that takes two arguments.

Closes #23662

See merge request !7088
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 6d84f057
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
## 8.13.1 (unreleased) ## 8.13.1 (2016-10-25)
- Fix hidden pipeline graph on commit and MR page. !6895 - Fix hidden pipeline graph on commit and MR page. !6895
- Fix Cycle analytics not showing correct data when filtering by date. !6906 - Fix Cycle analytics not showing correct data when filtering by date. !6906
...@@ -16,6 +16,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -16,6 +16,7 @@ Please view this file on the master branch, on stable branches it's out of date.
- Fix bug where labels would be assigned to issues that were moved. !7065 - Fix bug where labels would be assigned to issues that were moved. !7065
- Fix reply-by-email not working due to queue name mismatch. !7068 - Fix reply-by-email not working due to queue name mismatch. !7068
- Fix 404 for group pages when GitLab setup uses relative url. !7071 - Fix 404 for group pages when GitLab setup uses relative url. !7071
- Fix `User#to_reference`. !7088
## 8.13.0 (2016-10-22) ## 8.13.0 (2016-10-22)
......
...@@ -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
......
...@@ -208,10 +208,10 @@ describe Issues::MoveService, services: true do ...@@ -208,10 +208,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}" }
...@@ -220,6 +220,16 @@ describe Issues::MoveService, services: true do ...@@ -220,6 +220,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