tabletop-companion/test/controllers/counters_controller_test.rb

29 lines
894 B
Ruby

# frozen_string_literal: true
require "test_helper"
class CountersControllerTest < ActionDispatch::IntegrationTest
test "should render new turbo stream" do
sign_in users(:trevor)
get new_character_sheet_section_counter_url(character_sheet_sections(:counters)), as: :turbo_stream
assert_response :success
end
test "should create counter" do
sign_in users(:trevor)
assert_difference "Counter.count", 1 do
post character_sheet_section_counters_url(character_sheet_sections(:counters)),
params: { counter: { name: "Ammo", character_sheet_section_id: character_sheet_sections(:counters).id } },
as: :turbo_stream
end
end
test "should delete counter" do
sign_in users(:trevor)
assert_difference "Counter.count", -1 do
delete counter_url(Counter.first), as: :turbo_stream
assert_response :success
end
end
end