]> source.dussan.org Git - redmine.git/commitdiff
When create by copying the issue, status can not be changed to default (#19553).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 11 Apr 2015 07:09:11 +0000 (07:09 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 11 Apr 2015 07:09:11 +0000 (07:09 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@14158 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 48608f7a704dcb7c20cdd6f07a1cda3e91b50fe3..8bc326eaab55ba530baedcbc904a60ecf5f02c71 100644 (file)
@@ -425,7 +425,7 @@ class IssuesController < ApplicationController
     @issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
 
     if attrs = params[:issue].deep_dup
-      if params[:was_default_status] == attrs[:status_id]
+      if action_name == 'new' && params[:was_default_status] == attrs[:status_id]
         attrs.delete(:status_id)
       end
       @issue.safe_attributes = attrs
index 7685dc127ee31d7930c93e786f32aee43464f367..33a85540e4430c9ced607bb0b318c1d690d631e6 100644 (file)
@@ -2605,6 +2605,20 @@ class IssuesControllerTest < ActionController::TestCase
     assert_equal 'Copy', issue.subject
   end
 
+  def test_create_as_copy_should_allow_status_to_be_set_to_default
+    copied = Issue.generate! :status_id => 2
+    assert_equal 2, copied.reload.status_id
+
+    @request.session[:user_id] = 2
+    assert_difference 'Issue.count' do
+      post :create, :project_id => 1, :copy_from => copied.id,
+        :issue => {:project_id => '1', :tracker_id => '1', :status_id => '1'},
+        :was_default_status => '1'
+    end
+    issue = Issue.order('id DESC').first
+    assert_equal 1, issue.status_id
+  end
+
   def test_create_as_copy_should_copy_attachments
     @request.session[:user_id] = 2
     issue = Issue.find(3)