Skip to content

Commit cf992fb

Browse files
committed
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.
1 parent 4c34cb3 commit cf992fb

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

railties/lib/rails/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def ordered_railties #:nodoc:
185185
end
186186

187187
all = (railties.all - order)
188-
all.push(self) unless all.include?(self)
188+
all.push(self) unless (all + order).include?(self)
189189
order.push(:all) unless order.include?(:all)
190190

191191
index = order.index(:all)

railties/test/railties/engine_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,10 @@ def bar
10981098

10991099
get("/assets/bar.js")
11001100
assert_equal "// App's bar js\n;", last_response.body.strip
1101+
1102+
# ensure that railties are not added twice
1103+
railties = Rails.application.ordered_railties.map(&:class)
1104+
assert_equal railties, railties.uniq
11011105
end
11021106

11031107
test "railties_order adds :all with lowest priority if not given" do

0 commit comments

Comments
 (0)