FIX: when sending private message emails do not check email_direct setting

This commit is contained in:
Arpit Jalan 2015-06-09 13:05:26 +05:30 committed by Robin Ward
parent ccaf525e8d
commit 0393aa63d4
2 changed files with 20 additions and 2 deletions

View File

@ -41,7 +41,6 @@ class UserEmailObserver < ActiveRecord::Observer
def enqueue(type)
return unless notification.user.email_direct?
Jobs.enqueue_in(delay,
:user_email,
type: type,
@ -50,7 +49,8 @@ class UserEmailObserver < ActiveRecord::Observer
end
def enqueue_private(type)
return unless (notification.user.email_direct? && notification.user.email_private_messages?)
return unless notification.user.email_private_messages?
Jobs.enqueue_in(delay,
:user_email,
type: type,

View File

@ -98,6 +98,24 @@ describe UserEmailObserver do
end
context 'private_message' do
let(:user) { Fabricate(:user) }
let!(:notification) { Fabricate(:notification, user: user, notification_type: 6) }
it "enqueues a job for the email" do
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_private_message, user_id: notification.user_id, notification_id: notification.id)
UserEmailObserver.send(:new).after_commit(notification)
end
it "doesn't enqueue an email if the user has private message emails disabled" do
user.expects(:email_private_messages?).returns(false)
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_private_message)).never
UserEmailObserver.send(:new).after_commit(notification)
end
end
context 'user_invited_to_topic' do
let(:user) { Fabricate(:user) }