Permalink
Browse files

Fixed acts_as_list for definitions without an explicit :order #2803 […

…jonathan@bluewire.net.nz]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2951 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent e6f412d commit bc7ec23f4ef9ee5f8a8e7ec7b17af6652e4d438e @dhh dhh committed Nov 9, 2005
View
@@ -1,9 +1,8 @@
*SVN*
-* Upgrade bundled ruby-mysql 0.2.4 with mysql411 shim (see #440) to ruby-mysql
-0.2.6 with a patchset for 4.1 protocol support. Local change [301] is now a
-part of the main driver; reapplied local change [2182]. Removed GC.start from
-Result.free. [tommy@tmtm.org, akuroda@gmail.com, Doug Fales <doug.fales@gmail.com>, Jeremy Kemper]
+* Fixed acts_as_list for definitions without an explicit :order #2803 [jonathan@bluewire.net.nz]
+
+* Upgrade bundled ruby-mysql 0.2.4 with mysql411 shim (see #440) to ruby-mysql 0.2.6 with a patchset for 4.1 protocol support. Local change [301] is now a part of the main driver; reapplied local change [2182]. Removed GC.start from Result.free. [tommy@tmtm.org, akuroda@gmail.com, Doug Fales <doug.fales@gmail.com>, Jeremy Kemper]
* Correct handling of complex order clauses with SQL Server limit emulation. #2770 [Tom Ward <tom@popdog.net>, Matt B.]
@@ -49,10 +49,10 @@ def acts_as_tree(options = {})
module_eval <<-END
def self.roots
- self.find(:all, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => "#{configuration[:order]}")
+ self.find(:all, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}})
end
def self.root
- self.find(:first, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => "#{configuration[:order]}")
+ self.find(:first, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}})
end
END
@@ -6,6 +6,10 @@ class TreeMixin < Mixin
acts_as_tree :foreign_key => "parent_id", :order => "id"
end
+class TreeMixinWithoutOrder < Mixin
+ acts_as_tree :foreign_key => "parent_id"
+end
+
class ListMixin < Mixin
acts_as_list :column => "pos", :scope => :parent
@@ -35,4 +39,4 @@ class NestedSetWithSymbolScope < Mixin
acts_as_nested_set :scope => :root
def self.table_name() "mixins" end
-end
+end
@@ -28,7 +28,17 @@ tree3_1:
id: 1006
type: TreeMixin
parent_id:
-
+
+tree_without_order_1:
+ id: 1101
+ type: TreeMixinWithoutOrder
+ parent_id:
+
+tree_without_order_2:
+ id: 1100
+ type: TreeMixinWithoutOrder
+ parent_id:
+
# List mixins
<% (1..4).each do |counter| %>
@@ -291,6 +291,18 @@ def test_self_and_siblings
end
end
+class TreeTestWithoutOrder < Test::Unit::TestCase
+ fixtures :mixins
+
+ def test_root
+ assert [mixins(:tree_without_order_1), mixins(:tree_without_order_2)].include?(TreeMixinWithoutOrder.root)
+ end
+
+ def test_roots
+ assert_equal [], [mixins(:tree_without_order_1), mixins(:tree_without_order_2)] - TreeMixinWithoutOrder.roots
+ end
+end
+
class TouchTest < Test::Unit::TestCase
fixtures :mixins

0 comments on commit bc7ec23

Please sign in to comment.