Don't bundle new notifications is bundling is disabled
This commit is contained in:
@@ -43,6 +43,6 @@ class Notification < ApplicationRecord
|
||||
end
|
||||
|
||||
def bundle
|
||||
user.bundle(self)
|
||||
user.bundle(self) if user.settings.bundling_emails?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,12 +19,16 @@ class User::Settings < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def bundling_emails?
|
||||
!bundle_email_never?
|
||||
end
|
||||
|
||||
private
|
||||
def review_pending_bundles
|
||||
if bundle_email_never?
|
||||
cancel_pending_bundles
|
||||
else
|
||||
if bundling_emails?
|
||||
reschedule_pending_bundles
|
||||
else
|
||||
cancel_pending_bundles
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ require "test_helper"
|
||||
class Notification::BundleTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@user = users(:david)
|
||||
@user.settings.bundle_email_every_few_hours!
|
||||
end
|
||||
|
||||
test "new notifications are bundled" do
|
||||
@@ -14,6 +15,14 @@ class Notification::BundleTest < ActiveSupport::TestCase
|
||||
assert_includes bundle.notifications, notification
|
||||
end
|
||||
|
||||
test "don't bundle new notifications if bundling is disabled" do
|
||||
@user.settings.bundle_email_never!
|
||||
|
||||
assert_no_difference -> { @user.notification_bundles.count } do
|
||||
@user.notifications.create!(source: events(:logo_published), creator: @user)
|
||||
end
|
||||
end
|
||||
|
||||
test "notifications are bundled withing the aggregation period" do
|
||||
notification_1 = assert_difference -> { @user.notification_bundles.pending.count }, 1 do
|
||||
@user.notifications.create!(source: events(:logo_published), creator: @user)
|
||||
|
||||
Reference in New Issue
Block a user