Sha256: f775939761302c024374e90f090c2292ab8ac244be4f8a84a904329f6c7e703a

Contents?: true

Size: 798 Bytes

Versions: 6

Compression:

Stored size: 798 Bytes

Contents

module Apartment
  module Test
    
    extend self
    
    def reset
      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") } rescue true
    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
    
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
dr-apartment-0.14.1 spec/support/apartment_helpers.rb
apartment-0.14.1 spec/support/apartment_helpers.rb
apartment-0.14.0 spec/support/apartment_helpers.rb
apartment-0.13.1 spec/support/apartment_helpers.rb
apartment-0.13.0 spec/support/apartment_helpers.rb
apartment-0.12.0 spec/support/apartment_helpers.rb