diff options
author | Tobias Bühlmann <tbuehlmann@users.noreply.github.com> | 2018-12-16 11:02:45 +0100 |
---|---|---|
committer | Tobias Bühlmann <tbuehlmann@users.noreply.github.com> | 2018-12-16 12:27:37 +0100 |
commit | 8246a8139c78aca29f988274be9732b1e9f4f51d (patch) | |
tree | 53cb2d013947d5542b4abddb554d274095a87bdc /actionpack/lib/action_dispatch/testing/test_response.rb | |
parent | ce48b5a366482d4b4c4c053e1e39e79d71987197 (diff) | |
download | rails-8246a8139c78aca29f988274be9732b1e9f4f51d.tar.gz rails-8246a8139c78aca29f988274be9732b1e9f4f51d.tar.bz2 rails-8246a8139c78aca29f988274be9732b1e9f4f51d.zip |
Allow using parsed_body in ActionController::TestCase
… by switching the initialzation of an appropriate response parser
in `ActionDispatch::TestResponse` from eagerly to lazily.
By doing so, the response parser can be correctly set for
`ActionController::TestCase`, which doesn't include
the content type header in the constructor but only sets it at
a later time.
Fixes #34676.
Diffstat (limited to 'actionpack/lib/action_dispatch/testing/test_response.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/test_response.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/testing/test_response.rb b/actionpack/lib/action_dispatch/testing/test_response.rb index 1e6b21f235..7c1202dc0e 100644 --- a/actionpack/lib/action_dispatch/testing/test_response.rb +++ b/actionpack/lib/action_dispatch/testing/test_response.rb @@ -14,11 +14,6 @@ module ActionDispatch new response.status, response.headers, response.body end - def initialize(*) # :nodoc: - super - @response_parser = RequestEncoder.parser(content_type) - end - # Was the response successful? def success? ActiveSupport::Deprecation.warn(<<-MSG.squish) @@ -47,7 +42,11 @@ module ActionDispatch end def parsed_body - @parsed_body ||= @response_parser.call(body) + @parsed_body ||= response_parser.call(body) + end + + def response_parser + @response_parser ||= RequestEncoder.parser(content_type) end end end |