67 lines
2.1 KiB
Ruby
67 lines
2.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "test_helper"
|
|
|
|
class AdminGameSystemsIntegrationTest < ActionDispatch::IntegrationTest
|
|
test "index should show most all game systems" do
|
|
sign_in users(:admin)
|
|
get admin_game_systems_path
|
|
assert_response :success
|
|
|
|
assert_select ".game-system", GameSystem.all.size
|
|
end
|
|
|
|
test "show should show game system" do
|
|
sign_in users(:admin)
|
|
get admin_game_system_path(game_systems(:troika))
|
|
assert_response :success
|
|
assert_select "h2", game_systems(:troika).name
|
|
end
|
|
|
|
test "new should show form to create new game system" do
|
|
sign_in users(:admin)
|
|
get new_admin_game_system_path
|
|
assert_response :success
|
|
|
|
assert_select "form[action=?][method=?]", admin_game_systems_path, "post"
|
|
end
|
|
|
|
test "create should create new game system" do
|
|
sign_in users(:admin)
|
|
assert_difference "GameSystem.count", 1 do
|
|
post admin_game_systems_path, params: { game_system: { name: "Test Game System" } }
|
|
end
|
|
assert_redirected_to admin_game_system_path(GameSystem.last)
|
|
end
|
|
|
|
test "create should fail if game system already exists" do
|
|
sign_in users(:admin)
|
|
assert_no_difference "GameSystem.count" do
|
|
post admin_game_systems_path, params: { game_system: { name: game_systems(:troika).name } }
|
|
end
|
|
assert_response :unprocessable_entity
|
|
end
|
|
|
|
test "edit should show form to edit game system" do
|
|
sign_in users(:admin)
|
|
get edit_admin_game_system_path(game_systems(:troika))
|
|
assert_response :success
|
|
|
|
assert_select "form[action=?][method=?]", admin_game_system_path(game_systems(:troika)), "post"
|
|
end
|
|
|
|
test "update should update game system" do
|
|
sign_in users(:admin)
|
|
patch admin_game_system_path(game_systems(:troika)), params: { game_system: { name: "Test Game System" } }
|
|
assert_redirected_to admin_game_system_path(game_systems(:troika))
|
|
end
|
|
|
|
test "destroy should destroy game system" do
|
|
sign_in users(:admin)
|
|
assert_difference "GameSystem.count", -1 do
|
|
delete admin_game_system_path(game_systems(:dnd))
|
|
end
|
|
assert_redirected_to admin_game_systems_path
|
|
end
|
|
end
|