Sha256: 6e831a1c76b8266598dbc5ed9d2be34334f56bb9abeb1ccabc00bb877d6d93e5

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 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_warnings{ 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

8 entries across 8 versions & 2 rubygems

Version Path
ros-apartment-2.3.0 spec/support/apartment_helpers.rb
ros-apartment-2.3.0.alpha2 spec/support/apartment_helpers.rb
ros-apartment-2.3.0.alpha1 spec/support/apartment_helpers.rb
apartment-2.2.1 spec/support/apartment_helpers.rb
apartment-2.2.0 spec/support/apartment_helpers.rb
apartment-2.1.0 spec/support/apartment_helpers.rb
apartment-2.0.0 spec/support/apartment_helpers.rb
apartment-1.2.0 spec/support/apartment_helpers.rb