Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions test/requests/core_flows_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
require "test_helper"
require "active_job/test_helper"
require "time"

class CoreFlowsTest < ActionDispatch::IntegrationTest
include ActiveJob::TestHelper

setup do
@original_queue_adapter = ActiveJob::Base.queue_adapter
ActiveJob::Base.queue_adapter = :test
clear_enqueued_jobs
clear_performed_jobs
end

teardown do
clear_enqueued_jobs
clear_performed_jobs
ActiveJob::Base.queue_adapter = @original_queue_adapter
end

test "GET / responds successfully" do
counter = Counter.clicks
Copy link
Copy Markdown
Author

@roo-code-bruno roo-code-bruno Bot Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pre-creates the clicks row before the request, so the test no longer exercises the controller path that bootstraps the counter from an empty database. A regression where home#index stops initializing that record would still pass here.

Fix it with Roomote


get root_path

assert_response :success
assert_select "h1", text: "Hello, World!"
assert_select "#counter_display", text: /\b#{counter.value}\b/
end

test "GET /ping returns the current pong payload" do
get ping_path

assert_response :success
assert_equal "application/json", response.media_type

payload = response.parsed_body

assert_equal "Pong", payload["message"]
assert Time.iso8601(payload["timestamp"])
end

test "POST /increment redirects home and enqueues the increment job" do
counter = Counter.clicks
counter.update!(value: 7)

assert_no_changes -> { counter.reload.value } do
assert_enqueued_with(job: IncrementCounterJob) do
post increment_path
end
end

assert_redirected_to root_path

follow_redirect!

assert_response :success
assert_match "Job enqueued! Counter will increment in ~2 seconds.", response.body
assert_select "#counter_display", text: /\b7\b/
end
end