Functional testing confusion...

I am trying to be a good RORer and write all my tests to achieve 100%
coverage with rcov.

However, I have run up against something that really confuses me.

In my test file
<code>
  def test_should_mark_task_done
    task = tasks(:tasks_001)
    post_with_user('admin', :mark_done, {:id => task.id} )
    assert_response :success
    assert_equal flash[:notice], 'Task was successfully updated.'
    task.reload
    assert_equal task.done
  end
</code>

In my controller:
<code>
def mark_done
    @task = Task.find(params[:id])
    @task.done = true
    @task.save
    flash[:notice] = 'Task was successfully updated.'
    respond_to do |format|
        format.js # mark_done.js.rjs
        format.html { redirect_to :action => "index" }
        format.xml { head :ok }
    end
  end
</code>

The assert_response :success passes (as it should)
The assert_equal flash[:notice] passes (as it should)
The assert_equal task.done fails (HUH?!?!?!?!)

The code works in practice (ie, it modifies the done column of the record.)

Any suggestions of where to look?

Thanks,

Alan

Hi --

I apologize, the actual code says
assert task_done

It was a typo on my part in the email.

--Alan

I apologize, the actual code says
assert task_done

I assume that's another typo and you mean assert task.done
Have you tried changing the save to a save! (so that you get an exception saying why it has failed) ?

Fred

You are correct, it should be assert task.done

I know that the save in the actual controller works, because
flash[:notice] gets set appropriately. Just for grins, I changed it
from save, to save! in the controller with no difference.

Thanks for helping me with this!

--Alan

I just realized that my post is not clear, I still have the problem
that assert task.done fails

You are correct, it should be assert task.done

I know that the save in the actual controller works, because
flash[:notice] gets set appropriately. Just for grins, I changed it
from save, to save! in the controller with no difference.

Can you see a matching update query in the test logs ?

Fred

Thank you VERY VERY VERY VERY VERY much. I hadn't even thought about
looking in the logs. It turns out there was no update query. It
ended up being that my fixtures had bad data in it. I don't know why
the save! wasn't complaining the first time, but it is now.

Thanks again,

Alan