Sha256: 1616332b34279ec3cfa68b27927729f76eb2fd746d965dca839e956eeddb17e5

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

begin
  require 'rails/railtie'
  class Tork::Railtie < Rails::Railtie
    config.before_initialize do |app|
      app.config.cache_classes = false
      ActiveSupport::Dependencies.mechanism = :load
    end

    # if using an sqlite3 database for the test environment, make
    # it an in-memory database to support parallel test execution
    config.after_initialize do
      current = ActiveRecord::Base.connection_config
      memory = {:adapter => 'sqlite3', :database => ':memory:'}

      if current[:adapter] == memory[:adapter]
        # ensure that the sqlite3 database is in-memory
        unless current[:database] == memory[:database]
          ActiveRecord::Base.establish_connection memory
        end

        # create application schema if it does not exist
        unless File.exist? schema = "#{Rails.root}/db/schema.rb"
          system 'rake', '--trace', 'db:schema:dump', 'RAILS_ENV=development'
        end

        # apply application schema to in-memory database
        silence_stream(STDOUT) { load schema }
        ActiveRecord::Base.connection.schema_cache.clear!

        # load any seed data into the in-memory database
        if File.exist? seeds = "#{Rails.root}/db/seeds.rb"
          load seeds
        end
      end
    end
  end
rescue LoadError
  warn "tork/config/rails/master: could not set configuration using railties;\n"\
       "you will have to add the following to your test environment manually:\n\t"\
       'config.cache_classes = false'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tork-19.5.0 lib/tork/config/rails/master.rb
tork-19.4.0 lib/tork/config/rails/master.rb