summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-01-09 08:41:39 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-01-09 08:41:39 +0000
commit72ba180cba5fb3b8d347fccca41cc827ebd59a78 (patch)
tree5fa61f897d5bf94fad2a29ee9460daf747295c60
parent4a98b7d58f47de005b411a5fcc2a9c13cc1fc99e (diff)
downloadredmine-72ba180cba5fb3b8d347fccca41cc827ebd59a78.tar.gz
redmine-72ba180cba5fb3b8d347fccca41cc827ebd59a78.zip
Merged r14988 and r14988 (#21504).
git-svn-id: http://svn.redmine.org/redmine/branches/3.1-stable@15015 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/issue_priority.rb2
-rw-r--r--test/unit/issue_priority_test.rb14
2 files changed, 15 insertions, 1 deletions
diff --git a/app/models/issue_priority.rb b/app/models/issue_priority.rb
index b925c3e04..e5b2d473f 100644
--- a/app/models/issue_priority.rb
+++ b/app/models/issue_priority.rb
@@ -19,7 +19,7 @@ class IssuePriority < Enumeration
has_many :issues, :foreign_key => 'priority_id'
after_destroy {|priority| priority.class.compute_position_names}
- after_save {|priority| priority.class.compute_position_names if priority.position_changed? && priority.position}
+ after_save {|priority| priority.class.compute_position_names if (priority.position_changed? && priority.position) || priority.active_changed?}
OptionName = :enumeration_issue_priorities
diff --git a/test/unit/issue_priority_test.rb b/test/unit/issue_priority_test.rb
index e9d44b68e..afce3688a 100644
--- a/test/unit/issue_priority_test.rb
+++ b/test/unit/issue_priority_test.rb
@@ -99,6 +99,20 @@ class IssuePriorityTest < ActiveSupport::TestCase
assert_equal %w(lowest default high4 high3 high2 highest), IssuePriority.active.to_a.sort.map(&:position_name)
end
+ def test_moving_a_priority_should_update_position_names
+ prio = IssuePriority.first
+ prio.move_to = 'lowest'
+ prio.reload
+ assert_equal 'highest', prio.position_name
+ end
+
+ def test_deactivating_a_priority_should_update_position_names
+ prio = IssuePriority.active.order(:position).last
+ prio.active = false
+ prio.save
+ assert_equal 'highest', IssuePriority.active.order(:position).last.position_name
+ end
+
def test_destroying_a_priority_should_update_position_names
IssuePriority.find_by_position_name('highest').destroy
assert_equal %w(lowest default high2 highest), IssuePriority.active.to_a.sort.map(&:position_name)