2012-06-20 16:29:10 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe UserObserver do
|
2013-04-10 20:28:42 +00:00
|
|
|
before(:each) { enable_observers }
|
2013-04-25 14:15:33 +00:00
|
|
|
after(:each) {disable_observers}
|
2012-06-20 16:29:10 +00:00
|
|
|
subject { UserObserver.instance }
|
2013-12-10 13:43:27 +00:00
|
|
|
before { subject.stub(notification: double('NotificationService').as_null_object) }
|
2012-06-20 16:29:10 +00:00
|
|
|
|
|
|
|
it 'calls #after_create when new users are created' do
|
2012-11-06 03:31:55 +00:00
|
|
|
new_user = build(:user)
|
2012-06-20 16:29:10 +00:00
|
|
|
subject.should_receive(:after_create).with(new_user)
|
2013-01-02 17:46:06 +00:00
|
|
|
new_user.save
|
2012-06-20 16:29:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a new user is created' do
|
|
|
|
it 'sends an email' do
|
2013-03-26 17:00:54 +00:00
|
|
|
subject.should_receive(:notification)
|
2013-01-09 06:14:05 +00:00
|
|
|
create(:user)
|
2012-06-20 16:29:10 +00:00
|
|
|
end
|
2012-09-12 06:05:12 +00:00
|
|
|
|
|
|
|
it 'trigger logger' do
|
2012-09-19 18:36:00 +00:00
|
|
|
user = double(:user, id: 42, password: 'P@ssword!', name: 'John', email: 'u@mail.local', extern_uid?: false)
|
2012-09-12 06:05:12 +00:00
|
|
|
Gitlab::AppLogger.should_receive(:info)
|
2013-01-09 06:14:05 +00:00
|
|
|
create(:user)
|
2012-09-12 06:05:12 +00:00
|
|
|
end
|
2012-06-20 16:29:10 +00:00
|
|
|
end
|
|
|
|
end
|