diff --git a/app/observers/user_observer.rb b/app/observers/user_observer.rb index c1179ed7881..6c461e07865 100644 --- a/app/observers/user_observer.rb +++ b/app/observers/user_observer.rb @@ -2,7 +2,8 @@ class UserObserver < ActiveRecord::Observer def after_create(user) log_info("User \"#{user.name}\" (#{user.email}) was created") - Notify.delay.new_user_email(user.id, user.password) + # Dont email omniauth created users + Notify.delay.new_user_email(user.id, user.password) unless user.extern_uid? end def after_destroy user diff --git a/spec/observers/user_observer_spec.rb b/spec/observers/user_observer_spec.rb index bffa5fcfd69..dd7d88fafc9 100644 --- a/spec/observers/user_observer_spec.rb +++ b/spec/observers/user_observer_spec.rb @@ -15,7 +15,13 @@ describe UserObserver do create(:user) end + it 'no email for external' do + Notify.should_receive(:new_user_email) + create(:user, extern_uid: '32442eEfsafada') + end + it 'trigger logger' do + user = double(:user, id: 42, password: 'P@ssword!', name: 'John', email: 'u@mail.local', extern_uid?: false) Gitlab::AppLogger.should_receive(:info) create(:user) end