mirror of
https://github.com/redmine/redmine.git
synced 2026-01-08 08:32:59 +01:00
Increase username length limit from 30 to 60 (#2719).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8778 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -547,14 +547,13 @@ class MailHandlerTest < ActiveSupport::TestCase
|
||||
['jsmith@example.net', 'John Smith'] => ['jsmith@example.net', 'John', 'Smith'],
|
||||
['jsmith@example.net', 'John Paul Smith'] => ['jsmith@example.net', 'John', 'Paul Smith'],
|
||||
['jsmith@example.net', 'AVeryLongFirstnameThatExceedsTheMaximumLength Smith'] => ['jsmith@example.net', 'AVeryLongFirstnameThatExceedsT', 'Smith'],
|
||||
['jsmith@example.net', 'John AVeryLongLastnameThatExceedsTheMaximumLength'] => ['jsmith@example.net', 'John', 'AVeryLongLastnameThatExceedsTh'],
|
||||
['alongemailaddressthatexceedsloginlength@example.net', 'John Smith'] => ['alongemailaddressthatexceedslo', 'John', 'Smith']
|
||||
['jsmith@example.net', 'John AVeryLongLastnameThatExceedsTheMaximumLength'] => ['jsmith@example.net', 'John', 'AVeryLongLastnameThatExceedsTh']
|
||||
}
|
||||
|
||||
to_test.each do |attrs, expected|
|
||||
user = MailHandler.new_user_from_attributes(attrs.first, attrs.last)
|
||||
|
||||
assert user.valid?
|
||||
assert user.valid?, user.errors.full_messages
|
||||
assert_equal attrs.first, user.mail
|
||||
assert_equal expected[0], user.login
|
||||
assert_equal expected[1], user.firstname
|
||||
@@ -571,12 +570,10 @@ class MailHandlerTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def test_new_user_from_attributes_should_use_default_login_if_invalid
|
||||
MailHandler.new_user_from_attributes('alongemailaddressthatexceedsloginlength-1@example.net').save!
|
||||
|
||||
# another long address that would result in duplicate login
|
||||
user = MailHandler.new_user_from_attributes('alongemailaddressthatexceedsloginlength-2@example.net')
|
||||
user = MailHandler.new_user_from_attributes('foo+bar@example.net')
|
||||
assert user.valid?
|
||||
assert user.login =~ /^user[a-f0-9]+$/
|
||||
assert_equal 'foo+bar@example.net', user.mail
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -58,6 +58,16 @@ class UserTest < ActiveSupport::TestCase
|
||||
u.errors[:mail].to_s
|
||||
end
|
||||
|
||||
def test_login_length_validation
|
||||
user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
|
||||
user.login = "x" * (User::LOGIN_LENGTH_LIMIT+1)
|
||||
assert !user.valid?
|
||||
|
||||
user.login = "x" * (User::LOGIN_LENGTH_LIMIT)
|
||||
assert user.valid?
|
||||
assert user.save
|
||||
end
|
||||
|
||||
def test_create
|
||||
user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user