tracker.disabled_core_fields.each do |attribute|
send "#{attribute}=", nil
end
+ self.priority_id ||= IssuePriority.default&.id || IssuePriority.active.first.id
self.done_ratio ||= 0
end
end
class Tracker < ActiveRecord::Base
include Redmine::SafeAttributes
- CORE_FIELDS_UNDISABLABLE = %w(project_id tracker_id subject priority_id is_private).freeze
+ CORE_FIELDS_UNDISABLABLE = %w(project_id tracker_id subject is_private).freeze
# Fields that can be disabled
# Other (future) fields should be appended, not inserted!
CORE_FIELDS =
- %w(assigned_to_id category_id fixed_version_id parent_issue_id
+ %w(priority_id assigned_to_id category_id fixed_version_id parent_issue_id
start_date due_date estimated_hours done_ratio description).freeze
CORE_FIELDS_ALL = (CORE_FIELDS_UNDISABLABLE + CORE_FIELDS).freeze
<div class="attributes">
<%= issue_fields_rows do |rows|
rows.left l(:field_status), @issue.status.name, :class => 'status'
- rows.left l(:field_priority), @issue.priority.name, :class => 'priority'
+ unless @issue.disabled_core_fields.include?('priority_id')
+ rows.left l(:field_priority), @issue.priority.name, :class => 'priority'
+ end
unless @issue.disabled_core_fields.include?('assigned_to_id')
rows.left l(:field_assigned_to), (@issue.assigned_to ? link_to_principal(@issue.assigned_to) : "-"), :class => 'assigned-to'
end
assert_select 'input[name=?][value=category_id]', 'tracker[core_fields][]'
assert_select 'input[name=?][value=category_id][checked=checked]', 'tracker[core_fields][]', 0
+ assert_select 'input[name=?][value=priority_id]', 'tracker[core_fields][]'
+ assert_select 'input[name=?][value=priority_id][checked=checked]', 'tracker[core_fields][]', 0
+
assert_select 'input[name=?][value=""][type=hidden]', 'tracker[core_fields][]'
end
assert_save issue
end
+ def test_default_priority_should_be_set_when_priority_field_is_disabled
+ tracker = Tracker.find(1)
+ tracker.core_fields = tracker.core_fields - ['priority_id']
+ tracker.save!
+
+ issue = Issue.new(:project_id => 1, :tracker_id => tracker.id, :author_id => 1, :subject => 'priority_id is disabled')
+ issue.save!
+ assert_equal IssuePriority.default, issue.priority
+ end
+
def test_start_date_format_should_be_validated
set_language_if_valid 'en'
['2012', 'ABC', '2012-15-20'].each do |invalid_date|