mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Replay commit from spree_auth_devise that upgrades to devise 3
fe7941f674
This commit is contained in:
@@ -5,12 +5,11 @@ module Spree
|
||||
include I18nHelper
|
||||
|
||||
# Overrides `Devise::Mailer.reset_password_instructions`
|
||||
def reset_password_instructions(user)
|
||||
recipient = user.respond_to?(:id) ? user : Spree.user_class.find(user)
|
||||
def reset_password_instructions(user, token, _opts = {})
|
||||
@edit_password_reset_url = spree.
|
||||
edit_spree_user_password_url(reset_password_token: recipient.reset_password_token)
|
||||
edit_spree_user_password_url(reset_password_token: token)
|
||||
|
||||
mail(to: recipient.email, from: from_address,
|
||||
mail(to: user.email, from: from_address,
|
||||
subject: Spree::Config[:site_name] + ' ' +
|
||||
I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions]))
|
||||
end
|
||||
|
||||
@@ -49,10 +49,6 @@ module Spree
|
||||
has_spree_role?('admin')
|
||||
end
|
||||
|
||||
def send_reset_password_instructions
|
||||
generate_reset_password_token!
|
||||
UserMailer.reset_password_instructions(id).deliver
|
||||
end
|
||||
# handle_asynchronously will define send_reset_password_instructions_with_delay.
|
||||
# If handle_asynchronously is called twice, we get an infinite job loop.
|
||||
handle_asynchronously :send_reset_password_instructions unless method_defined? :send_reset_password_instructions_with_delay
|
||||
|
||||
@@ -49,7 +49,7 @@ describe Spree::UserMailer do
|
||||
describe '#reset_password_instructions' do
|
||||
describe 'message contents' do
|
||||
before do
|
||||
@message = described_class.reset_password_instructions(user)
|
||||
@message = described_class.reset_password_instructions(user, nil)
|
||||
end
|
||||
|
||||
context 'subject includes' do
|
||||
@@ -72,7 +72,7 @@ describe Spree::UserMailer do
|
||||
describe 'legacy support for User object' do
|
||||
it 'sends an email' do
|
||||
expect do
|
||||
Spree::UserMailer.reset_password_instructions(user).deliver
|
||||
Spree::UserMailer.reset_password_instructions(user, nil).deliver
|
||||
end.to change(ActionMailer::Base.deliveries, :size).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user