From: Jean-Philippe Lang Date: Wed, 9 Dec 2009 16:04:45 +0000 (+0000) Subject: Fixes that issue copy/move throws an error when status is not changed (#4369). X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=7537e86fd2e40187fdee8dc5257d49d508d73918;p=redminele%2Fredmine.git Fixes that issue copy/move throws an error when status is not changed (#4369). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3148 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index c997da94..51229342 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -296,7 +296,9 @@ class IssuesController < ApplicationController @issues.each do |issue| changed_attributes = {} [:assigned_to_id, :status_id, :start_date, :due_date].each do |valid_attribute| - changed_attributes[valid_attribute] = params[valid_attribute] if params[valid_attribute] + unless params[valid_attribute].blank? + changed_attributes[valid_attribute] = (params[valid_attribute] == 'none' ? nil : params[valid_attribute]) + end end issue.init_journal(User.current) if r = issue.move_to(@target_project, new_tracker, {:copy => @copy, :attributes => changed_attributes}) diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 5f5ea383..6a374504 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -1049,7 +1049,7 @@ class IssuesControllerTest < ActionController::TestCase def test_move_one_issue_to_another_project @request.session[:user_id] = 2 - post :move, :id => 1, :new_project_id => 2 + post :move, :id => 1, :new_project_id => 2, :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_equal 2, Issue.find(1).project_id end @@ -1091,11 +1091,25 @@ class IssuesControllerTest < ActionController::TestCase end context "#move via bulk copy" do + should "allow not changing the issue's attributes" do + @request.session[:user_id] = 2 + issue_before_move = Issue.find(1) + assert_difference 'Issue.count', 1 do + assert_no_difference 'Project.find(1).issues.count' do + post :move, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' + end + end + issue_after_move = Issue.first(:order => 'id desc', :conditions => {:project_id => 2}) + assert_equal issue_before_move.tracker_id, issue_after_move.tracker_id + assert_equal issue_before_move.status_id, issue_after_move.status_id + assert_equal issue_before_move.assigned_to_id, issue_after_move.assigned_to_id + end + should "allow changing the issue's attributes" do @request.session[:user_id] = 2 assert_difference 'Issue.count', 2 do assert_no_difference 'Project.find(1).issues.count' do - post :move, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}, :assigned_to_id => 4, :status_id => 3, :start_date => '2009-12-01', :due_date => '2009-12-31' + post :move, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => 4, :status_id => 3, :start_date => '2009-12-01', :due_date => '2009-12-31' end end