From 2d3681bb3c9ed8136fc46857828b74ae39b6d990 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Sun, 16 Mar 2008 17:35:11 -0700 Subject: nested orderings --- spec/active_relation/unit/relations/order_spec.rb | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'spec/active_relation') 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 -- cgit v1.2.3