class PostgresqlExtensionMigrationTest

Public Instance Methods

setup() click to toggle source
Calls superclass method
# File activerecord/test/cases/adapters/postgresql/extension_migration_test.rb, line 20
def setup
  super

  @connection = ActiveRecord::Base.connection

  unless @connection.supports_extensions?
    return skip("no extension support")
  end

  @old_schema_migration_table_name = ActiveRecord::SchemaMigration.table_name
  @old_table_name_prefix = ActiveRecord::Base.table_name_prefix
  @old_table_name_suffix = ActiveRecord::Base.table_name_suffix

  ActiveRecord::Base.table_name_prefix = "p_"
  ActiveRecord::Base.table_name_suffix = "_s"
  ActiveRecord::SchemaMigration.delete_all rescue nil
  ActiveRecord::SchemaMigration.table_name = "p_schema_migrations_s"
  ActiveRecord::Migration.verbose = false
end
teardown() click to toggle source
Calls superclass method
# File activerecord/test/cases/adapters/postgresql/extension_migration_test.rb, line 40
def teardown
  ActiveRecord::Base.table_name_prefix = @old_table_name_prefix
  ActiveRecord::Base.table_name_suffix = @old_table_name_suffix
  ActiveRecord::SchemaMigration.delete_all rescue nil
  ActiveRecord::Migration.verbose = true
  ActiveRecord::SchemaMigration.table_name = @old_schema_migration_table_name

  super
end
test_disable_extension_migration_ignores_prefix_and_suffix() click to toggle source
# File activerecord/test/cases/adapters/postgresql/extension_migration_test.rb, line 58
def test_disable_extension_migration_ignores_prefix_and_suffix
  @connection.enable_extension("hstore")

  migrations = [DisableHstore.new(nil, 1)]
  ActiveRecord::Migrator.new(:up, migrations).migrate
  assert_not @connection.extension_enabled?("hstore"), "extension hstore should not be enabled"
end
test_enable_extension_migration_ignores_prefix_and_suffix() click to toggle source
# File activerecord/test/cases/adapters/postgresql/extension_migration_test.rb, line 50
def test_enable_extension_migration_ignores_prefix_and_suffix
  @connection.disable_extension("hstore")

  migrations = [EnableHstore.new(nil, 1)]
  ActiveRecord::Migrator.new(:up, migrations).migrate
  assert @connection.extension_enabled?("hstore"), "extension hstore should be enabled"
end