Take care about data being rewritten when moving issue
This commit is contained in:
parent
fbb5a8b089
commit
8d3f072ec4
2 changed files with 20 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue