From a2ae78bde9faffc84d1b873f6883f181b9545426 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Thu, 18 Jun 2020 18:11:49 +0100 Subject: [PATCH] Replay commit from spree_auth_devise that upgrades to devise 3 https://github.com/spree/spree_auth_devise/commit/fe7941f67426ac17aa894b3b73c45577e4bb2513 --- app/mailers/spree/user_mailer.rb | 7 +++---- app/models/spree/user.rb | 4 ---- spec/mailers/user_mailer_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/app/mailers/spree/user_mailer.rb b/app/mailers/spree/user_mailer.rb index 13acb321dc..a93aff05a5 100644 --- a/app/mailers/spree/user_mailer.rb +++ b/app/mailers/spree/user_mailer.rb @@ -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 diff --git a/app/models/spree/user.rb b/app/models/spree/user.rb index 3df57a9cf8..e602c172de 100644 --- a/app/models/spree/user.rb +++ b/app/models/spree/user.rb @@ -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 diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index 9b4790e5ad..642ffd1406 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -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