Permalink
Browse files

Make acts_as_list work for insert_at(1) #1966 [hensleyl@papermountain…

….org]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2008 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent e17bf81 commit 85c603fc9ea94aae98255bb5bd8e20212441ff2e @jamis jamis committed Aug 14, 2005
Showing with 12 additions and 1 deletion.
  1. +2 −0 activerecord/CHANGELOG
  2. +1 −1 activerecord/lib/active_record/acts/list.rb
  3. +9 −0 activerecord/test/mixin_test.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Make acts_as_list work for insert_at(1) #1966 [hensleyl@papermountain.org]
+
* Fix typo in count_by_sql documentation #1969 [Alexey Verkhovsky]
* Allow add_column and create_table to specify NOT NULL #1712 [emptysands@gmail.com]
@@ -72,7 +72,7 @@ def position_column
# the first in the list of all chapters.
module InstanceMethods
def insert_at(position = 1)
- position == 1 ? add_to_list_top : insert_at_position(position)
+ insert_at_position(position)
end
def move_lower
@@ -142,6 +142,15 @@ def test_insert_at
new4.reload
assert_equal 4, new4.pos
+
+ new5 = ListMixin.create("parent_id" => 20)
+ assert_equal 5, new5.pos
+
+ new5.insert_at(1)
+ assert_equal 1, new5.pos
+
+ new4.reload
+ assert_equal 5, new4.pos
end
def test_delete_middle

0 comments on commit 85c603f

Please sign in to comment.