Sha256: 9e8ae6bab8ae4fd5db2dd95d4df965ca3011ae04df8af17b0365a3ccdf7505be

Contents?: true

Size: 941 Bytes

Versions: 2

Compression:

Stored size: 941 Bytes

Contents

module Apartment
  module Test
    
    extend self
    
    def reset
      Apartment::Database.instance_variable_set :@initialized, nil
      Apartment.excluded_models = nil
      Apartment.use_postgres_schemas = nil
    end
    
    def drop_schema(schema)
      ActiveRecord::Base.silence{ ActiveRecord::Base.connection.execute("DROP SCHEMA IF EXISTS #{schema} CASCADE") }
    end
    
    def create_schema(schema)
      ActiveRecord::Base.connection.execute("CREATE SCHEMA #{schema}")
    end
    
    def load_schema
      silence_stream(STDOUT){ load("#{Rails.root}/db/schema.rb") }
    end
    
    def migrate
      ActiveRecord::Migrator.migrate(Rails.root + ActiveRecord::Migrator.migrations_path)
    end
    
    def rollback
      ActiveRecord::Migrator.rollback(Rails.root + ActiveRecord::Migrator.migrations_path)
    end
    
    private
    
    def sanitize(database)
      database.gsub(/[\W]/,'')
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
apartment-0.11.0 spec/support/apartment_helpers.rb
apartment-0.10.3 spec/support/apartment_helpers.rb