Hi,
I am trying to test factory girl associations basically I have a user
model and status model , what is supposed to happen is a user has many
statuses and a status belongs to a user. I have tried to model this in
factory girl as you can see in the files. When I try to execute the test
I get
Failure/Error: visit("/users/#{user.id}/statuses/#{status.id}")
ActiveRecord::RecordNotFound:
Couldn't find Status with id=2 [WHERE `statuses`.`user_id` = 1]
when I run the request spec for statuses. What should I change to get
this test to pass.
Shaban
on 2012-11-12 11:01
on 2012-11-13 10:48
That's because users are actually different. To fix this you need to
pass a
user record into the FactoryGirl's create method.
let(:user) {FactoryGirl.create(:user)}
let(:status) {FactoryGirl.create(:status, user: user)}
Regards,
Anton
, 12 2012 ., 14:03:19 UTC+4 Ruby-Forum.com
User :
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.