Functional tests and creating objects

I obviously don’t fully understand functional testing. I’m trying to
test object creation, but I can’t get my functional test to actually
create an object with a unique ID. Here’s a rough outline of what I’m
doing:

Controller:

def create
@my_object = MyObject.new(:owner => params[:user_id])
@my_object.name = ‘dog’
@my_object.save!
end

Test:

def test_create_empty_object
post :create, :user_id => ‘sample_user’
assert_status 200

my_new_object = MyObject.find_by_owner('sample_user')
puts my_new_object.id

end

My question is: why does my_new_object come back with an ID of 0?

This really causes problems when I’m trying to relate new objects to
one another and somehow the functional tests keep setting the object
IDs to 0. Is there a way around this? Should I be testing this
functionality in another way?

Thanks,
Sean

As a follow up, is there a really good functional testing guide
somewhere? Right now they feel pretty useless to me, as it looks like
I can only test that I get a certain type of response from a request,
rather than the controller method did what it was supposed to.

Try http://www.openqa.org/selenium/ selenium on
http://www.randomhacks.net/articles/2006/02/15/selenium-on-rails-reloadedrails
if you want more flexibility.

Vish