提交 39034997 编写于 作者: C Carlhuda

Add support for bare ActiveSupport via config.active_support.bare

上级 8ff310ae
require "pathname"
require 'active_support'
require 'active_support/core_ext/kernel/reporting'
require 'active_support/core_ext/logger'
require 'rails/initializable'
require 'rails/application'
require 'rails/railties_path'
......
......@@ -93,18 +93,8 @@ def call(env)
# list. By default, all frameworks (Active Record, Active Support,
# Action Pack, Action Mailer, and Active Resource) are loaded.
initializer :require_frameworks do
begin
require 'active_support'
require 'active_support/core_ext/kernel/reporting'
require 'active_support/core_ext/logger'
# TODO: This is here to make Sam Ruby's tests pass. Needs discussion.
require 'active_support/core_ext/numeric/bytes'
config.frameworks.each { |framework| require(framework.to_s) }
rescue LoadError => e
# Re-raise as RuntimeError because Mongrel would swallow LoadError.
raise e.to_s
end
require 'active_support/all' unless config.active_support.bare
config.frameworks.each { |framework| require(framework.to_s) }
end
# Set the paths from which Rails will automatically load source files, and
......@@ -308,9 +298,6 @@ def call(env)
base_class.send("#{setting}=", value)
end
end
config.active_support.each do |setting, value|
ActiveSupport.send("#{setting}=", value)
end
end
# Sets +ActionController::Base#view_paths+ and +ActionMailer::Base#template_root+
......
......@@ -44,5 +44,14 @@ def setup
assert_equal Pathname.new("#{app_path}/app"), Rails.application.root
end
end
test "config.active_support.bare does not require all of ActiveSupport" do
add_to_config "config.frameworks = []; config.active_support.bare = true"
Dir.chdir("#{app_path}/app") do
require "#{app_path}/config/environment"
assert_raises(NoMethodError, /day/) { 1.day }
end
end
end
end
\ No newline at end of file
......@@ -25,7 +25,9 @@ def setup
config.frameworks << :action_foo
end
assert_raises RuntimeError do
require "active_support/core_ext/load_error"
assert_raises MissingSourceFile do
Rails.initialize!
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册