require File.expand_path('../boot', __FILE__)

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module RailsTemplate
  class Application < Rails::Application
    config.encoding = 'utf-8'

    # i18n
    config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
    config.i18n.default_locale = :ru

    # Autoloads
    config.autoload_paths += %W(#{config.root}/lib/ #{config.root}/services/** #{config.root}/forms/**)

    # Generators
    config.generators do |g|
      g.template_engine :slim
      g.test_framework :rspec,
                       fixtures: true,
                       view_specs: false,
                       helper_specs: false,
                       routing_specs: false,
                       controller_specs: true,
                       request_specs: true
      g.fixture_replacement :factory_girl, dir: 'spec/factories'
    end

    # Error handler
    config.exceptions_app = ->(env) { Common::ErrorsController.action(:show).call(env) }
  end
end
