gitlab-org--gitlab-foss/spec/observers/user_observer_spec.rb

27 lines
741 B
Ruby
Raw Normal View History

require 'spec_helper'
describe UserObserver do
before(:each) { enable_observers }
subject { UserObserver.instance }
before { subject.stub(notification: mock('NotificationService').as_null_object) }
it 'calls #after_create when new users are created' do
new_user = build(:user)
subject.should_receive(:after_create).with(new_user)
2013-01-02 12:46:06 -05:00
new_user.save
end
context 'when a new user is created' do
it 'sends an email' do
subject.should_receive(:notification)
2013-01-09 01:14:05 -05:00
create(:user)
end
2012-09-12 02:05:12 -04:00
it 'trigger logger' do
2012-09-19 14:36:00 -04:00
user = double(:user, id: 42, password: 'P@ssword!', name: 'John', email: 'u@mail.local', extern_uid?: false)
2012-09-12 02:05:12 -04:00
Gitlab::AppLogger.should_receive(:info)
2013-01-09 01:14:05 -05:00
create(:user)
2012-09-12 02:05:12 -04:00
end
end
end