提交 1e410972 编写于 作者: C Carl Lerche

Fully remove config.frameworks in favor of requires in boot.rb

上级 783caae5
......@@ -273,7 +273,9 @@ def call(env)
# 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 @@ class Configuration < Plugin::Configuration
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 @@ def threadsafe!
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 @@ def log_level
@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 @@ class Application < Rails::Application
# :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 @@
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"
\ No newline at end of file
......@@ -75,10 +75,11 @@ def setup
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 @@ class InitializerTest < Test::Unit::TestCase
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 Zoo::ReptileHouse ; end
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 @@ def test_config_database_is_not_added_if_skip_activerecord_is_given
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 @@ class PathTest < Test::Unit::TestCase
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册