diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index bea3c7e45be..51e2f2109c2 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -142,6 +142,7 @@ class UserNotifications < ActionMailer::Base notification_type = opts[:notification_type] || Notification.types[@notification.notification_type].to_s return if SiteSetting.enable_mailing_list_mode && + user.mailing_list_mode && ["replied", "mentioned", "quoted", "posted"].include?(notification_type) title = @notification.data_hash[:topic_title] diff --git a/spec/mailers/user_notifications_spec.rb b/spec/mailers/user_notifications_spec.rb index 57462825239..138030c2d48 100644 --- a/spec/mailers/user_notifications_spec.rb +++ b/spec/mailers/user_notifications_spec.rb @@ -70,10 +70,11 @@ describe UserNotifications do end describe '.user_replied' do - let!(:post) { Fabricate(:post) } - let!(:response) { Fabricate(:post, topic: post.topic)} - let!(:user) { Fabricate(:user) } - let!(:notification) { Fabricate(:notification, user: user) } + let(:post) { Fabricate(:post) } + let(:response) { Fabricate(:post, topic: post.topic)} + let(:user) { Fabricate(:user) } + let(:notification) { Fabricate(:notification, user: user) } + it 'generates a correct email' do mail = UserNotifications.user_replied(response.user, post: response, notification: notification) @@ -87,6 +88,19 @@ describe UserNotifications do # side effect, topic user is updated with post number tu = TopicUser.get(post.topic_id, response.user) tu.last_emailed_post_number.should == response.post_number + + # in mailing list mode user_replies is not sent through + SiteSetting.stubs(:enable_mailing_list_mode).returns(true) + response.user.mailing_list_mode = true + mail = UserNotifications.user_replied(response.user, post: response, notification: notification) + mail.class.should == ActionMailer::Base::NullMail + + + response.user.mailing_list_mode = nil + mail = UserNotifications.user_replied(response.user, post: response, notification: notification) + + mail.class.should_not == ActionMailer::Base::NullMail + end end