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_sign_up_params, only: [:create]
|
||||||
# before_filter :configure_account_update_params, only: [:update]
|
# 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
|
# GET /resource/sign_up
|
||||||
# def new
|
# def new
|
||||||
# super
|
# super
|
||||||
|
@ -9,9 +14,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
||||||
|
|
||||||
# POST /resource
|
# POST /resource
|
||||||
def create
|
def create
|
||||||
retour = super
|
super
|
||||||
WelcomeMailer.welcome_email(User.last).deliver_now!
|
|
||||||
retour
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /resource/edit
|
# GET /resource/edit
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe Users::RegistrationsController, type: :controller do
|
||||||
let(:email) { 'test@octo.com' }
|
let(:email) { 'test@octo.com' }
|
||||||
let(:password) { 'password' }
|
let(:password) { 'password' }
|
||||||
|
|
||||||
let(:user) { { email: email, password: password, password_confirmation: password } }
|
let(:user) { {email: email, password: password, password_confirmation: password} }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@request.env["devise.mapping"] = Devise.mappings[:user]
|
@request.env["devise.mapping"] = Devise.mappings[:user]
|
||||||
|
@ -14,13 +14,25 @@ describe Users::RegistrationsController, type: :controller do
|
||||||
describe '.create' do
|
describe '.create' do
|
||||||
subject { post :create, user: user }
|
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
|
it 'welcome email is send' do
|
||||||
expect(WelcomeMailer).to receive(:welcome_email).and_return(WelcomeMailer)
|
expect(WelcomeMailer).to receive(:welcome_email).and_return(WelcomeMailer)
|
||||||
expect(WelcomeMailer).to receive(:deliver_now!)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue