summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-05 11:50:53 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-05 11:50:53 +0000
commita00f04886fac78e489bb030d20414ebdf10841e3 (patch)
tree91d304c1be59bd251afb54143c288eebef2ed1e4 /test
parent1d4ef8964def4ecbe7a11485f72d7fbe61c55724 (diff)
downloadredmine-a00f04886fac78e489bb030d20414ebdf10841e3.tar.gz
redmine-a00f04886fac78e489bb030d20414ebdf10841e3.zip
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
Diffstat (limited to 'test')
-rw-r--r--test/unit/mail_handler_test.rb11
-rw-r--r--test/unit/user_test.rb10
2 files changed, 14 insertions, 7 deletions
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb
index d21c46183..205f68607 100644
--- a/test/unit/mail_handler_test.rb
+++ b/test/unit/mail_handler_test.rb
@@ -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
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index a9484501d..b75555383 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -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")