Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

assert_response assumes a rendered template

#141

Since changeset 8559, assert_response assumes it can find the instance variable @exception in the rendered template. This is not the case if the exception is being rescued and the response is something other than a rendered template. For example...

In this example, xml error responses are created without a template -and this breaks assert_response.

Reported by Chris Hapgood · May 7th, 2008 @ 11:23 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Chris Hapgood
    Chris Hapgood

    I am unable to post a comment that includes my ruby source code -LH blows up. But the code example is pretty simple: implement a rescue_action_in_public and render a string directly instead of a template. That's a common practices for XML and JSON error messages.

    Also attaching a patch that fixes the problem. Tests to come.

    May 7th, 2008 @ 11:28 PM

  2. Chris Hapgood
    Chris Hapgood

    Here's a pastie of the code that causes LH to barf:

    http://pastie.caboo.se/193322

    NB: Even if I remove the "@@@ ruby" tag, it doesn't help.

    May 7th, 2008 @ 11:33 PM

  3. Pratik
    Pratik
    • State changed from new to incomplete

    Could you please add a failing test case ?

    Thanks.

    May 14th, 2008 @ 11:44 AM

  4. Chris Hapgood
    Chris Hapgood

    I can write a failing test against 2.0.2, but to get one against edge is going to take me a while. Would 2.0.2 be good enough?

    -Chris

    May 14th, 2008 @ 01:01 PM

  5. Pratik
    Pratik

    One against edge would be nicer. But if you can't, then 2.0.x is fine too and I'll try to port it to edge.

    Thanks.

    May 14th, 2008 @ 02:39 PM

  6. Chris Hapgood
    Chris Hapgood

    Jeremy fixed this already in Edge (Commit eb837b52e34c1f7f0c71d704ffdb3e4eb4b582e2).

    May 16th, 2008 @ 02:24 PM

  7. Chris Hapgood
    Chris Hapgood

    Since I had gone to the trouble of writing a failing test before I found Jeremy's patch on Edge, I figured it would be a good idea to add the test anyway.

    Attached is a patch against Edge that validates assert_response's behavior faced with a failure response but no exception.

    May 16th, 2008 @ 04:38 PM

  8. Pratik
    Pratik
    • State changed from incomplete to open

    May 16th, 2008 @ 05:42 PM

  9. Repository
    Repository
    • State changed from open to resolved

    (from [e6f5079a48094eeba3dab9dca52b16b58ddc3634]) Test for assert_response for failure response without an exception. [#141 state:resolved]

    Signed-off-by: Pratik Naik

    http://github.com/rails/rails/co...

    May 19th, 2008 @ 11:22 AM

  10. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 9th, 2010 @ 09:48 PM

  11. Jeff Kreeftmeijer