diff options
author | Stan Hu <stanhu@gmail.com> | 2017-08-25 16:15:43 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-08-25 22:00:07 -0700 |
commit | e94a2fde0dbb1802ad3e01486c2c8f6d8a3ee4da (patch) | |
tree | 9a6a19be034620c5a388d2285b228949ce20f3b8 /spec/services/users | |
parent | 2be34630623711fc20ef8c101b5cef688f207cc1 (diff) | |
download | gitlab-ce-e94a2fde0dbb1802ad3e01486c2c8f6d8a3ee4da.tar.gz |
Fire system hooks when a user is created via LDAP or OAuthsh-system-hooks-ldap-users
Closes #37073
Diffstat (limited to 'spec/services/users')
-rw-r--r-- | spec/services/users/update_service_spec.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/spec/services/users/update_service_spec.rb b/spec/services/users/update_service_spec.rb index 985f6d94876..6ee35a33b2d 100644 --- a/spec/services/users/update_service_spec.rb +++ b/spec/services/users/update_service_spec.rb @@ -37,7 +37,10 @@ describe Users::UpdateService do describe '#execute!' do it 'updates the name' do - result = update_user(user, name: 'New Name') + service = described_class.new(user, name: 'New Name') + expect(service).not_to receive(:notify_new_user) + + result = service.execute! expect(result).to be true expect(user.name).to eq('New Name') @@ -49,6 +52,18 @@ describe Users::UpdateService do end.to raise_error(ActiveRecord::RecordInvalid) end + it 'fires system hooks when a new user is saved' do + system_hook_service = spy(:system_hook_service) + user = build(:user) + service = described_class.new(user, name: 'John Doe') + expect(service).to receive(:notify_new_user).and_call_original + expect(service).to receive(:system_hook_service).and_return(system_hook_service) + + service.execute + + expect(system_hook_service).to have_received(:execute_hooks_for).with(user, :create) + end + def update_user(user, opts) described_class.new(user, opts).execute! end |