Allow for multiple notifications to be read
cc @kevinmcconnell
This commit is contained in:
@@ -2,7 +2,7 @@ class Cards::ReadingsController < ApplicationController
|
||||
include CardScoped
|
||||
|
||||
def create
|
||||
Current.user.notifications.unread.where(card: @card).read_all
|
||||
@notifications = Current.user.notifications.unread.ordered.limit(20)
|
||||
@notifications = Current.user.notifications.where(card: @card)
|
||||
@notifications.each(&:read)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<%= turbo_stream.update "notifications" do %>
|
||||
<%= render collection: @notifications, partial: "notifications/notification" %>
|
||||
<% @notifications.each do |notification| %>
|
||||
<%= turbo_stream.remove notification %>
|
||||
<% end %>
|
||||
|
||||
@@ -5,11 +5,21 @@ class Cards::ReadingsControllerTest < ActionDispatch::IntegrationTest
|
||||
sign_in_as :kevin
|
||||
end
|
||||
|
||||
test "index" do
|
||||
test "read one notification on card visit" do
|
||||
assert_changes -> { notifications(:logo_published_kevin).reload.read? }, from: false, to: true do
|
||||
post card_reading_path(cards(:logo)), as: :turbo_stream
|
||||
end
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "read multiple notifications on card visit" do
|
||||
assert_changes -> { notifications(:logo_published_kevin).reload.read? }, from: false, to: true do
|
||||
assert_changes -> { notifications(:logo_assignment_kevin).reload.read? }, from: false, to: true do
|
||||
post card_reading_path(cards(:logo)), as: :turbo_stream
|
||||
end
|
||||
end
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
Vendored
+7
@@ -5,6 +5,13 @@ logo_published_kevin:
|
||||
resource: logo (Card)
|
||||
created_at: <%= 1.week.ago %>
|
||||
|
||||
logo_assignment_kevin:
|
||||
user: kevin
|
||||
event: logo_assignment_km
|
||||
card: logo
|
||||
resource: logo (Card)
|
||||
created_at: <%= 1.week.ago %>
|
||||
|
||||
layout_commented_kevin:
|
||||
user: kevin
|
||||
event: layout_commented
|
||||
|
||||
Reference in New Issue
Block a user