mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fully remove config.frameworks in favor of requires in boot.rb
This commit is contained in:
parent
783caae52f
commit
1e41097294
8 changed files with 24 additions and 38 deletions
|
@ -273,7 +273,9 @@ module Rails
|
|||
# For each framework, search for instrument file with Notifications hooks.
|
||||
#
|
||||
initializer :load_notifications_hooks do
|
||||
config.frameworks.each do |framework|
|
||||
frameworks = [ :active_record, :action_controller, :action_view,
|
||||
:action_mailer, :active_resource ]
|
||||
frameworks.each do |framework|
|
||||
begin
|
||||
require "#{framework}/notifications"
|
||||
rescue LoadError => e
|
||||
|
|
|
@ -59,7 +59,7 @@ module Rails
|
|||
|
||||
attr_writer :cache_store, :controller_paths,
|
||||
:database_configuration_file, :eager_load_paths,
|
||||
:frameworks, :framework_root_path, :i18n, :load_paths,
|
||||
:i18n, :load_paths,
|
||||
:log_level, :log_path, :paths, :routes_configuration_file,
|
||||
:view_path
|
||||
|
||||
|
@ -134,21 +134,6 @@ module Rails
|
|||
self
|
||||
end
|
||||
|
||||
def framework_paths
|
||||
paths = %w(railties railties/lib activesupport/lib)
|
||||
paths << 'actionpack/lib' if frameworks.include?(:action_controller) || frameworks.include?(:action_view)
|
||||
|
||||
[:active_record, :action_mailer, :active_resource, :action_web_service].each do |framework|
|
||||
paths << "#{framework.to_s.gsub('_', '')}/lib" if frameworks.include?(framework)
|
||||
end
|
||||
|
||||
paths.map { |dir| "#{framework_root_path}/#{dir}" }.select { |dir| File.directory?(dir) }
|
||||
end
|
||||
|
||||
def framework_root_path
|
||||
defined?(::RAILS_FRAMEWORK_ROOT) ? ::RAILS_FRAMEWORK_ROOT : "#{root}/vendor/rails"
|
||||
end
|
||||
|
||||
# Loads and returns the contents of the #database_configuration_file. The
|
||||
# contents of the file are processed via ERB before being sent through
|
||||
# YAML::load.
|
||||
|
@ -239,10 +224,6 @@ module Rails
|
|||
@log_level ||= RAILS_ENV == 'production' ? :info : :debug
|
||||
end
|
||||
|
||||
def frameworks
|
||||
@frameworks ||= [ :active_record, :action_controller, :action_view, :action_mailer, :active_resource ]
|
||||
end
|
||||
|
||||
def i18n
|
||||
@i18n ||= begin
|
||||
i18n = ActiveSupport::OrderedOptions.new
|
||||
|
|
|
@ -13,16 +13,8 @@ module <%= app_name.classify %>
|
|||
# :all can be used as a placeholder for all plugins not explicitly named
|
||||
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
||||
|
||||
# Skip frameworks you're not going to use. To use Rails without a database,
|
||||
# you must remove the Active Record framework.
|
||||
<% if options[:skip_activerecord] -%>
|
||||
config.frameworks -= [ :active_record ]
|
||||
<% else -%>
|
||||
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
|
||||
|
||||
# Activate observers that should always be running
|
||||
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
||||
<% end -%>
|
||||
|
||||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||
# Run "rake -D time" for a list of tasks for finding time zone names.
|
||||
|
|
|
@ -14,3 +14,12 @@ else
|
|||
end
|
||||
|
||||
require 'rails'
|
||||
# To skip frameworks you're not going to use, remove require "rails" and
|
||||
# list the frameworks that you are going to use.
|
||||
#
|
||||
# require "active_model/rails"
|
||||
# require "active_record/rails"
|
||||
# require "action_controller/rails"
|
||||
# require "action_view/rails"
|
||||
# require "action_mailer/rails"
|
||||
# require "active_resource/rails"
|
|
@ -75,10 +75,11 @@ module ApplicationTests
|
|||
test "the application can be marked as threadsafe when there are no frameworks" do
|
||||
FileUtils.rm_rf("#{app_path}/config/environments")
|
||||
add_to_config <<-RUBY
|
||||
config.frameworks = []
|
||||
config.threadsafe!
|
||||
RUBY
|
||||
|
||||
use_frameworks []
|
||||
|
||||
assert_nothing_raised do
|
||||
require "#{app_path}/config/application"
|
||||
end
|
||||
|
|
|
@ -7,7 +7,6 @@ module ApplicationTests
|
|||
def setup
|
||||
build_app
|
||||
boot_rails
|
||||
require "rails"
|
||||
end
|
||||
|
||||
test "initializing an application adds the application paths to the load path" do
|
||||
|
@ -51,8 +50,9 @@ module ApplicationTests
|
|||
assert_nothing_raised NameError do
|
||||
add_to_config <<-RUBY
|
||||
config.root = "#{app_path}"
|
||||
config.frameworks = []
|
||||
RUBY
|
||||
|
||||
use_frameworks []
|
||||
require "#{app_path}/config/environment"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -63,10 +63,11 @@ class AppGeneratorTest < GeneratorsTestCase
|
|||
assert_no_file "config/database.yml"
|
||||
end
|
||||
|
||||
def test_activerecord_is_removed_from_frameworks_if_skip_activerecord_is_given
|
||||
run_generator ["--skip-activerecord"]
|
||||
assert_file "config/application.rb", /config\.frameworks \-= \[ :active_record \]/
|
||||
end
|
||||
# TODO: Bring this back using requires
|
||||
# def test_activerecord_is_removed_from_frameworks_if_skip_activerecord_is_given
|
||||
# run_generator ["--skip-activerecord"]
|
||||
# assert_file "config/application.rb", /config\.frameworks \-= \[ :active_record \]/
|
||||
# end
|
||||
|
||||
def test_prototype_and_test_unit_are_added_by_default
|
||||
run_generator
|
||||
|
|
|
@ -7,14 +7,14 @@ module InitializerTests
|
|||
def setup
|
||||
build_app
|
||||
boot_rails
|
||||
require "rails"
|
||||
add_to_config <<-RUBY
|
||||
config.root = "#{app_path}"
|
||||
config.frameworks = [:action_controller, :action_view, :action_mailer, :active_record]
|
||||
config.after_initialize do
|
||||
ActionController::Base.session_store = nil
|
||||
end
|
||||
RUBY
|
||||
use_frameworks [:action_controller, :action_view, :action_mailer, :active_record]
|
||||
require "rails"
|
||||
require "#{app_path}/config/environment"
|
||||
@paths = Rails.application.config.paths
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue