diff options
author | John Mileham <jmileham@gmail.com> | 2011-03-25 02:13:21 +0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-03-25 04:14:20 +0800 |
commit | f771b71d1d7cb75e4d19b85e33a85f659088f17f (patch) | |
tree | 81ff9f1a36ae52e017640191ee5f9de558fd117a /test | |
parent | 2b27e653f7be7649f56b834543bcaf27e2b44c74 (diff) | |
download | rails-f771b71d1d7cb75e4d19b85e33a85f659088f17f.tar.gz rails-f771b71d1d7cb75e4d19b85e33a85f659088f17f.tar.bz2 rails-f771b71d1d7cb75e4d19b85e33a85f659088f17f.zip |
Make SelectManager#as act like node predications
Diffstat (limited to 'test')
-rw-r--r-- | test/test_select_manager.rb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/test/test_select_manager.rb b/test/test_select_manager.rb index 799c9fe453..7f276d071f 100644 --- a/test/test_select_manager.rb +++ b/test/test_select_manager.rb @@ -91,6 +91,22 @@ module Arel end end + describe 'as' do + it 'makes an AS node by grouping the AST' do + manager = Arel::SelectManager.new Table.engine + as = manager.as(Arel.sql('foo')) + assert_kind_of Arel::Nodes::Grouping, as.left + assert_equal manager.ast, as.left.expr + assert_equal 'foo', as.right + end + + it 'converts right to SqlLiteral if a string' do + manager = Arel::SelectManager.new Table.engine + as = manager.as('foo') + assert_kind_of Arel::Nodes::SqlLiteral, as.right + end + end + describe 'from' do it 'ignores strings when table of same name exists' do table = Table.new :users @@ -111,8 +127,8 @@ module Arel manager2.from table manager1.project Arel.sql('lol') - as = manager2.as manager2.grouping(manager2.ast), Arel.sql('omg') - manager1.from as + as = manager2.as Arel.sql('omg') + manager1.from(as) manager1.to_sql.must_be_like %{ SELECT lol FROM (SELECT * FROM "users" ) AS omg |