This project is archived and is in readonly mode.
assert_response assumes a rendered template
Reported by Chris Hapgood | May 7th, 2008 @ 11:23 PM
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.
Comments and changes to this ticket
-
Chris Hapgood May 7th, 2008 @ 11:28 PM
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.
-
Chris Hapgood May 7th, 2008 @ 11:33 PM
Here's a pastie of the code that causes LH to barf:
NB: Even if I remove the "@@@ ruby" tag, it doesn't help.
-
Pratik May 14th, 2008 @ 11:44 AM
- State changed from new to incomplete
Could you please add a failing test case ?
Thanks.
-
Chris Hapgood May 14th, 2008 @ 01:01 PM
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
-
Pratik May 14th, 2008 @ 02:39 PM
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.
-
Chris Hapgood May 16th, 2008 @ 02:24 PM
Jeremy fixed this already in Edge (Commit eb837b52e34c1f7f0c71d704ffdb3e4eb4b582e2).
-
Chris Hapgood May 16th, 2008 @ 04:38 PM
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.
-
Pratik May 16th, 2008 @ 05:42 PM
- State changed from incomplete to open
-
Repository May 19th, 2008 @ 11:22 AM
- 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
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>