aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-08-14 08:35:08 +0000
committerJamis Buck <jamis@37signals.com>2005-08-14 08:35:08 +0000
commit85c603fc9ea94aae98255bb5bd8e20212441ff2e (patch)
tree042e38f71f0313607cc9b216f76f23eb141bf9ad /activerecord
parente17bf81823454f490f4df972b570dd54d509e386 (diff)
downloadrails-85c603fc9ea94aae98255bb5bd8e20212441ff2e.tar.gz
rails-85c603fc9ea94aae98255bb5bd8e20212441ff2e.tar.bz2
rails-85c603fc9ea94aae98255bb5bd8e20212441ff2e.zip
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
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rw-r--r--activerecord/lib/active_record/acts/list.rb2
-rw-r--r--activerecord/test/mixin_test.rb9
3 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 23dde00259..b4cad5b4ba 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -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]
diff --git a/activerecord/lib/active_record/acts/list.rb b/activerecord/lib/active_record/acts/list.rb
index f3cb3496d8..425ac3856d 100644
--- a/activerecord/lib/active_record/acts/list.rb
+++ b/activerecord/lib/active_record/acts/list.rb
@@ -72,7 +72,7 @@ module ActiveRecord
# 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
diff --git a/activerecord/test/mixin_test.rb b/activerecord/test/mixin_test.rb
index df03bcd9a7..a6f759432f 100644
--- a/activerecord/test/mixin_test.rb
+++ b/activerecord/test/mixin_test.rb
@@ -142,6 +142,15 @@ class ListTest < Test::Unit::TestCase
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