From 85882d1b26b033afb2643865afe6410673949d32 Mon Sep 17 00:00:00 2001 From: Arthur Taylor Date: Thu, 28 Apr 2011 10:11:50 +0200 Subject: Add support for ordering on expressions Conflicts: lib/arel.rb lib/arel/attributes/attribute.rb lib/arel/nodes/infix_operation.rb lib/arel/nodes/named_function.rb Conflicts: lib/arel.rb lib/arel/attributes/attribute.rb --- test/test_select_manager.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test') diff --git a/test/test_select_manager.rb b/test/test_select_manager.rb index 8de1520b6f..29d317e16a 100644 --- a/test/test_select_manager.rb +++ b/test/test_select_manager.rb @@ -484,6 +484,29 @@ module Arel manager = Arel::SelectManager.new Table.engine manager.order(table[:id]).must_equal manager end + + it 'has order attributes' do + table = Table.new :users + manager = Arel::SelectManager.new Table.engine + manager.project SqlLiteral.new '*' + manager.from table + manager.order table[:id].desc + manager.to_sql.must_be_like %{ + SELECT * FROM "users" ORDER BY "users"."id" DESC + } + end + + it 'has order attributes for expressions' do + table = Table.new :users + manager = Arel::SelectManager.new Table.engine + manager.project SqlLiteral.new '*' + manager.from table + manager.order table[:id].count.desc + manager.to_sql.must_be_like %{ + SELECT * FROM "users" ORDER BY COUNT("users"."id") DESC + } + end + end describe 'on' do -- cgit v1.2.3