From cf992fba95eb5d6282b0d04a52a3595f1c089512 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 27 May 2012 12:28:26 +0200 Subject: 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. --- railties/lib/rails/application.rb | 2 +- railties/test/railties/engine_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index d44465e547..660e864d2a 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -185,7 +185,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 7a047ef93a..4437e2c8af 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -1098,6 +1098,10 @@ YAML 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 -- cgit v1.2.3