diff options
author | Arthur Nogueira Neves <github@arthurnn.com> | 2015-12-11 13:12:33 -0500 |
---|---|---|
committer | Arthur Nogueira Neves <github@arthurnn.com> | 2015-12-11 13:12:33 -0500 |
commit | eb0e8e216fcf535a1e6b82720dfb7639fcc20ff2 (patch) | |
tree | f1d238e72d4fd1fc84095ed629dadafe96d55d8c /actionpack/lib/action_dispatch | |
parent | a42770cdd806d141ae8de1fa879703967532da85 (diff) | |
parent | c6fe614e45a4ae40bb635c1259423ef9e776dd40 (diff) | |
download | rails-eb0e8e216fcf535a1e6b82720dfb7639fcc20ff2.tar.gz rails-eb0e8e216fcf535a1e6b82720dfb7639fcc20ff2.tar.bz2 rails-eb0e8e216fcf535a1e6b82720dfb7639fcc20ff2.zip |
Merge pull request #22511 from jonatack/redirect-to-302
Show redirect response code in assert_response messages
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/assertions/response.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb index cc2a2fb119..c138660a21 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/response.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb @@ -85,17 +85,15 @@ module ActionDispatch end end - def generate_response_message(type) - message = "Expected response to be a <#{type}>, but was" - - if @response.redirection? - redirect_is = normalize_argument_to_redirection(@response.location) - message << " a redirect to <#{redirect_is}>" - else - message << " <#{@response.response_code}>" - end + def generate_response_message(type, code = @response.response_code) + "Expected response to be a <#{type}>, but was a <#{code}>" + .concat location_if_redirected + end - message + def location_if_redirected + return '' unless @response.redirection? && @response.location.present? + location = normalize_argument_to_redirection(@response.location) + " redirect to <#{location}>" end end end |