Stack notifications everywhere
We had client-side notification stacking in the tray since launch, but now we want to stack notifications in the notifications page, in API responses and in email bundles.
This commit is contained in:
@@ -5,6 +5,7 @@ class Notification::BundleTest < ActiveSupport::TestCase
|
||||
|
||||
setup do
|
||||
@user = users(:david)
|
||||
@user.notifications.destroy_all
|
||||
@user.settings.bundle_email_every_few_hours!
|
||||
end
|
||||
|
||||
@@ -25,7 +26,7 @@ class Notification::BundleTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
test "notifications are bundled withing the aggregation period" do
|
||||
test "notifications are bundled within the aggregation period" do
|
||||
@user.notification_bundles.destroy_all
|
||||
|
||||
notification_1 = assert_difference -> { @user.notification_bundles.pending.count }, 1 do
|
||||
@@ -34,12 +35,12 @@ class Notification::BundleTest < ActiveSupport::TestCase
|
||||
travel_to 3.hours.from_now
|
||||
|
||||
notification_2 = assert_no_difference -> { @user.notification_bundles.count } do
|
||||
@user.notifications.create!(source: events(:logo_published), creator: @user)
|
||||
@user.notifications.create!(source: events(:layout_published), creator: @user)
|
||||
end
|
||||
travel_to 3.days.from_now
|
||||
|
||||
notification_3 = assert_difference -> { @user.notification_bundles.pending.count }, 1 do
|
||||
@user.notifications.create!(source: events(:logo_published), creator: @user)
|
||||
@user.notifications.create!(source: events(:text_published), creator: @user)
|
||||
end
|
||||
|
||||
assert_equal 2, @user.notification_bundles.count
|
||||
@@ -150,10 +151,10 @@ class Notification::BundleTest < ActiveSupport::TestCase
|
||||
|
||||
test "out-of-order notification bundling should still work" do
|
||||
first_notification = @user.notifications.create!(source: events(:logo_published), creator: @user)
|
||||
second_notification = @user.notifications.create!(source: events(:logo_published), creator: @user)
|
||||
second_notification = @user.notifications.create!(source: events(:layout_commented), creator: @user)
|
||||
@user.notification_bundles.destroy_all
|
||||
|
||||
assert first_notification.created_at < second_notification.created_at
|
||||
assert first_notification.updated_at <= second_notification.updated_at
|
||||
@user.bundle(second_notification)
|
||||
@user.bundle(first_notification)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user