Skip to content

Commit

Permalink
Fix railties_order when application object is passed
Browse files Browse the repository at this point in the history
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
drogus committed May 27, 2012
1 parent 4c34cb3 commit cf992fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion railties/lib/rails/application.rb
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions railties/test/railties/engine_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit cf992fb

Please sign in to comment.