Skip to content

Commit

Permalink
Avoid loading ActionController::TestCase in production
Browse files Browse the repository at this point in the history
Ref: Shopify#3

> By referencing that object, it brings in all of the patches defined
> in `ActionController::TestCase` to the development and production
> environment, including behaviours like disabling the threading
> implementation of `ActionController::Live`
  • Loading branch information
byroot committed Apr 9, 2024
1 parent 07da9d0 commit 06263e0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/active_model_serializers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@
ActiveSupport.on_load(:action_controller) do
if ::ActionController::Serialization.enabled
ActionController::Base.send(:include, ::ActionController::Serialization)
ActionController::TestCase.send(:include, ::ActionController::SerializationAssertions)

if ActiveSupport::VERSION::STRING < '5'
if defined?(Rails) && Rails.env.test?
ActionController::TestCase.send(:include, ::ActionController::SerializationAssertions)
end
else
ActiveSupport.on_load(:action_controller_test_case) do
ActionController::TestCase.send(:include, ::ActionController::SerializationAssertions)
end
end
end
end
rescue LoadError
Expand Down

0 comments on commit 06263e0

Please sign in to comment.