Commit 26123d54 authored by Aishwarya Subramanian's avatar Aishwarya Subramanian Committed by Robert Speicher

Trigger system hook for user create event on Trial sign up

parent 459b44af
......@@ -20,6 +20,7 @@ class RegistrationsController < Devise::RegistrationsController
super do |new_user|
persist_accepted_terms_if_required(new_user)
yield new_user if block_given?
end
rescue Gitlab::Access::AccessDeniedError
redirect_to(new_user_session_path)
......
......@@ -4,10 +4,16 @@ class TrialRegistrationsController < RegistrationsController
before_action :check_if_gl_com
before_action :check_if_improved_trials_enabled
def create
super do |new_user|
new_user.system_hook_service.execute_hooks_for(new_user, :create)
end
end
private
def sign_up_params
params.require(:user).permit(:first_name, :last_name, :username, :email, :password, :skip_confirmation)
params.require(:user).permit(:first_name, :last_name, :username, :email, :password, :skip_confirmation, :email_opted_in)
end
def resource
......
......@@ -72,6 +72,14 @@ describe TrialRegistrationsController do
expect(User.last.name).to eq("#{user_params[:first_name]} #{user_params[:last_name]}")
end
end
context 'system hook' do
it 'triggers user_create event on trial sign up' do
expect_any_instance_of(SystemHooksService).to receive(:execute_hooks_for).with(an_instance_of(User), :create)
post :create, params: { user: user_params }
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment