associate user at his invite after sign up devise account
This commit is contained in:
parent
6b7d3e0ac1
commit
b3a90376d4
2 changed files with 23 additions and 1 deletions
|
@ -3,7 +3,9 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|||
# before_filter :configure_account_update_params, only: [:update]
|
||||
|
||||
def after_sign_up_path_for(resource_or_scope)
|
||||
WelcomeMailer.welcome_email(User.last).deliver_now!
|
||||
WelcomeMailer.welcome_email(resource_or_scope).deliver_now!
|
||||
check_invite! resource_or_scope
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
|
@ -62,4 +64,11 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|||
# def after_inactive_sign_up_path_for(resource)
|
||||
# super(resource)
|
||||
# end
|
||||
|
||||
private
|
||||
|
||||
def check_invite! user
|
||||
Invite.where(email: user.email)
|
||||
.each { |invite| invite.update_attribute(:user, user) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,6 +23,19 @@ describe Users::RegistrationsController, type: :controller do
|
|||
|
||||
subject
|
||||
end
|
||||
|
||||
describe '#check_invite!' do
|
||||
let!(:invite) { create :invite, email: email }
|
||||
let!(:invite2) { create :invite, email: email }
|
||||
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
it 'the new user is connect at his two invite' do
|
||||
expect(User.last.invites.size).to eq 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user is not correct' do
|
||||
|
|
Loading…
Reference in a new issue