Sha256: 1c9a7cd1d24696c356cd3f89cab1cdddc6ce97d672e23dc659879dc2f71271a2

Contents?: true

Size: 1.39 KB

Versions: 16

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

class FirstMigration < Landable::Migration
  self.verbose = false
  def up
    execute 'CREATE SCHEMA test_schema; SET SEARCH_PATH TO test_schema,public;'
  end
end

class RegularMigration < ActiveRecord::Migration
  self.verbose = false
  def up
    execute 'CREATE SCHEMA test_schema; SET SEARCH_PATH TO test_schema,public;'
  end
end

describe Landable::Migration do
  describe 'migrate' do
    let(:connection) { ActiveRecord::Base.connection }

    before(:each) do 
      ActiveRecord::Base.connection_pool.should_receive(:with_connection).and_yield(connection)
    end

    def connection_search_path
      Landable::Migration.connection_search_path connection
    end

    context 'Landable::Migration' do
      it 'should reset the search_path to the original schema_search_path' do
        default_search_path = connection_search_path

        connection.schema_search_path = 'public'
        FirstMigration.migrate(:up)
        connection_search_path.should == 'public'

        connection.schema_search_path = default_search_path
      end
    end

    context 'ActiveRecord::Migration' do
      it 'should NOT reset the search_path to the original schema_search_path' do
        connection.schema_search_path = 'public'

        connection_search_path.should == 'public'
        RegularMigration.migrate(:up)
        connection_search_path.should_not == 'public'
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
landable-1.13.1 spec/lib/landable/migration_spec.rb
landable-1.12.3 spec/lib/landable/migration_spec.rb
landable-1.12.2 spec/lib/landable/migration_spec.rb
landable-1.12.1 spec/lib/landable/migration_spec.rb
landable-1.11.1 spec/lib/landable/migration_spec.rb
landable-1.11.0 spec/lib/landable/migration_spec.rb
landable-1.10.0.rc2 spec/lib/landable/migration_spec.rb
landable-1.10.0.rc1 spec/lib/landable/migration_spec.rb
landable-1.9.2 spec/lib/landable/migration_spec.rb
landable-1.9.1 spec/lib/landable/migration_spec.rb
landable-1.9.0 spec/lib/landable/migration_spec.rb
landable-1.9.0.rc2 spec/lib/landable/migration_spec.rb
landable-1.9.0.rc1 spec/lib/landable/migration_spec.rb
landable-1.8.0 spec/lib/landable/migration_spec.rb
landable-1.7.1.rc1 spec/lib/landable/migration_spec.rb
landable-1.7.0 spec/lib/landable/migration_spec.rb