Files
once-campfire/test/controllers/rooms/refreshes_controller_test.rb
Kevin McConnell df76a227dc Hello world
First open source release of Campfire 🎉
2025-08-21 09:31:59 +01:00

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