mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Add reloadable specific for engines and move environment to application paths.
Signed-off-by: Carl Lerche <carllerche@mac.com>
This commit is contained in:
@@ -8,14 +8,16 @@ module Rails
|
||||
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 @@ module Rails
|
||||
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 @@ module Rails
|
||||
def log_level
|
||||
@log_level ||= Rails.env.production? ? :info : :debug
|
||||
end
|
||||
|
||||
def time_zone
|
||||
@time_zone ||= "UTC"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -124,7 +124,7 @@ module Rails
|
||||
protected
|
||||
|
||||
def reloadable?(app)
|
||||
app.config.reload_plugins
|
||||
app.config.reload_engines
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -22,7 +22,6 @@ module Rails
|
||||
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 @@ module Rails
|
||||
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 @@ module RailtiesTest
|
||||
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 @@ module RailtiesTest
|
||||
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 @@ module RailtiesTest
|
||||
plugin.write "lib/another.rb", "class Another; end"
|
||||
end
|
||||
end
|
||||
|
||||
def reload_config
|
||||
:reload_engines
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,6 +15,10 @@ module RailtiesTest
|
||||
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 @@ module RailtiesTest
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user