Ruby on rails User.invite!测试中不发送电子邮件
我正在尝试为我的用户模型创建一些测试。当我使用designe_invitable User.invite邀请用户访问我的应用程序时!创建用户,但似乎不记录电子邮件<代码>ActionMailer::Base.deliveries.count==0。在生产中发送电子邮件,以及在测试中使用客户电子邮件时Ruby on rails User.invite!测试中不发送电子邮件,ruby-on-rails,ruby,devise,devise-invitable,Ruby On Rails,Ruby,Devise,Devise Invitable,我正在尝试为我的用户模型创建一些测试。当我使用designe_invitable User.invite邀请用户访问我的应用程序时!创建用户,但似乎不记录电子邮件ActionMailer::Base.deliveries.count==0。在生产中发送电子邮件,以及在测试中使用客户电子邮件时ActionMailer::Base.deliveries.count是正确的数字 在designe\u invitable中是否缺少配置测试电子邮件发送的功能?我相信这不是designe的功能,Rails默
ActionMailer::Base.deliveries.count
是正确的数字
在designe\u invitable中是否缺少配置测试电子邮件发送的功能?我相信这不是designe的功能,Rails默认情况下不会在测试环境中发送电子邮件,您可能有这样的行
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
在您的config/environments/test.rb上,为了实际发送电子邮件,您可以评论这一行,并使用production.rb的ActionMailer配置,但不建议这样做,因为您可以使用ActionMailer::Base.deliveries数组本身来测试您的电子邮件。我相信这不是设计的东西,Rails默认情况下不会在测试环境中发送电子邮件,您可能会有这样的行
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
在您的config/environments/test.rb上,为了实际发送电子邮件,您可以评论这一行,并使用production.rb的ActionMailer配置,但不建议这样做,因为您可以使用ActionMailer::Base.deliveries数组本身来测试电子邮件。我在测试和开发这两个环境时遇到了相同的问题,并注意到它以静默方式返回了
ArgumentError-发送邮件需要SMTP收件人地址。将邮件smtp信封设置为、收件人、抄送或密件抄送地址。
在日志中
我没有使用designe::invitationcontroller
,所以打电话给确认在我的案例中,code>是必需的,因为启用了:confirmable
User.invite!(invite_params, current_user) do |u|
u.confirm!
end
Desive_invitable(1.4.0)我在测试和开发这两个环境时遇到了相同的问题,并注意到它以静默方式返回了ArgumentError-发送消息需要SMTP收件人地址。将邮件smtp信封设置为、收件人、抄送或密件抄送地址。
在日志中
我没有使用designe::invitationcontroller
,所以打电话给确认在我的案例中,code>是必需的,因为启用了:confirmable
User.invite!(invite_params, current_user) do |u|
u.confirm!
end
设计出不可质疑的(1.4.0)绝妙答案。让我一天都很愉快真棒的回答。让我一天都很愉快