From 8d3f072ec4f01017a4ec2e1d2082bafcf2b58188 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 24 Feb 2016 13:20:08 +0100 Subject: [PATCH] Take care about data being rewritten when moving issue --- app/services/issues/move_service.rb | 4 +--- spec/services/issues/move_service_spec.rb | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb index 510a04e98f7..37aaeb28857 100644 --- a/app/services/issues/move_service.rb +++ b/app/services/issues/move_service.rb @@ -49,9 +49,7 @@ module Issues def new_issue_params new_params = { id: nil, iid: nil, milestone_id: nil, label_ids: [], project_id: @project_new.id, - author_id: @issue_old.author_id, - description: rewrite_references(@issue_old), - updated_by_id: current_user.id } + description: rewrite_references(@issue_old) } params.merge(new_params) end diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index ec913cdde2a..282dfd9187d 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -2,13 +2,18 @@ require 'spec_helper' describe Issues::MoveService, services: true do let(:user) { create(:user) } + let(:author) { create(:user) } let(:title) { 'Some issue' } let(:description) { 'Some issue description' } let(:old_project) { create(:project) } - let(:old_issue) { create(:issue, title: title, description: description, project: old_project) } let(:new_project) { create(:project) } 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 described_class.new(old_project, user, issue_params, old_issue, new_project_id) end @@ -73,6 +78,19 @@ describe Issues::MoveService, services: true do expect(old_issue.changed?).to be false expect(new_issue.changed?).to be false 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 context 'issue with notes' do