]> source.dussan.org Git - redmine.git/commitdiff
Fixed that bulk copy raises an error on validation failure (#13943).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 4 May 2013 15:18:16 +0000 (15:18 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 4 May 2013 15:18:16 +0000 (15:18 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11788 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
test/functional/issues_controller_test.rb

index 5336d8c2431d5119d33b31f8abb845b91a3e6dbe..327530009c2b4687695b33fe7e2b2f38a0a8fc3a 100644 (file)
@@ -260,13 +260,15 @@ class IssuesController < ApplicationController
       @issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}}
     end
 
-    @issues.each do |issue|
-      issue.reload
+    @issues.each do |orig_issue|
+      orig_issue.reload
       if @copy
-        issue = issue.copy({},
+        issue = orig_issue.copy({},
           :attachments => params[:copy_attachments].present?,
           :subtasks => params[:copy_subtasks].present?
         )
+      else
+        issue = orig_issue
       end
       journal = issue.init_journal(User.current, params[:notes])
       issue.safe_attributes = attributes
@@ -274,7 +276,7 @@ class IssuesController < ApplicationController
       if issue.save
         saved_issues << issue
       else
-        unsaved_issues << issue
+        unsaved_issues << orig_issue
       end
     end
 
index 62c76512511c2d9a07f5d43154b62a166865ce50..43908401be32021196e2c7f8cc016658eab36c31 100644 (file)
@@ -3821,6 +3821,13 @@ class IssuesControllerTest < ActionController::TestCase
     assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
   end
 
+  def test_bulk_copy_with_all_failures_should_display_errors
+    @request.session[:user_id] = 2
+    post :bulk_update, :ids => [1, 2], :copy => '1', :issue => {:start_date => 'foo'}
+
+    assert_response :success
+  end
+
   def test_destroy_issue_with_no_time_entries
     assert_nil TimeEntry.find_by_issue_id(2)
     @request.session[:user_id] = 2