BUGFIX: mailing list mode broke regular email

This commit is contained in:
Sam 2014-02-12 16:51:26 +11:00
parent 4803d387bc
commit 9ec52d9425
2 changed files with 19 additions and 4 deletions

View file

@ -142,6 +142,7 @@ class UserNotifications < ActionMailer::Base
notification_type = opts[:notification_type] || Notification.types[@notification.notification_type].to_s notification_type = opts[:notification_type] || Notification.types[@notification.notification_type].to_s
return if SiteSetting.enable_mailing_list_mode && return if SiteSetting.enable_mailing_list_mode &&
user.mailing_list_mode &&
["replied", "mentioned", "quoted", "posted"].include?(notification_type) ["replied", "mentioned", "quoted", "posted"].include?(notification_type)
title = @notification.data_hash[:topic_title] title = @notification.data_hash[:topic_title]

View file

@ -70,10 +70,11 @@ describe UserNotifications do
end end
describe '.user_replied' do describe '.user_replied' do
let!(:post) { Fabricate(:post) } let(:post) { Fabricate(:post) }
let!(:response) { Fabricate(:post, topic: post.topic)} let(:response) { Fabricate(:post, topic: post.topic)}
let!(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }
let!(:notification) { Fabricate(:notification, user: user) } let(:notification) { Fabricate(:notification, user: user) }
it 'generates a correct email' do it 'generates a correct email' do
mail = UserNotifications.user_replied(response.user, post: response, notification: notification) 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 # side effect, topic user is updated with post number
tu = TopicUser.get(post.topic_id, response.user) tu = TopicUser.get(post.topic_id, response.user)
tu.last_emailed_post_number.should == response.post_number 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
end end