提交 64ea3dfd 编写于 作者: J José Valim 提交者: Carl Lerche

Add reloadable specific for engines and move environment to application paths.

Signed-off-by: NCarl Lerche <carllerche@mac.com>
上级 d3d48747
......@@ -8,14 +8,16 @@ class Configuration < ::Rails::Engine::Configuration
attr_accessor :cache_classes, :cache_store, :colorize_logging,
:consider_all_requests_local, :dependency_loading,
:filter_parameters, :log_level, :logger, :metals,
:plugins, :preload_frameworks, :reload_plugins,
:plugins, :preload_frameworks, :reload_engines, :reload_plugins,
:serve_static_assets, :time_zone, :whiny_nils
def initialize(*)
super
@colorize_logging = true
@filter_parameters = []
@dependency_loading = true
@serve_static_assets = true
@time_zone = "UTC"
end
def paths
......@@ -23,6 +25,7 @@ def paths
paths = super
paths.app.controllers << builtin_controller if builtin_controller
paths.config.database "config/database.yml"
paths.config.environment "config/environments", :glob => "#{Rails.env}.rb"
paths.log "log/#{Rails.env}.log"
paths.tmp "tmp"
paths.tmp.cache "tmp/cache"
......@@ -76,10 +79,6 @@ def builtin_controller
def log_level
@log_level ||= Rails.env.production? ? :info : :debug
end
def time_zone
@time_zone ||= "UTC"
end
end
end
end
\ No newline at end of file
......@@ -124,7 +124,7 @@ def load_tasks
protected
def reloadable?(app)
app.config.reload_plugins
app.config.reload_engines
end
end
end
\ No newline at end of file
......@@ -22,7 +22,6 @@ def paths
paths.lib "lib", :load_path => true
paths.lib.tasks "lib/tasks", :glob => "**/*.rake"
paths.config "config"
paths.config.environment "config/environments", :glob => "#{Rails.env}.rb"
paths.config.initializers "config/initializers", :glob => "**/*.rb"
paths.config.locales "config/locales", :glob => "*.{rb,yml}"
paths.config.routes "config/routes.rb"
......
......@@ -54,5 +54,11 @@ def config
raise "\"#{name}\" is a Railtie/Engine and cannot be installed as plugin"
end
end
protected
def reloadable?(app)
app.config.reload_plugins
end
end
end
......@@ -18,13 +18,13 @@ class Foo < Rails::Railtie ; config.foo.greetings = "hello" ; end
assert_equal "hello", Foo.config.foo.greetings
end
test "plugin configurations are available in the application" do
test "railtie configurations are available in the application" do
class Foo < Rails::Railtie ; config.foo.greetings = "hello" ; end
require "#{app_path}/config/application"
assert_equal "hello", AppTemplate::Application.config.foo.greetings
end
test "plugin config merges are deep" do
test "railtie config merges are deep" do
class Foo < Rails::Railtie ; config.foo.greetings = 'hello' ; end
class Bar < Rails::Railtie
config.foo.bar = "bar"
......@@ -33,7 +33,7 @@ class Bar < Rails::Railtie
assert_equal "bar", Bar.config.foo.bar
end
test "plugin can add subscribers" do
test "railtie can add subscribers" do
begin
class Foo < Rails::Railtie; subscriber(Rails::Subscriber.new); end
assert_kind_of Rails::Subscriber, Rails::Subscriber.subscribers[:foo]
......
......@@ -19,5 +19,9 @@ class Engine < ::Rails::Engine
plugin.write "lib/another.rb", "class Another; end"
end
end
def reload_config
:reload_engines
end
end
end
......@@ -15,6 +15,10 @@ def setup
end
end
def reload_config
:reload_plugins
end
test "plugin can load the file with the same name in lib" do
boot_rails
require "bukkits"
......
......@@ -31,7 +31,7 @@ def test_plugins_constants_are_not_reloaded_by_default
def test_plugin_constants_get_reloaded_if_config_reload_plugins
add_to_config <<-RUBY
config.reload_plugins = true
config.#{reload_config} = true
RUBY
boot_rails
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册