On Sep 3, 9:22 am, brianp <[email protected]> wrote:
> I also tried reloading on the active record object directly
>
>   def test_should_delete_word2
>     assert_equal :published, words(:one).status
>     delete :destroy, :id => words(:one).to_param
>     words(:one).reload (as well as reload!)
>     word_status = Word.find(:id).status

That doesn't make a whole load of sense - unless there had been a word
whose id was the string id.

>     assert_equal :deleted, word_status
>   end
> It returns: ActiveRecord::RecordNotFound: Couldn't find Word with
> ID=id
>
> Eventually it worked with(just a last attempt before I posted):
>
>   def test_should_delete_word2
>     assert_equal :published, words(:one).status
>     delete :destroy, :id => words(:one).to_param
>     words(:one).reload
>     word_status = Word.find(words(:one)).status
>     assert_equal :deleted, word_status
>   end
>
> Which I find a little weird. Just because in this and other tests I've
> found the fixtures produce weird id's when they hit the db. The only
> way I can find matching id's is with the to_param string. So why
> Word.find(words(:one)) managed to find a matching ID in the db without
> using to_param beats me.

because find knows the right thing to do if you give it an
activerecord object.
You can do either words(:one).reload and then look at words
(:one).status or look at Word.find(words(:one)).status but you don't
need to do both - that's just redundant.

Fred


>
> But thanks for everyones input ! If you have any idea about the id's I
> wouldn't mind understanding exactly what is going on there.
>


--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to