Skip to content

Commit

Permalink
Fix overriding ActionController::Live
Browse files Browse the repository at this point in the history
Including ActionController::TestCase::Behavior overrides ActionController::Live#new_controller_thread. This issue also affects
any production mode as the include is not done just in test mode.

This pull request separates production code from test code by query
the environment.

In the future we should think about separating even more by monkey
patching in tests only.


Ref: rails/rails#31200
  • Loading branch information
gurix authored and tagliala committed Apr 9, 2018
1 parent a675344 commit a3f9e31
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
@@ -1,7 +1,8 @@
# Changelog

## 5.6.1 / unreleased
## 5.6.1 / 2018-04-09

* [BUGFIX] Fix overriding ActionController::Live ([#183](https://github.com/enriclluelles/route_translator/pull/183))
* [ENHANCEMENT] Update development dependencies
* [ENHANCEMENT] Test against latest Ruby versions

Expand Down
2 changes: 1 addition & 1 deletion lib/route_translator/extensions/action_controller.rb
Expand Up @@ -42,5 +42,5 @@ def _routes

ActiveSupport.on_load(:action_controller) do
ActionController::Base.send :include, RouteTranslator::Controller
ActionController::TestCase.send :include, RouteTranslator::TestCase
ActionController::TestCase.send :include, RouteTranslator::TestCase if ENV['RAILS_ENV'] == 'test'
end
2 changes: 1 addition & 1 deletion lib/route_translator/translator/route_helpers.rb
Expand Up @@ -34,7 +34,7 @@ def add(old_name, named_route_collection)
__send__(Translator.route_name_for(args, old_name, suffix, self), *args)
end

add_helpers_to_test_cases(helper_container)
add_helpers_to_test_cases(helper_container) if ENV['RAILS_ENV'] == 'test'
end
end
end
Expand Down

0 comments on commit a3f9e31

Please sign in to comment.