add tests
This commit is contained in:
@@ -1,7 +1,34 @@
|
||||
require "test_helper"
|
||||
|
||||
class UserTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
test "should be valid with an email and password" do
|
||||
user = User.new(email: "test@example.com", password: "password")
|
||||
assert user.valid?
|
||||
end
|
||||
|
||||
test "should be invalid without an email" do
|
||||
user = User.new(password: "password")
|
||||
assert_not user.valid?
|
||||
end
|
||||
|
||||
test "should be invalid with a duplicate email" do
|
||||
User.create(email: "test@example.com", password: "password")
|
||||
user = User.new(email: "test@example.com", password: "password")
|
||||
assert_not user.valid?
|
||||
end
|
||||
|
||||
test "should have a default role of contributor" do
|
||||
user = User.new(email: "test@example.com", password: "password")
|
||||
assert user.contributor?
|
||||
end
|
||||
|
||||
test "can be a reviewer" do
|
||||
user = User.new(email: "test@example.com", password: "password", role: :reviewer)
|
||||
assert user.reviewer?
|
||||
end
|
||||
|
||||
test "can be an admin" do
|
||||
user = User.new(email: "test@example.com", password: "password", role: :admin)
|
||||
assert user.admin?
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user