Files
fizzy/test/controllers/cards/pins_controller_test.rb
T
David Heinemeier Hansson fc0cf3917f Pin without redirect
Use turbo stream response to save on the redirect latency
2025-04-17 14:05:26 +02:00

32 lines
843 B
Ruby

require "test_helper"
class Cards::PinsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "create" do
assert_changes -> { cards(:layout).pinned_by?(users(:kevin)) }, from: false, to: true do
perform_enqueued_jobs do
assert_turbo_stream_broadcasts([ users(:kevin), :pins ], count: 1) do
post card_pin_path(cards(:layout)), as: :turbo_stream
end
end
end
assert_response :success
end
test "destroy" do
assert_changes -> { cards(:shipping).pinned_by?(users(:kevin)) }, from: true, to: false do
perform_enqueued_jobs do
assert_turbo_stream_broadcasts([ users(:kevin), :pins ], count: 1) do
delete card_pin_path(cards(:shipping)), as: :turbo_stream
end
end
end
assert_response :success
end
end