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.

[PATCH] ActionDispatch::TestProcess::assigns breaks array tests due to HashWithIndifferentAccess

#5956

I ran across this issue while upgrading a large, well tested app to rails3. Basically, anywhere in the specs where we where testing for a WillPaginate::Collection or methods on a WillPaginate::Collection would fail. I narrowed it down to HashWithIndifferentAccess replacing arrays or anything subclassing arrays with a new array via collect (#convert_value hash_with_indifferent_access.rb:143).

I would like some help resolving this issue. The attached patch is a first pass at fixing it and it works for the general use case, however, problems arise if you use caching which basically creates a frozen object. Any array that is frozen throws an exception because replace is trying to modify the array...

Example of failing test: https://gist.github.com/667961

Reported by Larry Sprock · November 12th, 2010 @ 12:53 AM

State: resolved
Milestone: none
Assigned to: Michael Koziarski Michael Koziarski
Importance: Low

Activity

  1. Larry Sprock
    Larry Sprock
    • Title changed from HashWithIndifferentAccess should not change the class of an array to ActionDispatch::TestProcess::assigns breaks array tests do to HashWithIndifferentAccess
    • Tag set to activesupport, assigns, testing

    November 14th, 2010 @ 01:01 AM

  2. Larry Sprock
    Larry Sprock
    • Assigned user set to Michael Koziarski

    November 14th, 2010 @ 01:08 AM

  3. Larry Sprock
    Larry Sprock
    • Title changed from ActionDispatch::TestProcess::assigns breaks array tests do to HashWithIndifferentAccess to ActionDispatch::TestProcess::assigns breaks array tests due to HashWithIndifferentAccess

    November 14th, 2010 @ 05:41 AM

  4. Larry Sprock
    Larry Sprock
    • Title changed from ActionDispatch::TestProcess::assigns breaks array tests due to HashWithIndifferentAccess to [PATCH] ActionDispatch::TestProcess::assigns breaks array tests due to HashWithIndifferentAccess

    Ok, Sorted and tests passing... Can someone have a look?

    Thanks

    November 14th, 2010 @ 07:04 AM

  5. José Valim
    José Valim
    • State changed from new to resolved
    • Importance changed from to Low

    November 14th, 2010 @ 09:15 AM