kasugaijin / baja-pet-rescue

Kasugaijin's open-source Ruby on Rails production app that enables dog rescue organisation staff in Mexico to post dogs and receive applications for adoption from users in USA and Canada..
27 stars 9 forks source link

Intermittent Test Issue in Adopter Profile Form Integration Test #53

Closed Eduardo06sp closed 1 year ago

Eduardo06sp commented 1 year ago

After successfully cloning & initializing the db/seeds, I was getting errors on the default test suite (without having made any modifications whatsoever).

The error:

undefined method `adopter_account' for nil:NilClass (NoMethodError) 

it pointed to line 5 within test/integration/adopter_profile_form_test.rb which contains:

adopter_account_id = User.find_by(email: 'test@test123.com').adopter_account.id

I even checked the database (in the console), and I could still see the User in your fixtures. However, after running the tests a few more times, the issue was gone.

Proposed solution: Use the setup method with an instance variable that references the stored fixture. I believe this would be more reliable than using the local variable within the test class. Please let me know if you have other ideas!

Related PR: #52

kasugaijin commented 1 year ago

Nice find on the solution. That is definitely a better way to do it. I have merged your PR for this change and will close this issue.