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
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Source available from github
The Git repository resides at http://github.com/rails
Check out the current development trunk (Edge Rails) with:
git clone git://github.com/rails/rails.git
Creating or reviewing a patch
See the contributor guide.
Creating a feature request
Please don't. If you want a new feature in Rails, you'll have to pull up your sleeves and get busy yourself. Or convince someone else to do it. See the contributor guide on how to get going. But posting them here is just going to lead to ticket root.
Creating a bug report
When creating a bug report, be sure to include as much relevant information as possible. Post the code sample that causes the problem. Preferably, alter the unit tests and show through either changed or added tests how the expected behavior is not occuring.
Security vulnerabilities should be reported via an email to security@rubyonrails.org, do not use trac for reporting security vulnerabilities. All content in trac is publicly available as soon as it is posted.
Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kinda bug, you're creating this ticket in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the ticket automatically will see any activity or that others will jump to fix it. Creating a ticket like this is mostly to help yourself start on the path of fixing the problem and for others to sign on to with a "I'm having this problem too".
