aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-05-27 12:28:26 +0200
committerPiotr Sarnacki <drogus@gmail.com>2012-05-27 14:26:13 +0200
commitcf992fba95eb5d6282b0d04a52a3595f1c089512 (patch)
treeda871952519128b90d593139da5bba8e0c6c998e /railties
parent4c34cb31fab087217a666a0dd7b1363128acd3a6 (diff)
downloadrails-cf992fba95eb5d6282b0d04a52a3595f1c089512.tar.gz
rails-cf992fba95eb5d6282b0d04a52a3595f1c089512.tar.bz2
rails-cf992fba95eb5d6282b0d04a52a3595f1c089512.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.
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/application.rb2
-rw-r--r--railties/test/railties/engine_test.rb4
2 files changed, 5 insertions, 1 deletions
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