diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-06-09 07:27:43 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-06-09 07:27:43 +0000 |
commit | 2314e41474b8d15fa7fa496de2b93875429adb5e (patch) | |
tree | 0d2c81700e858805a15ec900dd4b30a6686e4af3 /test/unit | |
parent | 77bac4b14d3bdf0ec53d88ee4aef05471bd8d198 (diff) | |
download | redmine-2314e41474b8d15fa7fa496de2b93875429adb5e.tar.gz redmine-2314e41474b8d15fa7fa496de2b93875429adb5e.zip |
Priorities have the same position and can't be reordered (#11098).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9781 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/issue_priority_test.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/test/unit/issue_priority_test.rb b/test/unit/issue_priority_test.rb index 349cc2e4b..96d58196c 100644 --- a/test/unit/issue_priority_test.rb +++ b/test/unit/issue_priority_test.rb @@ -47,5 +47,30 @@ class IssuePriorityTest < ActiveSupport::TestCase def test_option_name assert_equal :enumeration_issue_priorities, IssuePriority.new.option_name end -end + def test_should_be_created_at_last_position + IssuePriority.delete_all + + priorities = [1, 2, 3].map {|i| IssuePriority.create!(:name => "P#{i}")} + assert_equal [1, 2, 3], priorities.map(&:position) + end + + def test_reset_positions_in_list_should_set_sequential_positions + IssuePriority.delete_all + + priorities = [1, 2, 3].map {|i| IssuePriority.create!(:name => "P#{i}")} + priorities[0].update_attribute :position, 4 + priorities[1].update_attribute :position, 2 + priorities[2].update_attribute :position, 7 + assert_equal [4, 2, 7], priorities.map(&:reload).map(&:position) + + priorities[0].reset_positions_in_list + assert_equal [2, 1, 3], priorities.map(&:reload).map(&:position) + end + + def test_moving_in_list_should_reset_positions + priority = IssuePriority.first + priority.expects(:reset_positions_in_list).once + priority.move_to = 'higher' + end +end |