diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-16 17:35:11 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-16 17:35:11 -0700 |
commit | 2d3681bb3c9ed8136fc46857828b74ae39b6d990 (patch) | |
tree | 3d1cb0091a093197499247ddffa8d7515e1ebec6 /spec | |
parent | 7bd0d634867ccbdf4537ba3d62b865b1cb7beebf (diff) | |
download | rails-2d3681bb3c9ed8136fc46857828b74ae39b6d990.tar.gz rails-2d3681bb3c9ed8136fc46857828b74ae39b6d990.tar.bz2 rails-2d3681bb3c9ed8136fc46857828b74ae39b6d990.zip |
nested orderings
Diffstat (limited to 'spec')
-rw-r--r-- | spec/active_relation/unit/relations/order_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/active_relation/unit/relations/order_spec.rb b/spec/active_relation/unit/relations/order_spec.rb index f37a9f26e9..e4f925f21a 100644 --- a/spec/active_relation/unit/relations/order_spec.rb +++ b/spec/active_relation/unit/relations/order_spec.rb @@ -7,6 +7,17 @@ module ActiveRelation @attribute = @relation[:id] end + describe '#initialize' do + before do + @another_attribtue = @relation[:name] + end + + it "manufactures nested Order relations if multiple predicates are provided" do + Order.new(@relation, @predicate, @another_attribute). \ + should == Order.new(Order.new(@relation, @another_attribute), @predicate) + end + end + describe '#qualify' do it "descends" do Order.new(@relation, @attribute).qualify. \ @@ -59,6 +70,21 @@ module ActiveRelation ") end end + + describe "when ordering an ordered relation" do + before do + @ordered_relation = Order.new(@relation, @attribute) + @another_attribute = @relation[:name] + end + + it "manufactures sql with an order clause populated by comma-separated attributes" do + Order.new(@ordered_relation, @another_attribute).to_sql.should be_like(" + SELECT `users`.`id`, `users`.`name` + FROM `users` + ORDER BY `users`.`id`, `users`.`name` + ") + end + end end end end |