This project is archived and is in readonly mode.
Adding some more tests for the new behaviour of partial collection counters
Reported by Cameron Yule | August 6th, 2008 @ 06:25 PM
There's been changes made to partial collection counters between Rails 2.1 and Edge which haven't been fully tested.
In Rails 2.1, render :partial => 'sometemplate', with no collection parameter being passed in, still results in sometemplate_counter being set as a local variable with a value of 0.
This behaviour is no longer the same in Edge rails, where the counter is only generated for partials with a collection. This is a good change, as it allows for the counter to be over-ridden by passing in your own local variable (e.g. when you're adding new elements to a pre-rendered list via AJAX).
See this thread on the the Rails Core mailing list for more information;
http://groups.google.com/group/r...
I've attempted to write a few tests to check for this behaviour.
Comments and changes to this ticket
-
Frederick Cheung August 6th, 2008 @ 07:04 PM
Am I missing something or is the second test not duplicating the already existing test test_partial_collection_with_counter ?
Also would it not be preferable if the first test asserted what we're really interested in: that the value from :locals is taken into account, rather a side effect of it (an error being raised if :locals doesn't specify a value ?
-
Cameron Yule August 6th, 2008 @ 07:58 PM
Hi Frederick, thanks for the reply. You're entirely correct, I'd duped another test, and the value from :locals being taken into account is of course the logical thing to test as opposed to the error being raised.
Updated the patch with changes to reflect your suggestions, hopefully it's more suitable.
-
Pratik August 6th, 2008 @ 08:41 PM
- Title changed from [PATCH] Adding some more tests for the new behaviour of partial collection counters to Adding some more tests for the new behaviour of partial collection counters
-
josh August 7th, 2008 @ 03:31 AM
- Assigned user set to josh
-
josh August 7th, 2008 @ 03:47 AM
- State changed from new to open
Its really awesome that you found this. I also surprised to "good" features accidentally added by the refactoring.
However, I do get a test failure after I applied it.
test_render_partial_with_locals(ViewRenderTest): NoMethodError: undefined method `controller_path' for NilClass:Class
-
josh August 7th, 2008 @ 06:49 AM
- Milestone cleared.
-
Cameron Yule August 7th, 2008 @ 08:19 AM
Hi Joshua, thanks for pointing that out!
Updated to correct the failing test (was simply an incorrect path).
-
Repository August 9th, 2008 @ 04:49 PM
- State changed from open to resolved
(from [2faf35cea9846fdfa1099f5dfd1589d53a3daf3b]) Added tests for partial collection counters [#766 state:resolved] Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...
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>
People watching this ticket
Attachments
Tags
Referenced by
- 766 Adding some more tests for the new behaviour of partial collection counters (from [2faf35cea9846fdfa1099f5dfd1589d53a3daf3b]) Added t...