implement /setup and /admin
This commit is contained in:
@@ -2,33 +2,39 @@ require "test_helper"
|
||||
|
||||
class UserTest < ActiveSupport::TestCase
|
||||
test "should be valid with an email and password" do
|
||||
user = User.new(email: "test@example.com", password: "password")
|
||||
user = User.new(email: "test@example.com", password: "password123456")
|
||||
assert user.valid?
|
||||
end
|
||||
|
||||
test "should be invalid without an email" do
|
||||
user = User.new(password: "password")
|
||||
user = User.new(password: "password123456")
|
||||
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")
|
||||
User.create(email: "test@example.com", password: "password123456")
|
||||
user = User.new(email: "test@example.com", password: "password123456")
|
||||
assert_not user.valid?
|
||||
end
|
||||
|
||||
test "should have a default role of contributor" do
|
||||
user = User.new(email: "test@example.com", password: "password")
|
||||
user = User.new(email: "test@example.com", password: "password123456")
|
||||
assert user.contributor?
|
||||
end
|
||||
|
||||
test "can be a reviewer" do
|
||||
user = User.new(email: "test@example.com", password: "password", role: :reviewer)
|
||||
user = User.new(email: "test@example.com", password: "password123456", role: :reviewer)
|
||||
assert user.reviewer?
|
||||
end
|
||||
|
||||
test "can be an admin" do
|
||||
user = User.new(email: "test@example.com", password: "password", role: :admin)
|
||||
user = User.new(email: "test@example.com", password: "password123456", role: :admin)
|
||||
assert user.admin?
|
||||
end
|
||||
|
||||
test "should be invalid with a password shorter than 12 characters" do
|
||||
user = User.new(email: "test@example.com", password: "short")
|
||||
assert_not user.valid?
|
||||
assert_includes user.errors[:password], "is too short (minimum is 12 characters)"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user