diff --git a/app/models/notification.rb b/app/models/notification.rb index 8ad6a0fab21d069bff2207844a1ca5a475272b59..5fd5117f216409cbaed381c673402ab31936f39b 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -15,7 +15,7 @@ class Notification < ActiveRecord::Base end def self.notify(recipient, target, actor) - return nil unless target.respond_to? :notification_type + return nil unless target.respond_to?(:notification_type) && recipient.person != actor note_type = target.notification_type(recipient, actor) return nil unless note_type diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index e3644db8cea4a24d82f7eaec95b29dbf9a3947f3..1881aec22b5b40872df82012d31823f65103e67f 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -73,6 +73,11 @@ describe Notification, :type => :model do Notification.notify(@user, @request, @person) end + it "does nothing if told to notify oneself" do + notification = Notification.notify(@user, @request, @user.person) + expect(notification).to eq(nil) + end + describe '#emails_the_user' do it 'calls mail' do opts = {