aboutsummaryrefslogtreecommitdiffstats
path: root/spec/attributes/attribute_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/attributes/attribute_spec.rb')
-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