aboutsummaryrefslogtreecommitdiffstats
path: root/spec/attributes
diff options
context:
space:
mode:
authorErnie Miller <ernie@metautonomo.us>2010-09-29 20:08:57 -0400
committerErnie Miller <ernie@metautonomo.us>2010-09-29 20:08:57 -0400
commiteef61ab909b614ce6f2d100cfb50044c063bc24a (patch)
treeeaa50f239fab9b1b3ed88be89ba743b5724fb19a /spec/attributes
parentf5b76c220ed6583628a84fd899fbb24c39c997ee (diff)
downloadrails-eef61ab909b614ce6f2d100cfb50044c063bc24a.tar.gz
rails-eef61ab909b614ce6f2d100cfb50044c063bc24a.tar.bz2
rails-eef61ab909b614ce6f2d100cfb50044c063bc24a.zip
Support Attribute#asc and Attribute#desc to create orderings
Diffstat (limited to 'spec/attributes')
-rw-r--r--spec/attributes/attribute_spec.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/attributes/attribute_spec.rb b/spec/attributes/attribute_spec.rb
index c6d4fcebd4..562781ade9 100644
--- a/spec/attributes/attribute_spec.rb
+++ b/spec/attributes/attribute_spec.rb
@@ -601,6 +601,38 @@ module Arel
}
end
end
+
+ describe '#asc' do
+ it 'should create an Ordering node' do
+ relation = Table.new(:users)
+ relation[:id].asc.should be_kind_of Nodes::Ordering
+ end
+
+ it 'should generate ASC in sql' do
+ relation = Table.new(:users)
+ mgr = relation.project relation[:id]
+ mgr.order relation[:id].asc
+ mgr.to_sql.should be_like %{
+ SELECT "users"."id" FROM "users" ORDER BY "users"."id" ASC
+ }
+ end
+ end
+
+ describe '#desc' do
+ it 'should create an Ordering node' do
+ relation = Table.new(:users)
+ relation[:id].desc.should be_kind_of Nodes::Ordering
+ end
+
+ it 'should generate DESC in sql' do
+ relation = Table.new(:users)
+ mgr = relation.project relation[:id]
+ mgr.order relation[:id].desc
+ mgr.to_sql.should be_like %{
+ SELECT "users"."id" FROM "users" ORDER BY "users"."id" DESC
+ }
+ end
+ end
end
describe 'equality' do