Hey Everyone,
I have a function test the is failing (despite the fact the function
actually works in the application). I was looking for some debug
advice on how to find my problem.

Here is the test:
  def test_should_delete_word
    assert_equal 'published', words(:one).status
    debugger
    delete :destroy, :id => words(:one).to_param

    assert_equal 'deleted', words(:one).status
  end

It fails on the last with: <"deleted"> expected but was <"published">.

//My fixture:
one:
  word: cup
  was_created_by_user: true
  status: published
  user_id: 1
  ip_address: '129.1.0.0'

//Controller:
def destroy
    @word = Word.find(params[:id], :include => :definitions)
    @word.status = 'deleted'
    @word.save

    @word.definitions.each do |h|
      h.status = 'deleted'
      h.save
    end

    respond_to do |format|
      format.html { redirect_to(words_url) }
    end
  end

Now the actually application works just like expected changes all
appropriate columns in the db.

I think the problem is that after I run the delete method in the test
the fixtures are reloaded before the next assert so the status is put
back to "published" when it should be "deleted". I think this is the
problem only because when I step through the process in the debugger I
see:
   force_reload = fixtures.pop if fixtures.last == true ||
fixtures.last == :reload
Right after it calls the delete.

Any help would be appreciated.
- bp

--~--~---------~--~----~------------~-------~--~----~
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