]> source.dussan.org Git - redmine.git/commitdiff
Merged r16619 (#26072).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 7 Jun 2017 19:33:15 +0000 (19:33 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 7 Jun 2017 19:33:15 +0000 (19:33 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@16628 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb
test/unit/issue_test.rb

index 2d72dfbec753c670cc61c48cdf6fbba14df016ac..4f9520cc7a76a386fad94769b9f61748ba31b130 100644 (file)
@@ -103,8 +103,8 @@ class Issue < ActiveRecord::Base
     ids.any? ? where(:assigned_to_id => ids) : none
   }
 
+  before_validation :default_assign, on: :create
   before_validation :clear_disabled_fields
-  before_create :default_assign
   before_save :close_duplicates, :update_done_ratio_from_issue_status,
               :force_updated_on_change, :update_closed_on, :set_assigned_to_was
   after_save {|issue| issue.send :after_project_change if !issue.id_changed? && issue.project_id_changed?}
index b977032441737694b8d4964593c18c720112b130..1b26ace145e88f6d283020701c2334f4e4218de7 100644 (file)
@@ -605,6 +605,18 @@ class IssueTest < ActiveSupport::TestCase
     assert_equal version, issue.fixed_version
   end
 
+  def test_default_assigned_to_with_required_assignee_should_validate
+    category = IssueCategory.create!(:project_id => 1, :name => 'With default assignee', :assigned_to_id => 3)
+    Issue.any_instance.stubs(:required_attribute_names).returns(['assigned_to_id'])
+
+    issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :subject => 'Default')
+    assert !issue.save
+    assert issue.errors['assigned_to_id'].present?
+
+    issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :subject => 'Default', :category_id => category.id)
+    assert_save issue
+  end
+
   def test_should_not_update_custom_fields_on_changing_tracker_with_different_custom_fields
     issue = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1,
                           :status_id => 1, :subject => 'Test',