diff options
Diffstat (limited to 'test/visitors/test_join_sql.rb')
-rw-r--r-- | test/visitors/test_join_sql.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/visitors/test_join_sql.rb b/test/visitors/test_join_sql.rb new file mode 100644 index 0000000000..3dc70d7dd6 --- /dev/null +++ b/test/visitors/test_join_sql.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +module Arel + module Visitors + describe 'the join_sql visitor' do + before do + @visitor = JoinSql.new Table.engine + end + + describe 'inner join' do + it 'should visit left if left is a join' do + t = Table.new :users + join = Nodes::InnerJoin.new t, t, Nodes::On.new(t[:id]) + j2 = Nodes::InnerJoin.new join, t, Nodes::On.new(t[:id]) + @visitor.accept(j2).must_be_like %{ + INNER JOIN "users" ON "users"."id" + INNER JOIN "users" ON "users"."id" + } + end + end + + describe 'outer join' do + it 'should visit left if left is a join' do + t = Table.new :users + join = Nodes::OuterJoin.new t, t, Nodes::On.new(t[:id]) + j2 = Nodes::OuterJoin.new join, t, Nodes::On.new(t[:id]) + @visitor.accept(j2).must_be_like %{ + LEFT OUTER JOIN "users" ON "users"."id" + LEFT OUTER JOIN "users" ON "users"."id" + } + end + end + end + end +end |