Sha256: fe00287651a7f67972b36ef36bcf5dbd590fe5e2601bc935dd06cb571db851d7

Contents?: true

Size: 1.13 KB

Versions: 93

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
        @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

93 entries across 75 versions & 14 rubygems

Version Path
challah-0.9.0 vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
challah-rolls-0.2.0 vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
challah-0.8.3 vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
challah-0.8.1 vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
challah-rolls-0.1.0 vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
challah-rolls-0.1.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
challah-0.8.0.pre vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
challah-0.7.1 vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
challah-0.7.0 vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
challah-0.7.0.pre2 vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
challah-0.7.0.pre vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
challah-0.6.2 vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/test/visitors/test_join_sql.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/test/visitors/test_join_sql.rb
initforthe-cookies-0.0.1 vendor/bundle/gems/arel-3.0.2/test/visitors/test_join_sql.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/test/visitors/test_join_sql.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/test/visitors/test_join_sql.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/test/visitors/test_join_sql.rb