This commit is contained in:
r888888888
2013-04-19 15:51:38 -07:00
parent d1e843390f
commit 4320df3116
2 changed files with 19 additions and 0 deletions

View File

@@ -154,6 +154,24 @@ class UserTest < ActiveSupport::TestCase
assert_equal(Danbooru.config.default_guest_name, User.id_to_name(-1))
end
should "not contain a colon" do
user = FactoryGirl.build(:user, :name => "a:b")
user.save
assert_equal(["Name cannot have whitespace or colons"], user.errors.full_messages)
end
should "not begin with an underscore" do
user = FactoryGirl.build(:user, :name => "_x")
user.save
assert_equal(["Name cannot begin or end with an underscore"], user.errors.full_messages)
end
should "not end with an underscore" do
user = FactoryGirl.build(:user, :name => "x_")
user.save
assert_equal(["Name cannot begin or end with an underscore"], user.errors.full_messages)
end
should "be fetched given a user id" do
@user = FactoryGirl.create(:user)
assert_equal(@user.name, User.id_to_name(@user.id))