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 f6c7be7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/route_translator/extensions/action_controller.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 f6c7be7

Please sign in to comment.