ids.any? ? where(:fixed_version_id => ids) : where('1=0')
}
+ 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
# Returns the names of attributes that are journalized when updating the issue
def journalized_attribute_names
- Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on closed_on)
+ names = Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on closed_on)
+ if tracker
+ names -= tracker.disabled_core_fields
+ end
+ names
end
# Returns the id of the last journal or nil
@assigned_to_was = nil
@previous_assigned_to_id = nil
end
+
+ def clear_disabled_fields
+ if tracker
+ tracker.disabled_core_fields.each do |attribute|
+ send "#{attribute}=", nil
+ end
+ end
+ end
end
assert_equal 'MySQL', issue.custom_field_value(1)
end
+ def test_changing_tracker_should_clear_disabled_core_fields
+ tracker = Tracker.find(2)
+ tracker.core_fields = tracker.core_fields - %w(due_date)
+ tracker.save!
+
+ issue = Issue.generate!(:tracker_id => 1, :start_date => Date.today, :due_date => Date.today)
+ issue.save!
+
+ issue.tracker_id = 2
+ issue.save!
+ assert_not_nil issue.start_date
+ assert_nil issue.due_date
+ end
+
+ def test_changing_tracker_should_not_add_cleared_fields_to_journal
+ tracker = Tracker.find(2)
+ tracker.core_fields = tracker.core_fields - %w(due_date)
+ tracker.save!
+
+ issue = Issue.generate!(:tracker_id => 1, :due_date => Date.today)
+ issue.save!
+
+ assert_difference 'Journal.count' do
+ issue.init_journal User.find(1)
+ issue.tracker_id = 2
+ issue.save!
+ assert_nil issue.due_date
+ end
+ journal = Journal.order('id DESC').first
+ assert_equal 1, journal.details.count
+ end
+
def test_reload_should_reload_custom_field_values
issue = Issue.generate!
issue.custom_field_values = {'2' => 'Foo'}