Sha256: b844084d527f1fbc0bbd76b9915830c7e516b4ce00d37211c31b5812d6abcf69

Contents?: true

Size: 1.13 KB

Versions: 31

Compression:

Stored size: 1.13 KB

Contents

require 'helper'

module Arel
  module Visitors
    describe 'the join_sql visitor' do
      before do
        @visitor = ToSql.new Table.engine.connection_pool
        @visitor.extend(JoinSql)
      end

      it 'should visit string join' do
        sql = @visitor.accept Nodes::StringJoin.new('omg')
        sql.must_be_like "'omg'"
      end

      describe 'inner join' do
        it 'should visit left if left is a join' do
          t    = Table.new :users
          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"
          }
        end
      end

      describe 'outer join' do
        it 'should visit left if left is a join' do
          t    = Table.new :users
          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"
          }
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.6.5 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.6.4 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.6.3 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.6.2 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.6.1 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.6.0 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.5.4 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.5.3 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.5.2 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
arel-2.2.3 test/visitors/test_join_sql.rb
arel-2.2.2 test/visitors/test_join_sql.rb
dirty_history-0.5.1 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.5.0 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb
dirty_history-0.4.10 dirty_history/ruby/1.9.1/gems/arel-2.2.1/test/visitors/test_join_sql.rb