Sha256: b6f8fade7b1a09c9fd42cc91a009f16ade0f63051743801ad6cacb74062a487d

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

RSpec.describe Spree::UserMailer, type: :mailer do
  let(:user) { create(:user) }
  let(:store) { Spree::Store.default }

  describe '#reset_password_instructions' do
    describe 'message contents' do
      before do
        @message = described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.default.id })
      end

      context 'subject includes' do
        it 'translated devise instructions' do
          expect(@message.subject).to include(
            I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions])
          )
        end

        it 'Spree site name' do
          expect(@message.subject).to include store.name
        end
      end

      context 'body includes' do
        it 'password reset url' do
          expect(@message.body.encoded).to include "http://#{store.url}/password/change"
        end
      end
    end

    describe 'legacy support for User object' do
      it 'sends an email' do
        expect {
          described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.default.id }).deliver_now
        }.to change(ActionMailer::Base.deliveries, :size).by(1)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_auth_devise-4.6.3 spec/mailers/user_mailer_spec.rb
spree_auth_devise-4.6.2 spec/mailers/user_mailer_spec.rb
spree_auth_devise-4.6.1 spec/mailers/user_mailer_spec.rb
spree_auth_devise-4.6.0 spec/mailers/user_mailer_spec.rb
spree_auth_devise-4.5.0 spec/mailers/user_mailer_spec.rb