Having the following mailer previewer code:
class RegistrationMailerPreview < ActionMailer::Preview
# Preview this email at http://localhost:3000/rails/mailers/registration_mailer/welcome
def welcome
RegistrationMailer.welcome users(:one)
end
end
(full file).
Which is unable to reach my fixtures (users(:one)
), return a 500 error status and print out the following error:
NoMethodError: undefined method `users' for #RegistrationMailerPreview
Can we get fixtures entries from mailer previewer?
If yes, I would like to know how to do that.
I have seen that should be possible here, but I can't require test_helper
in this file (I don't know why) and I don't understand the difference between ActionMailer::TestCase
and ActionMailer::Preview
.
If no, is there a way to preview the mail without sending as a parameter User.first
, since I could do my tests on a machine on which there is no data filled in the database.