Sha256: 6e9fc809dc3f794028cd6d56d6cfc38293a83943c7657aa97eaaa3c37e368f5a

Contents?: true

Size: 1.04 KB

Versions: 15

Compression:

Stored size: 1.04 KB

Contents

module Apartment
  module Test

    extend self

    def reset
      Apartment.excluded_models = nil
      Apartment.use_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(version = 3)
      file = File.expand_path("../../schemas/v#{version}.rb", __FILE__)

      silence_stream(STDOUT){ load(file) }
    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

15 entries across 15 versions & 1 rubygems

Version Path
apartment-1.0.2 spec/support/apartment_helpers.rb
apartment-1.0.1 spec/support/apartment_helpers.rb
apartment-1.0.0 spec/support/apartment_helpers.rb
apartment-0.26.1 spec/support/apartment_helpers.rb
apartment-0.26.0 spec/support/apartment_helpers.rb
apartment-0.25.2 spec/support/apartment_helpers.rb
apartment-0.25.1 spec/support/apartment_helpers.rb
apartment-0.25.0 spec/support/apartment_helpers.rb
apartment-0.24.3 spec/support/apartment_helpers.rb
apartment-0.24.2 spec/support/apartment_helpers.rb
apartment-0.24.1 spec/support/apartment_helpers.rb
apartment-0.24.0 spec/support/apartment_helpers.rb
apartment-0.23.2 spec/support/apartment_helpers.rb
apartment-0.23.1 spec/support/apartment_helpers.rb
apartment-0.23.0 spec/support/apartment_helpers.rb