Sha256: 9ee237927234e95a7986074539f23c67228dc0fa091cc7ca8f9ba5a1ad192ebf

Contents?: true

Size: 1015 Bytes

Versions: 6

Compression:

Stored size: 1015 Bytes

Contents

module Apartment
  module Test

    extend self

    def reset
      Apartment.excluded_models = nil
      Apartment.use_postgres_schemas = nil
      Apartment.seed_after_create = nil
      Apartment.default_schema = nil
    end

    def next_db
      @x ||= 0
      "db%d" % @x += 1
    end

    def drop_schema(schema)
      ActiveRecord::Base.connection.execute("DROP SCHEMA IF EXISTS #{schema} CASCADE") rescue true
    end

    # Use this if you don't want to import schema.rb etc... but need the postgres schema to exist
    # basically for speed purposes
    def create_schema(schema)
      ActiveRecord::Base.connection.execute("CREATE SCHEMA #{schema}")
    end

    def load_schema
      silence_stream(STDOUT){ load(Rails.root.join('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 & 1 rubygems

Version Path
apartment-0.18.0 spec/support/apartment_helpers.rb
apartment-0.17.3 spec/support/apartment_helpers.rb
apartment-0.17.2 spec/support/apartment_helpers.rb
apartment-0.17.1 spec/support/apartment_helpers.rb
apartment-0.17.0 spec/support/apartment_helpers.rb
apartment-0.16.0 spec/support/apartment_helpers.rb