diff --git a/app/models/forem/subscription.rb b/app/models/forem/subscription.rb index 9551d14b7..0e26be8c2 100644 --- a/app/models/forem/subscription.rb +++ b/app/models/forem/subscription.rb @@ -8,7 +8,7 @@ class Subscription < ActiveRecord::Base def send_notification(post_id) # If a user cannot be found, then no-op # This will happen if the user record has been deleted. - if subscriber.present? + if subscriber.present? && subscriber.email SubscriptionMailer.topic_reply(post_id, subscriber.id).deliver end end diff --git a/spec/models/subscription_spec.rb b/spec/models/subscription_spec.rb index 679bcfa78..cbb75185d 100644 --- a/spec/models/subscription_spec.rb +++ b/spec/models/subscription_spec.rb @@ -24,7 +24,7 @@ end # Regression test for #375 - it "does not send a notification when user is missing" do + it "does not send a notification when user is missing or if there is no email address" do subscription = Forem::Subscription.new Forem::SubscriptionMailer.should_not_receive(:topic_reply) subscription.send_notification(1)