2012-06-20 12:29:10 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe UserObserver do
|
|
|
|
subject { UserObserver.instance }
|
|
|
|
|
|
|
|
it 'calls #after_create when new users are created' do
|
2012-11-06 14:31:55 +11:00
|
|
|
new_user = build(:user)
|
2012-06-20 12:29:10 -04:00
|
|
|
subject.should_receive(:after_create).with(new_user)
|
2013-01-02 19:46:06 +02:00
|
|
|
new_user.save
|
2012-06-20 12:29:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a new user is created' do
|
|
|
|
it 'sends an email' do
|
2013-01-09 09:14:05 +03:00
|
|
|
Notify.should_receive(:new_user_email)
|
|
|
|
create(:user)
|
2012-06-20 12:29:10 -04:00
|
|
|
end
|
2012-09-12 09:05:12 +03:00
|
|
|
|
2012-09-19 13:36:00 -05:00
|
|
|
it 'no email for external' do
|
2013-03-05 16:50:37 +02:00
|
|
|
Notify.should_not_receive(:new_user_email)
|
2013-03-05 16:48:18 +02:00
|
|
|
create(:user, extern_uid: '32442eEfsafada')
|
2012-09-19 13:36:00 -05:00
|
|
|
end
|
|
|
|
|
2012-09-12 09:05:12 +03:00
|
|
|
it 'trigger logger' do
|
2012-09-19 13:36:00 -05:00
|
|
|
user = double(:user, id: 42, password: 'P@ssword!', name: 'John', email: 'u@mail.local', extern_uid?: false)
|
2012-09-12 09:05:12 +03:00
|
|
|
Gitlab::AppLogger.should_receive(:info)
|
2013-01-09 09:14:05 +03:00
|
|
|
create(:user)
|
2012-09-12 09:05:12 +03:00
|
|
|
end
|
2012-06-20 12:29:10 -04:00
|
|
|
end
|
|
|
|
end
|