diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2017-06-06 21:11:37 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2017-06-06 21:11:37 +0000 |
commit | b997f03211ee904da2667cabc421d40c92142e6c (patch) | |
tree | 850b87e007da4e6516e6e6a393e113d74314f793 | |
parent | ee0e821cc4442e3f88d29a40e88745526a99c136 (diff) | |
download | redmine-b997f03211ee904da2667cabc421d40c92142e6c.tar.gz redmine-b997f03211ee904da2667cabc421d40c92142e6c.zip |
Set default assignee before validation (#26072).
git-svn-id: http://svn.redmine.org/redmine/trunk@16619 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/issue.rb | 2 | ||||
-rw-r--r-- | test/unit/issue_test.rb | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index d5a43ed18..6a072efad 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -105,8 +105,8 @@ class Issue < ActiveRecord::Base end } + 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?} diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index f8fde822c..30afaf87b 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -625,6 +625,18 @@ class IssueTest < ActiveSupport::TestCase assert_equal user, issue.assigned_to 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', |