A platform for community discussion. Free, open, simple.
FIX: Staged users getting user_linked and user_quoted emails
Blake Erickson04b431b6a449
diff --git a/app/services/notification_emailer.rb b/app/services/notification_emailer.rbindex 40e044105d6..db51246e3db 100644--- a/app/services/notification_emailer.rb+++ b/app/services/notification_emailer.rb@@ -90,6 +90,7 @@ class NotificationEmaileruser = notification.userreturn unless user.active? || user.staged?return if SiteSetting.must_approve_users? && !user.approved? && !user.staged?+ return if user.staged? && (type == :user_linked || type == :user_quoted)return unless EMAILABLE_POST_TYPES.include?(post_type)diff --git a/spec/services/notification_emailer_spec.rb b/spec/services/notification_emailer_spec.rbindex e28e17201d9..9ca6d409575 100644--- a/spec/services/notification_emailer_spec.rb+++ b/spec/services/notification_emailer_spec.rb@@ -36,17 +36,24 @@ describe NotificationEmailer doNotificationEmailer.process_notification(notification)end- it "enqueues a job if the user is staged" do+ it "enqueues a job if the user is staged for non-linked and non-quoted types" donotification.user.staged = true- Jobs.expects(:enqueue_in).with(delay, :user_email, NotificationEmailer::EmailUser.notification_params(notification, type))+ if type == :user_linked || type == :user_quoted+ Jobs.expects(:enqueue_in).with(delay, :user_email, has_entry(type: type)).never+ else+ Jobs.expects(:enqueue_in).with(delay, :user_email, NotificationEmailer::EmailUser.notification_params(notification, type))+ endNotificationEmailer.process_notification(notification)end- it "enqueues a job if the user is staged even if site requires user approval" do- SiteSetting.must_approve_users = true-+ it "enqueues a job if the user is staged even if site requires user approval for non-linked and non-quoted typed" donotification.user.staged = true- Jobs.expects(:enqueue_in).with(delay, :user_email, NotificationEmailer::EmailUser.notification_params(notification, type))+ SiteSetting.must_approve_users = true+ if type == :user_linked || type == :user_quoted+ Jobs.expects(:enqueue_in).with(delay, :user_email, has_entry(type: type)).never+ else+ Jobs.expects(:enqueue_in).with(delay, :user_email, NotificationEmailer::EmailUser.notification_params(notification, type))+ endNotificationEmailer.process_notification(notification)endend