tabletop-companion/test/models/game_system_test.rb

34 lines
835 B
Ruby

# frozen_string_literal: true
require "test_helper"
class GameSystemTest < ActiveSupport::TestCase
test "name must exist" do
assert_must_exist(game_systems(:troika), :name)
end
test "cannot delete games with characters" do
game = game_systems(:dnd)
game.tables.destroy_all
assert_no_difference("GameSystem.count") do
game_systems(:dnd).destroy
end
game.characters.destroy_all
assert_difference("GameSystem.count", -1) do
game_systems(:dnd).destroy
end
end
test "cannot delete games with tables" do
game = game_systems(:dnd)
game.characters.destroy_all
assert_no_difference("GameSystem.count") do
game_systems(:dnd).destroy
end
game.tables.destroy_all
assert_difference("GameSystem.count", -1) do
game_systems(:dnd).destroy
end
end
end