diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-14 09:43:19 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-14 09:43:19 -0800 |
commit | 9653da3c7963834eb9ed93bf24837147fa9b0461 (patch) | |
tree | 08015f4d72cfc5ac615e600de87a953514a59411 /test | |
parent | 87c022bc98c57027f534d5e667cfc0344b5b40f0 (diff) | |
download | rails-9653da3c7963834eb9ed93bf24837147fa9b0461.tar.gz rails-9653da3c7963834eb9ed93bf24837147fa9b0461.tar.bz2 rails-9653da3c7963834eb9ed93bf24837147fa9b0461.zip |
adding a join source node
Diffstat (limited to 'test')
-rw-r--r-- | test/test_factory_methods.rb | 4 | ||||
-rw-r--r-- | test/test_select_manager.rb | 10 | ||||
-rw-r--r-- | test/test_table.rb | 6 | ||||
-rw-r--r-- | test/visitors/test_depth_first.rb | 8 | ||||
-rw-r--r-- | test/visitors/test_join_sql.rb | 13 |
5 files changed, 19 insertions, 22 deletions
diff --git a/test/test_factory_methods.rb b/test/test_factory_methods.rb index 89b10236d1..c40615564f 100644 --- a/test/test_factory_methods.rb +++ b/test/test_factory_methods.rb @@ -12,9 +12,9 @@ module Arel end def test_create_join - join = @factory.create_join :one, :two, :three + join = @factory.create_join :one, :two assert_kind_of Nodes::Join, join - assert_equal :three, join.constraint + assert_equal :two, join.constraint end def test_create_on diff --git a/test/test_select_manager.rb b/test/test_select_manager.rb index dec1c2d8c7..761ebdaee3 100644 --- a/test/test_select_manager.rb +++ b/test/test_select_manager.rb @@ -292,20 +292,18 @@ module Arel it 'should create join nodes' do relation = Arel::SelectManager.new Table.engine - join = relation.create_join 'foo', 'bar', 'baz' + join = relation.create_join 'foo', 'bar' assert_kind_of Arel::Nodes::InnerJoin, join assert_equal 'foo', join.left assert_equal 'bar', join.right - assert_equal 'baz', join.constraint end it 'should create join nodes with a klass' do relation = Arel::SelectManager.new Table.engine - join = relation.create_join 'foo', 'bar', 'baz', Arel::Nodes::OuterJoin + join = relation.create_join 'foo', 'bar', Arel::Nodes::OuterJoin assert_kind_of Arel::Nodes::OuterJoin, join assert_equal 'foo', join.left assert_equal 'bar', join.right - assert_equal 'baz', join.constraint end describe 'join' do @@ -350,7 +348,7 @@ module Arel table = Table.new :users aliaz = table.alias manager = Arel::SelectManager.new Table.engine - manager.from Nodes::InnerJoin.new(table, aliaz, table[:id].eq(aliaz[:id])) + manager.from Nodes::InnerJoin.new(aliaz, table[:id].eq(aliaz[:id])) manager.join_sql.must_be_like %{ INNER JOIN "users" "users_2" "users"."id" = "users_2"."id" } @@ -360,7 +358,7 @@ module Arel table = Table.new :users aliaz = table.alias manager = Arel::SelectManager.new Table.engine - manager.from Nodes::OuterJoin.new(table, aliaz, table[:id].eq(aliaz[:id])) + manager.from Nodes::OuterJoin.new(aliaz, table[:id].eq(aliaz[:id])) manager.join_sql.must_be_like %{ LEFT OUTER JOIN "users" "users_2" "users"."id" = "users_2"."id" } diff --git a/test/test_table.rb b/test/test_table.rb index 42362b563e..54f8b04b79 100644 --- a/test/test_table.rb +++ b/test/test_table.rb @@ -14,19 +14,17 @@ module Arel end it 'should create join nodes' do - join = @relation.create_join 'foo', 'bar', 'baz' + join = @relation.create_join 'foo', 'bar' assert_kind_of Arel::Nodes::InnerJoin, join assert_equal 'foo', join.left assert_equal 'bar', join.right - assert_equal 'baz', join.constraint end it 'should create join nodes with a klass' do - join = @relation.create_join 'foo', 'bar', 'baz', Arel::Nodes::OuterJoin + join = @relation.create_join 'foo', 'bar', Arel::Nodes::OuterJoin assert_kind_of Arel::Nodes::OuterJoin, join assert_equal 'foo', join.left assert_equal 'bar', join.right - assert_equal 'baz', join.constraint end it 'should return an insert manager' do diff --git a/test/visitors/test_depth_first.rb b/test/visitors/test_depth_first.rb index 7d7324f627..23b011c2eb 100644 --- a/test/visitors/test_depth_first.rb +++ b/test/visitors/test_depth_first.rb @@ -66,15 +66,15 @@ module Arel end def test_inner_join - join = Nodes::InnerJoin.new :a, :b, :c + join = Nodes::InnerJoin.new :a, :b @visitor.accept join - assert_equal [:a, :b, :c, join], @collector.calls + assert_equal [:a, :b, join], @collector.calls end def test_outer_join - join = Nodes::OuterJoin.new :a, :b, :c + join = Nodes::OuterJoin.new :a, :b @visitor.accept join - assert_equal [:a, :b, :c, join], @collector.calls + assert_equal [:a, :b, join], @collector.calls end [ diff --git a/test/visitors/test_join_sql.rb b/test/visitors/test_join_sql.rb index 181ef6c570..b0eba172e6 100644 --- a/test/visitors/test_join_sql.rb +++ b/test/visitors/test_join_sql.rb @@ -11,9 +11,9 @@ module Arel 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 %{ + sm = t.select_manager + sm.join(t).on(t[:id]).join(t).on(t[:id]) + sm.join_sql.must_be_like %{ INNER JOIN "users" ON "users"."id" INNER JOIN "users" ON "users"."id" } @@ -23,9 +23,10 @@ module Arel 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 %{ + sm = t.select_manager + sm.join(t, Nodes::OuterJoin).on(t[:id]).join( + t, Nodes::OuterJoin).on(t[:id]) + sm.join_sql.must_be_like %{ LEFT OUTER JOIN "users" ON "users"."id" LEFT OUTER JOIN "users" ON "users"."id" } |