summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-09 16:04:45 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-09 16:04:45 +0000
commit7537e86fd2e40187fdee8dc5257d49d508d73918 (patch)
tree19c387c731f58203c9d6d441a63974a77ade8337
parent9f6612651cb4c01a196bd279c7f8af314026f2b7 (diff)
downloadredmine-7537e86fd2e40187fdee8dc5257d49d508d73918.tar.gz
redmine-7537e86fd2e40187fdee8dc5257d49d508d73918.zip
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
-rw-r--r--app/controllers/issues_controller.rb4
-rw-r--r--test/functional/issues_controller_test.rb18
2 files changed, 19 insertions, 3 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index c997da940..512293428 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 5f5ea383d..6a3745040 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