Defect #26072

Set default assignee before validation

Added by Felix Schäfer 4 months ago. Updated 4 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Issues
Target version:3.2.7
Resolution:Fixed Affected version:3.3.3

Description

Currently the default assignee is set only after validations. This means that when the field is required the default assignee does not work.

The following patch changes setting the default assignee to before the validation:

diff --git a/app/models/issue.rb b/app/models/issue.rb
index 7d411fc94..a5ebfbffa 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?}

26072-reproduce.png (56 KB) Go MAEDA, 2017-05-31 15:32


Related issues

Related to Redmine - Feature #482: Default assignee on each project Closed
Related to Redmine - Feature #26680: Show default assignee when creating new issue New

Associated revisions

Revision 16619
Added by Jean-Philippe Lang 4 months ago

Set default assignee before validation (#26072).

History

#1 Updated by Go MAEDA 4 months ago

  • File 26072-reproduce.png added
  • Status changed from New to Confirmed
  • Target version set to 3.2.7

I can reproduce the problem as follows.
I confirmed that the problem is reproducible and can be fixed by the pasted patch.

#2 Updated by Felix Schäfer 4 months ago

Thank you for confirming this.

Please be aware that this also affects the newly introduced project default assignee, i.e. if an assignee is required and the project has a default assignee the issue will not be created.

Maybe it would be better to make this more explicit by change the "assignee" field to the default project assignee on new issues, and by changing the assignee when changing the category if the assignee wasn't changed yet.

#3 Updated by Go MAEDA 4 months ago

  • Related to Feature #482: Default assignee on each project added

#4 Updated by Jean-Philippe Lang 4 months ago

  • Status changed from Confirmed to Resolved
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

Fix committed in r16619 with a test.

Felix Schäfer wrote:

Maybe it would be better to make this more explicit by change the "assignee" field to the default project assignee on new issues, and by changing the assignee when changing the category if the assignee wasn't changed yet.

Agreed, it would be an interesting improvement.

#5 Updated by Jean-Philippe Lang 4 months ago

  • Status changed from Resolved to Closed

#6 Updated by Toshi MARUYAMA 11 days ago

  • Related to Feature #26680: Show default assignee when creating new issue added

Also available in: Atom PDF