mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-03-12 13:15:16 +09:00
33 lines
984 B
Ruby
33 lines
984 B
Ruby
require "test_helper"
|
|
|
|
class Rooms::RefreshesControllerTest < ActionDispatch::IntegrationTest
|
|
setup do
|
|
sign_in :david
|
|
end
|
|
|
|
test "refresh includes new messages since the last known" do
|
|
travel_to 1.day.ago do
|
|
@old_message = rooms(:hq).messages.create!(creator: users(:jason), body: "Old message", client_message_id: "old")
|
|
end
|
|
|
|
travel_to 1.minute.ago do
|
|
@new_message = rooms(:hq).messages.create!(creator: users(:jason), body: "New message", client_message_id: "new")
|
|
@old_message.touch
|
|
end
|
|
|
|
get room_refresh_url(rooms(:hq), format: :turbo_stream), params: { since: 10.minutes.ago.to_fs(:epoch) }
|
|
|
|
assert_response :success
|
|
|
|
assert_select "turbo-stream[action='append']" do
|
|
assert_select "#" + dom_id(@new_message)
|
|
assert_select "template", count: 1
|
|
end
|
|
|
|
assert_select "turbo-stream[action='replace']" do
|
|
assert_select "#" + dom_id(@old_message)
|
|
assert_select "template", count: 1
|
|
end
|
|
end
|
|
end
|