Fix bug send email sign up user
This commit is contained in:
parent
2d6e0d2864
commit
02b7680083
2 changed files with 24 additions and 9 deletions
|
@ -2,6 +2,11 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|||
# before_filter :configure_sign_up_params, only: [:create]
|
||||
# before_filter :configure_account_update_params, only: [:update]
|
||||
|
||||
def after_sign_up_path_for(resource_or_scope)
|
||||
WelcomeMailer.welcome_email(User.last).deliver_now!
|
||||
super
|
||||
end
|
||||
|
||||
# GET /resource/sign_up
|
||||
# def new
|
||||
# super
|
||||
|
@ -9,9 +14,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|||
|
||||
# POST /resource
|
||||
def create
|
||||
retour = super
|
||||
WelcomeMailer.welcome_email(User.last).deliver_now!
|
||||
retour
|
||||
super
|
||||
end
|
||||
|
||||
# GET /resource/edit
|
||||
|
|
|
@ -5,7 +5,7 @@ describe Users::RegistrationsController, type: :controller do
|
|||
let(:email) { 'test@octo.com' }
|
||||
let(:password) { 'password' }
|
||||
|
||||
let(:user) { { email: email, password: password, password_confirmation: password } }
|
||||
let(:user) { {email: email, password: password, password_confirmation: password} }
|
||||
|
||||
before do
|
||||
@request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
|
@ -14,13 +14,25 @@ describe Users::RegistrationsController, type: :controller do
|
|||
describe '.create' do
|
||||
subject { post :create, user: user }
|
||||
|
||||
it { expect(described_class).to be < Devise::RegistrationsController }
|
||||
context 'when user is correct' do
|
||||
it { expect(described_class).to be < Devise::RegistrationsController }
|
||||
|
||||
it 'welcome email is send' do
|
||||
expect(WelcomeMailer).to receive(:welcome_email).and_return(WelcomeMailer)
|
||||
expect(WelcomeMailer).to receive(:deliver_now!)
|
||||
it 'welcome email is send' do
|
||||
expect(WelcomeMailer).to receive(:welcome_email).and_return(WelcomeMailer)
|
||||
expect(WelcomeMailer).to receive(:deliver_now!)
|
||||
|
||||
subject
|
||||
subject
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user is not correct' do
|
||||
let(:user) { {email: '', password: password, password_confirmation: password} }
|
||||
|
||||
it 'welcome email is not send' do
|
||||
expect(WelcomeMailer).not_to receive(:welcome_email)
|
||||
|
||||
subject
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue