Permalink
Browse files

Add reloadable specific for engines and move environment to applicati…

…on paths.

Signed-off-by: Carl Lerche <carllerche@mac.com>
  • Loading branch information...
1 parent d3d4874 commit 64ea3dfd9f14b09b65905a10379050ba2f42d8b8 @josevalim josevalim committed with Carl Lerche Jan 27, 2010
@@ -8,21 +8,24 @@ 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
@paths ||= begin
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
@@ -124,7 +124,7 @@ def load_tasks
protected
def reloadable?(app)
- app.config.reload_plugins
+ app.config.reload_engines
end
end
end
@@ -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

0 comments on commit 64ea3df

Please sign in to comment.