refactor observers test since email logic moved to service

This commit is contained in:
Dmitriy Zaporozhets 2013-03-26 19:00:54 +02:00
parent ce0945efcd
commit 3728c4904e
7 changed files with 19 additions and 164 deletions

View file

@ -2,6 +2,7 @@ require 'spec_helper'
describe UserObserver do
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)
@ -11,15 +12,10 @@ describe UserObserver do
context 'when a new user is created' do
it 'sends an email' do
Notify.should_receive(:new_user_email)
subject.should_receive(:notification)
create(:user)
end
it 'no email for external' do
Notify.should_not_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)