After_create callback not working in test but works in console?

If you are using a database backed test then you need to reload the user in the test (because the user instance is not updated, the absence's user is updated and saved to the database), reloading the user would look like: assert_equal user.reload. Holidays_booked_this_year, 5 I would also guess that an absence needs to have a user, so you should use build instead of create so the foreign key for user is part of the "created" instance: user.absences. Build First guess would be that in the console you are operating on a real user in the database whereas the test is a fixture.

Have you tried this is in test? : raise user. Inspect Look at the output and determine which user you are actually working with and what the holidays_booked_this_year attributes is.

(your test block also needs a "do" after the description).

Thanks Brandon. I accidentally omitted the "do" above; it's definitely present in my code. I'll try out your suggestions above and report back.

– Robin Fisher Mar 15 '11 at 9:32 Thanks Brandon. Called reload and now have a passing test! – Robin Fisher Mar 15 '11 at 12:42.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions