mirror of
https://github.com/redmine/redmine.git
synced 2025-11-17 18:50:53 +01:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user