Confirmable integration test failing
Closed this issue · 6 comments
Hello, I'm having an issue with an integration test checking for the confirmation email to be sent. I have described the issue here. I really can't get my head around it - but I thought I'd post it here since it only appears when async is enabled and only for confirmable. Or maybe I'm missing something...
@kitsched would you please take a look here and see if it helps.
There's also a Devise::Async.enabled
option that might help you figure out what's happening.
Let me know how it goes.
Thank you. As suggested, if I start the register related spec block with Devise::Async.enabled = false
it passes. This is no surprise because the spec would also pass when I completely disabled async from the model, but I still don't understand why this one wouldn't work with async while the ones related to password reset go through.
You have use_transactional_fixtures
enabled in rspec, right?
The reason why the confirmable one fails is probably because you have it enabled and the user is created inside a transaction and therefore the after_commit hook is never called.
I'd guess the password reset code doesn't use transactions and that's way the emails are triggered.
You can confirm my theory in your logs.
Yes, I have it enabled. I solved this issue by disabling use_transactional_fixtures
for this one spec:
describe "Registers" do
self.use_transactional_fixtures = false
it "should inform the user to confirm account" do
[ ... snip ...]
end
end
Thank you for your help.
Great - just be sure to clean after yourself in this spec. You might end up leaving records behind you that confuses the specs running after this one.
I answered myself on SO. Hopefully correctly. Thanks again for your help.