@@ -96,6 +96,7 class Issue < ActiveRecord::Base | |||||
96 | ids.any? ? where(:fixed_version_id => ids) : where('1=0') |
|
96 | ids.any? ? where(:fixed_version_id => ids) : where('1=0') | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
|
99 | before_validation :clear_disabled_fields | |||
99 | before_create :default_assign |
|
100 | before_create :default_assign | |
100 | before_save :close_duplicates, :update_done_ratio_from_issue_status, |
|
101 | before_save :close_duplicates, :update_done_ratio_from_issue_status, | |
101 | :force_updated_on_change, :update_closed_on, :set_assigned_to_was |
|
102 | :force_updated_on_change, :update_closed_on, :set_assigned_to_was | |
@@ -689,7 +690,11 class Issue < ActiveRecord::Base | |||||
689 |
|
690 | |||
690 | # Returns the names of attributes that are journalized when updating the issue |
|
691 | # Returns the names of attributes that are journalized when updating the issue | |
691 | def journalized_attribute_names |
|
692 | def journalized_attribute_names | |
692 | Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on closed_on) |
|
693 | names = Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on closed_on) | |
|
694 | if tracker | |||
|
695 | names -= tracker.disabled_core_fields | |||
|
696 | end | |||
|
697 | names | |||
693 | end |
|
698 | end | |
694 |
|
699 | |||
695 | # Returns the id of the last journal or nil |
|
700 | # Returns the id of the last journal or nil | |
@@ -1590,4 +1595,12 class Issue < ActiveRecord::Base | |||||
1590 | @assigned_to_was = nil |
|
1595 | @assigned_to_was = nil | |
1591 | @previous_assigned_to_id = nil |
|
1596 | @previous_assigned_to_id = nil | |
1592 | end |
|
1597 | end | |
|
1598 | ||||
|
1599 | def clear_disabled_fields | |||
|
1600 | if tracker | |||
|
1601 | tracker.disabled_core_fields.each do |attribute| | |||
|
1602 | send "#{attribute}=", nil | |||
|
1603 | end | |||
|
1604 | end | |||
|
1605 | end | |||
1593 | end |
|
1606 | end |
@@ -502,6 +502,38 class IssueTest < ActiveSupport::TestCase | |||||
502 | assert_equal 'MySQL', issue.custom_field_value(1) |
|
502 | assert_equal 'MySQL', issue.custom_field_value(1) | |
503 | end |
|
503 | end | |
504 |
|
504 | |||
|
505 | def test_changing_tracker_should_clear_disabled_core_fields | |||
|
506 | tracker = Tracker.find(2) | |||
|
507 | tracker.core_fields = tracker.core_fields - %w(due_date) | |||
|
508 | tracker.save! | |||
|
509 | ||||
|
510 | issue = Issue.generate!(:tracker_id => 1, :start_date => Date.today, :due_date => Date.today) | |||
|
511 | issue.save! | |||
|
512 | ||||
|
513 | issue.tracker_id = 2 | |||
|
514 | issue.save! | |||
|
515 | assert_not_nil issue.start_date | |||
|
516 | assert_nil issue.due_date | |||
|
517 | end | |||
|
518 | ||||
|
519 | def test_changing_tracker_should_not_add_cleared_fields_to_journal | |||
|
520 | tracker = Tracker.find(2) | |||
|
521 | tracker.core_fields = tracker.core_fields - %w(due_date) | |||
|
522 | tracker.save! | |||
|
523 | ||||
|
524 | issue = Issue.generate!(:tracker_id => 1, :due_date => Date.today) | |||
|
525 | issue.save! | |||
|
526 | ||||
|
527 | assert_difference 'Journal.count' do | |||
|
528 | issue.init_journal User.find(1) | |||
|
529 | issue.tracker_id = 2 | |||
|
530 | issue.save! | |||
|
531 | assert_nil issue.due_date | |||
|
532 | end | |||
|
533 | journal = Journal.order('id DESC').first | |||
|
534 | assert_equal 1, journal.details.count | |||
|
535 | end | |||
|
536 | ||||
505 | def test_reload_should_reload_custom_field_values |
|
537 | def test_reload_should_reload_custom_field_values | |
506 | issue = Issue.generate! |
|
538 | issue = Issue.generate! | |
507 | issue.custom_field_values = {'2' => 'Foo'} |
|
539 | issue.custom_field_values = {'2' => 'Foo'} |
General Comments 0
You need to be logged in to leave comments.
Login now