ajout de tests unitaires sur le model team

This commit is contained in:
Lou 2021-08-03 17:07:16 +02:00
commit 544537ead4
2 changed files with 17 additions and 3 deletions

View file

@ -1,2 +1,4 @@
class Team < ApplicationRecord
validates :name, uniqueness: true, presence: true
end

View file

@ -1,7 +1,19 @@
require "test_helper"
class TeamTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test "team with valid name should be created" do
team = Team.new(name: "Valid name", description: "Random description")
assert team.valid?
end
test "team with taken name should not be created" do
other_team = teams(:one)
team = Team.new(name: other_team.name, description: "Random description")
assert_not team.valid?
end
test "team without name should not be created" do
team = Team.new(description: "Random description")
assert_not team.valid?
end
end