summaryrefslogtreecommitdiffstats
path: root/test/unit/enumeration_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-09-30 18:35:50 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-09-30 18:35:50 +0000
commit043264b6510cabc7b40b0c124483f9e486798858 (patch)
treeac23f72eb6f4d41458e410b71b887fec8e66681a /test/unit/enumeration_test.rb
parent44644679908ca0d292a9aa5113d5d93d2aa754f6 (diff)
downloadredmine-043264b6510cabc7b40b0c124483f9e486798858.tar.gz
redmine-043264b6510cabc7b40b0c124483f9e486798858.zip
Forces enumeration override position to the same as its parent (#19657).
git-svn-id: http://svn.redmine.org/redmine/trunk@14627 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/enumeration_test.rb')
-rw-r--r--test/unit/enumeration_test.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/unit/enumeration_test.rb b/test/unit/enumeration_test.rb
index 8f5f758d4..ac5e15c4c 100644
--- a/test/unit/enumeration_test.rb
+++ b/test/unit/enumeration_test.rb
@@ -127,4 +127,48 @@ class EnumerationTest < ActiveSupport::TestCase
assert_equal Enumeration, klass.superclass
end
end
+
+ def test_list_should_be_scoped_for_each_type
+ Enumeration.delete_all
+
+ a = IssuePriority.create!(:name => 'A')
+ b = IssuePriority.create!(:name => 'B')
+ c = DocumentCategory.create!(:name => 'C')
+
+ assert_equal [1, 2, 1], [a, b, c].map(&:reload).map(&:position)
+ end
+
+ def test_override_should_be_created_with_same_position_as_parent
+ Enumeration.delete_all
+
+ a = IssuePriority.create!(:name => 'A')
+ b = IssuePriority.create!(:name => 'B')
+ override = IssuePriority.create!(:name => 'BB', :parent_id => b.id)
+
+ assert_equal [1, 2, 2], [a, b, override].map(&:reload).map(&:position)
+ end
+
+ def test_override_position_should_be_updated_with_parent_position
+ Enumeration.delete_all
+
+ a = IssuePriority.create!(:name => 'A')
+ b = IssuePriority.create!(:name => 'B')
+ override = IssuePriority.create!(:name => 'BB', :parent_id => b.id)
+ b.move_to = 'higher'
+
+ assert_equal [2, 1, 1], [a, b, override].map(&:reload).map(&:position)
+ end
+
+ def test_destroying_override_should_not_update_positions
+ Enumeration.delete_all
+
+ a = IssuePriority.create!(:name => 'A')
+ b = IssuePriority.create!(:name => 'B')
+ c = IssuePriority.create!(:name => 'C')
+ override = IssuePriority.create!(:name => 'BB', :parent_id => b.id)
+ assert_equal [1, 2, 3, 2], [a, b, c, override].map(&:reload).map(&:position)
+
+ override.destroy
+ assert_equal [1, 2, 3], [a, b, c].map(&:reload).map(&:position)
+ end
end