On 9/28/07, Eric <eylin2000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> In my test case, I have lines that reads something like this:
>
> fixtures :orders
> assert_equal 0, orders(:eric).amount
> Order.update_all_amounts
> assert_equal 30, orders(:eric).amount
>
> This wouldn''t work because, apparently, the orders method
doesn''t
> reload the :eric instance on the second invocation, so it would still
> have the amount zero, even though update_all_amounts has already
> changed it to thirty in the database.
>
> My question is, how do I force orders(:eric) to re-fetch the data from
> the db, without using the find() method directly?
You can just reload the model:
assert_equal 30, orders(:eric).reload.amount
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---