Commit 8d3f072e authored by Grzegorz Bizon's avatar Grzegorz Bizon

Take care about data being rewritten when moving issue

parent fbb5a8b0
...@@ -49,9 +49,7 @@ module Issues ...@@ -49,9 +49,7 @@ module Issues
def new_issue_params def new_issue_params
new_params = { id: nil, iid: nil, milestone_id: nil, label_ids: [], new_params = { id: nil, iid: nil, milestone_id: nil, label_ids: [],
project_id: @project_new.id, project_id: @project_new.id,
author_id: @issue_old.author_id, description: rewrite_references(@issue_old) }
description: rewrite_references(@issue_old),
updated_by_id: current_user.id }
params.merge(new_params) params.merge(new_params)
end end
......
...@@ -2,13 +2,18 @@ require 'spec_helper' ...@@ -2,13 +2,18 @@ require 'spec_helper'
describe Issues::MoveService, services: true do describe Issues::MoveService, services: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:author) { create(:user) }
let(:title) { 'Some issue' } let(:title) { 'Some issue' }
let(:description) { 'Some issue description' } let(:description) { 'Some issue description' }
let(:old_project) { create(:project) } let(:old_project) { create(:project) }
let(:old_issue) { create(:issue, title: title, description: description, project: old_project) }
let(:new_project) { create(:project) } let(:new_project) { create(:project) }
let(:issue_params) { old_issue.serializable_hash } let(:issue_params) { old_issue.serializable_hash }
let(:old_issue) do
create(:issue, title: title, description: description,
project: old_project, author: author)
end
let(:move_service) do let(:move_service) do
described_class.new(old_project, user, issue_params, old_issue, new_project_id) described_class.new(old_project, user, issue_params, old_issue, new_project_id)
end end
...@@ -73,6 +78,19 @@ describe Issues::MoveService, services: true do ...@@ -73,6 +78,19 @@ describe Issues::MoveService, services: true do
expect(old_issue.changed?).to be false expect(old_issue.changed?).to be false
expect(new_issue.changed?).to be false expect(new_issue.changed?).to be false
end end
it 'changes author' do
expect(new_issue.author).to eq user
end
it 'removes data that is invalid in new context' do
expect(new_issue.milestone).to be_nil
expect(new_issue.labels).to be_empty
end
it 'creates a new internal id for issue' do
expect(new_issue.iid).to be 1
end
end end
context 'issue with notes' do context 'issue with notes' 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