2012-10-10 00:25:29 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe NoteObserver do
|
|
|
|
subject { NoteObserver.instance }
|
2013-03-26 18:00:54 +01:00
|
|
|
before { subject.stub(notification: mock('NotificationService').as_null_object) }
|
2012-10-10 00:25:29 +02:00
|
|
|
|
2012-10-13 22:46:27 +02:00
|
|
|
let(:team_without_author) { (1..2).map { |n| double :user, id: n } }
|
|
|
|
|
2012-10-10 00:25:29 +02:00
|
|
|
describe '#after_create' do
|
2012-10-13 22:46:27 +02:00
|
|
|
let(:note) { double :note }
|
2012-10-10 00:25:29 +02:00
|
|
|
|
|
|
|
it 'is called after a note is created' do
|
|
|
|
subject.should_receive :after_create
|
|
|
|
|
|
|
|
Note.observers.enable :note_observer do
|
2012-11-06 04:31:55 +01:00
|
|
|
create(:note)
|
2012-10-10 00:25:29 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-10-13 22:46:27 +02:00
|
|
|
it 'sends out notifications' do
|
2013-03-26 18:00:54 +01:00
|
|
|
subject.should_receive(:notification)
|
2012-10-13 22:46:27 +02:00
|
|
|
|
|
|
|
subject.after_create(note)
|
|
|
|
end
|
|
|
|
end
|
2012-10-10 00:25:29 +02:00
|
|
|
end
|