From fa3caaf5130fff9e94c5c2aaab9ca0d1b7b04b24 Mon Sep 17 00:00:00 2001 From: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com> Date: Fri, 29 May 2020 13:08:46 -0600 Subject: [PATCH] Enqueue feed_customization_notification (#8160) * Set notification_enqueued to true in #send_feed_customization_notification * Fix typo in generator_spec.rb * Add comment about enqueuing notification in generator.rb * Update app/services/broadcasts/welcome_notification/generator.rb Co-authored-by: Vaidehi Joshi Co-authored-by: Vaidehi Joshi --- app/services/broadcasts/welcome_notification/generator.rb | 2 ++ spec/services/broadcasts/welcome_notification/generator_spec.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/services/broadcasts/welcome_notification/generator.rb b/app/services/broadcasts/welcome_notification/generator.rb index 3e6be1cee..e6ecf6b82 100644 --- a/app/services/broadcasts/welcome_notification/generator.rb +++ b/app/services/broadcasts/welcome_notification/generator.rb @@ -31,6 +31,7 @@ module Broadcasts return if received_notification?(welcome_broadcast) || commented_on_welcome_thread? || user.created_at > 3.hours.ago Notification.send_welcome_notification(user.id, welcome_broadcast.id) + # Setting @notification_enqueued here prevents us from sending a user two welcome notifications in one day. @notification_enqueued = true end @@ -45,6 +46,7 @@ module Broadcasts return if user_is_following_tags? || received_notification?(customize_feed_broadcast) || user.created_at > 3.days.ago Notification.send_welcome_notification(user.id, customize_feed_broadcast.id) + @notification_enqueued = true end def send_ux_customization_notification diff --git a/spec/services/broadcasts/welcome_notification/generator_spec.rb b/spec/services/broadcasts/welcome_notification/generator_spec.rb index 6ca1acddd..76c7ecdf6 100644 --- a/spec/services/broadcasts/welcome_notification/generator_spec.rb +++ b/spec/services/broadcasts/welcome_notification/generator_spec.rb @@ -39,7 +39,7 @@ RSpec.describe Broadcasts::WelcomeNotification::Generator, type: :service do end.to not_change(user.notifications, :count) end - it "does not send a notification and if no active broadcast exists" do + it "does not send a notification if no active broadcast exists" do welcome_broadcast.update!(active: false) expect do sidekiq_perform_enqueued_jobs { described_class.call(user.id) }