aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2015-05-02 10:26:22 -0400
committereileencodes <eileencodes@gmail.com>2015-05-02 10:45:17 -0400
commit76836ef7db8d0b1e40492c9a62f7c637718d813d (patch)
tree6c42dee86adfb116a272e49b2de205ffe0a056a5 /railties
parente260975baf5b1a54d03ecd685f62f697871b9b65 (diff)
downloadrails-76836ef7db8d0b1e40492c9a62f7c637718d813d.tar.gz
rails-76836ef7db8d0b1e40492c9a62f7c637718d813d.tar.bz2
rails-76836ef7db8d0b1e40492c9a62f7c637718d813d.zip
Use `def before_setup` instead of `setup do`
`setup do` creates unnecessary allocations of proc objects in test callbacks. This prevents that from happening and results in faster code. Originally I had done this as `def setup` and all Railties tests passed. See 044f9ab. Later it was reported there was an issue with this that caused routes in tests to be nil because devs don't generally call `super` in their test setups. Because of that I reverted the commit until I could find a suitble replacement. `before_setup` esentially does the same thing but without the requirement that applications call `super` in their test setups.
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/test_help.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb
index 5cf44e6331..a83e39faee 100644
--- a/railties/lib/rails/test_help.rb
+++ b/railties/lib/rails/test_help.rb
@@ -27,13 +27,15 @@ if defined?(ActiveRecord::Base)
end
class ActionController::TestCase
- setup do
+ def before_setup
@routes = Rails.application.routes
+ super
end
end
class ActionDispatch::IntegrationTest
- setup do
+ def before_setup
@routes = Rails.application.routes
+ super
end
end