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