diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_select_manager.rb | 28 | ||||
-rw-r--r-- | test/test_table.rb | 14 |
2 files changed, 42 insertions, 0 deletions
diff --git a/test/test_select_manager.rb b/test/test_select_manager.rb index 837486fb46..09608ea71e 100644 --- a/test/test_select_manager.rb +++ b/test/test_select_manager.rb @@ -579,6 +579,28 @@ module Arel end end + describe 'outer join' do + it 'responds to join' do + left = Table.new :users + right = left.alias + predicate = left[:id].eq(right[:id]) + manager = Arel::SelectManager.new Table.engine + + manager.from left + manager.outer_join(right).on(predicate) + manager.to_sql.must_be_like %{ + SELECT FROM "users" + LEFT OUTER JOIN "users" "users_2" + ON "users"."id" = "users_2"."id" + } + end + + it 'noops on nil' do + manager = Arel::SelectManager.new Table.engine + manager.outer_join(nil).must_equal manager + end + end + describe 'joins' do it 'returns join sql' do table = Table.new :users @@ -1073,6 +1095,12 @@ module Arel manager.distinct(false) manager.ast.cores.last.set_quantifier.must_equal nil end + + it "chains" do + manager = Arel::SelectManager.new Table.engine + manager.distinct.must_equal manager + manager.distinct(false).must_equal manager + end end end end diff --git a/test/test_table.rb b/test/test_table.rb index 1591d1e49c..14256475ec 100644 --- a/test/test_table.rb +++ b/test/test_table.rb @@ -112,6 +112,20 @@ module Arel } end end + + describe 'join' do + it 'creates an outer join' do + right = @relation.alias + predicate = @relation[:id].eq(right[:id]) + mgr = @relation.outer_join(right).on(predicate) + + mgr.to_sql.must_be_like %{ + SELECT FROM "users" + LEFT OUTER JOIN "users" "users_2" + ON "users"."id" = "users_2"."id" + } + end + end end describe 'group' do |