mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-08 15:50:08 +09:00
Merge pull request #296: Fan the unread room notice out from a job
Reviewed and merged by GPT on behalf of DHH.
This commit is contained in:
@@ -15,8 +15,11 @@ class UnreadRoomsTest < ApplicationSystemTestCase
|
||||
using_session("Kevin") do
|
||||
sign_in "kevin@37signals.com"
|
||||
join_room designers_room
|
||||
send_message("Hello!!")
|
||||
send_message("Talking to myself?")
|
||||
|
||||
perform_enqueued_jobs only: Message::BroadcastUnreadRoomJob do
|
||||
send_message("Hello!!")
|
||||
send_message("Talking to myself?")
|
||||
end
|
||||
end
|
||||
|
||||
assert_room_unread designers_room
|
||||
@@ -24,4 +27,36 @@ class UnreadRoomsTest < ApplicationSystemTestCase
|
||||
join_room designers_room
|
||||
assert_room_read designers_room
|
||||
end
|
||||
|
||||
test "a notice about a message from before the room was read in another tab doesn't mark it unread again" do
|
||||
using_session("Kevin in HQ") do
|
||||
sign_in "kevin@37signals.com"
|
||||
join_room rooms(:hq)
|
||||
broadcast_unread_notice rooms(:designers), to: users(:kevin), at: Time.current
|
||||
assert_room_unread rooms(:designers)
|
||||
end
|
||||
|
||||
sent_before_reading = Time.current
|
||||
using_session("Kevin in Designers") do
|
||||
sign_in "kevin@37signals.com"
|
||||
join_room rooms(:designers)
|
||||
end
|
||||
|
||||
using_session("Kevin in HQ") do
|
||||
assert_room_read rooms(:designers)
|
||||
|
||||
broadcast_unread_notice rooms(:designers), to: users(:kevin), at: sent_before_reading
|
||||
broadcast_unread_notice rooms(:bender_and_kevin), to: users(:kevin), at: Time.current
|
||||
assert_selector "#" + dom_id(rooms(:bender_and_kevin), :list) + ".unread"
|
||||
assert_room_read rooms(:designers)
|
||||
|
||||
broadcast_unread_notice rooms(:designers), to: users(:kevin), at: Time.current
|
||||
assert_room_unread rooms(:designers)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def broadcast_unread_notice(room, to:, at:)
|
||||
ActionCable.server.broadcast UnreadRoomsChannel.stream_name_for(to.id), { roomId: room.id, at: at.to_fs(:epoch) }
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user