Permalink
Browse files

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.
  • Loading branch information...
1 parent 4c34cb3 commit cf992fba95eb5d6282b0d04a52a3595f1c089512 @drogus drogus committed May 27, 2012
Showing with 5 additions and 1 deletion.
  1. +1 −1 railties/lib/rails/application.rb
  2. +4 −0 railties/test/railties/engine_test.rb
@@ -185,7 +185,7 @@ def ordered_railties #:nodoc:
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)
@@ -1098,6 +1098,10 @@ def bar
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

0 comments on commit cf992fb

Please sign in to comment.