Permalink
Browse files

Added a test for my pull request

  • Loading branch information...
1 parent 033d0ef commit 2c1ca4617616698f84e6092121d2c0f53b9d35e2 @dubroe dubroe committed Jun 2, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 test/test_list.rb
View
@@ -234,6 +234,18 @@ def test_insert_at
new4.reload
assert_equal 4, new4.pos
end
+
+ def test_update_position
+ assert_equal [1, 2, 3, 4], DefaultScopedMixin.find(:all).map(&:id)
+ DefaultScopedMixin.find(2).update_attribute(:pos, 4)
+ assert_equal [1, 3, 4, 2], DefaultScopedMixin.find(:all).map(&:id)
+ DefaultScopedMixin.find(2).update_attribute(:pos, 2)
+ assert_equal [1, 2, 3, 4], DefaultScopedMixin.find(:all).map(&:id)
+ DefaultScopedMixin.find(1).update_attribute(:pos, 4)
+ assert_equal [2, 3, 4, 1], DefaultScopedMixin.find(:all).map(&:id)
+ DefaultScopedMixin.find(1).update_attribute(:pos, 1)
+ assert_equal [1, 2, 3, 4], DefaultScopedMixin.find(:all).map(&:id)
+ end
end

0 comments on commit 2c1ca46

Please sign in to comment.