From 9588a232428d7045fb3e86ce36a81437a854b160 Mon Sep 17 00:00:00 2001 From: Robb Kidd Date: Sat, 13 Oct 2012 14:37:36 -0400 Subject: [PATCH] Fix notification for notes on a wall. The fact that Notes on Walls have a noteable_type value of "nil" got lost in the refactoring of the observer. --- app/observers/note_observer.rb | 3 ++- spec/observers/note_observer_spec.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/observers/note_observer.rb b/app/observers/note_observer.rb index 3d51b9c2..d328338a 100644 --- a/app/observers/note_observer.rb +++ b/app/observers/note_observer.rb @@ -16,7 +16,8 @@ class NoteObserver < ActiveRecord::Observer protected def notify_team_of_new_note(note) - notify_method = 'note_' + note.noteable_type.underscore + '_email' + note_is_on = note.noteable_type || 'Wall' + notify_method = 'note_' + note_is_on.underscore + '_email' if Notify.respond_to? notify_method team_without_note_author(note).map do |u| diff --git a/spec/observers/note_observer_spec.rb b/spec/observers/note_observer_spec.rb index 3538cf04..fb5a3544 100644 --- a/spec/observers/note_observer_spec.rb +++ b/spec/observers/note_observer_spec.rb @@ -80,7 +80,7 @@ describe NoteObserver do subject.send(:notify_team_of_new_note, note) end it 'a wall' do - note.stub(:noteable_type).and_return('Wall') + note.stub(:noteable_type).and_return(nil) Notify.should_receive(:note_wall_email).twice.and_return(double(deliver: true)) subject.send(:notify_team_of_new_note, note)