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 <vaidehi.sj@gmail.com>

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
This commit is contained in:
Julianna Tetreault 2020-05-29 13:08:46 -06:00 committed by GitHub
parent a4be185720
commit fa3caaf513
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -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

View file

@ -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) }