diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2012-05-27 12:28:26 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2012-05-27 14:13:45 +0200 |
commit | 0e69705b0fc7501bada74b3ca023ae7f7b2b8592 (patch) | |
tree | 8a3343074b09e1fa2584887257efb153e1cb1525 | |
parent | 81ad94e0ac199cbae6c7bdc0380b2c821c3c56a5 (diff) | |
download | rails-0e69705b0fc7501bada74b3ca023ae7f7b2b8592.tar.gz rails-0e69705b0fc7501bada74b3ca023ae7f7b2b8592.tar.bz2 rails-0e69705b0fc7501bada74b3ca023ae7f7b2b8592.zip |
Fix railties_order when application object is passed
railites_order method, introduced in 40b19e0, had a bug that was causing
loading application instance twice in initializers if railties_order
already included application instance. So for example
railties_order = [Foo::Engine, :main_app, Bar::Engine]
would result in such railties array:
[MyApp::Application, Foo::Engine, MyAppApplication, Bar::Engine]
In order to fix it, we need to check for existence of application in
both railties_order and railties arrays.
-rw-r--r-- | railties/lib/rails/application.rb | 2 | ||||
-rw-r--r-- | railties/test/railties/engine_test.rb | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 6d3349c61b..d92117f97e 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -188,7 +188,7 @@ module Rails end all = (railties.all - order) - all.push(self) unless all.include?(self) + all.push(self) unless (all + order).include?(self) order.push(:all) unless order.include?(:all) index = order.index(:all) diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 400cae98b2..1a92f2f499 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -752,6 +752,10 @@ module RailtiesTest get("/assets/bar.js") assert_equal "// App's bar js\n;", last_response.body.strip + + # ensure that railties are not added twice + railties = Rails.application.ordered_railties.map(&:class) + assert_equal railties, railties.uniq end test "railties_order adds :all with lowest priority if not given" do |