Sha256: 48fadeb8d38791983b9ab100ae2500a834e85a0ae2035a1d0d550de8a7423c99

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

require 'rails/all'

module Clearance
  module Testing
    APP_ROOT = File.expand_path('..', __FILE__).freeze

    def self.rails4?
      Rails::VERSION::MAJOR >= 4
    end

    I18n.enforce_available_locales = true

    class Application < Rails::Application
      config.action_controller.allow_forgery_protection = false
      config.action_controller.perform_caching = false
      config.action_dispatch.show_exceptions = false
      config.action_mailer.default_url_options = { host: 'localhost' }
      config.action_mailer.delivery_method = :test
      config.active_support.deprecation = :stderr
      config.assets.enabled = true
      config.cache_classes = true
      config.consider_all_requests_local = true
      config.eager_load = false
      config.encoding = 'utf-8'
      config.paths['app/controllers'] << "#{APP_ROOT}/app/controllers"
      config.paths['app/views'] << "#{APP_ROOT}/app/views"
      config.paths['config/database'] = "#{APP_ROOT}/config/database.yml"
      config.paths['log'] = 'tmp/log/development.log'
      config.secret_token = 'SECRET_TOKEN_IS_MIN_30_CHARS_LONG'
      config.active_support.test_order = :random

      if Clearance::Testing.rails4?
        config.paths.add 'config/routes.rb', with: "#{APP_ROOT}/config/routes.rb"
        config.secret_key_base = 'SECRET_KEY_BASE'
      else
        config.paths.add 'config/routes', with: "#{APP_ROOT}/config/routes.rb"
      end

      def require_environment!
        initialize!
      end

      def initialize!(&block)
        FileUtils.mkdir_p(Rails.root.join('db').to_s)
        super unless @initialized
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clearance-1.6.0 lib/clearance/testing/application.rb