aboutsummaryrefslogtreecommitdiffstats
path: root/spec/active_relation/unit/relations/order_spec.rb
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-03-16 17:27:40 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-03-16 17:27:40 -0700
commit7bd0d634867ccbdf4537ba3d62b865b1cb7beebf (patch)
treef469465c385a99722b2263cae5f68a1a961a3c76 /spec/active_relation/unit/relations/order_spec.rb
parentaa5c9a19826c84bbb9c9f75f8d1a4b04b874780c (diff)
downloadrails-7bd0d634867ccbdf4537ba3d62b865b1cb7beebf.tar.gz
rails-7bd0d634867ccbdf4537ba3d62b865b1cb7beebf.tar.bz2
rails-7bd0d634867ccbdf4537ba3d62b865b1cb7beebf.zip
allowing string passthrough for order clauses
Diffstat (limited to 'spec/active_relation/unit/relations/order_spec.rb')
-rw-r--r--spec/active_relation/unit/relations/order_spec.rb42
1 files changed, 36 insertions, 6 deletions
diff --git a/spec/active_relation/unit/relations/order_spec.rb b/spec/active_relation/unit/relations/order_spec.rb
index 6a9ce07024..f37a9f26e9 100644
--- a/spec/active_relation/unit/relations/order_spec.rb
+++ b/spec/active_relation/unit/relations/order_spec.rb
@@ -22,12 +22,42 @@ module ActiveRelation
end
describe '#to_sql' do
- it "manufactures sql with an order clause" do
- Order.new(@relation, @attribute).to_sql.should be_like("
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- ORDER BY `users`.`id`
- ")
+ describe "when given an attribute" do
+ it "manufactures sql with an order clause populated by the attribute" do
+ Order.new(@relation, @attribute).to_sql.should be_like("
+ SELECT `users`.`id`, `users`.`name`
+ FROM `users`
+ ORDER BY `users`.`id`
+ ")
+ end
+ end
+
+ describe "when given multiple attributes" do
+ before do
+ @another_attribute = @relation[:name]
+ end
+
+ it "manufactures sql with an order clause populated by comma-separated attributes" do
+ Order.new(@relation, @attribute, @another_attribute).to_sql.should be_like("
+ SELECT `users`.`id`, `users`.`name`
+ FROM `users`
+ ORDER BY `users`.`id`, `users`.`name`
+ ")
+ end
+ end
+
+ describe "when given a string" do
+ before do
+ @string = "asdf".bind(@relation)
+ end
+
+ it "passes the string through to the order clause" do
+ Order.new(@relation, @string).to_sql.should be_like("
+ SELECT `users`.`id`, `users`.`name`
+ FROM `users`
+ ORDER BY asdf
+ ")
+ end
end
end
end