Update User#identifier to conform to Gitolite 2.x's user pattern

Also modifies the specs a bit because I can't help myself.

Closes #480
This commit is contained in:
Robert Speicher 2012-09-04 00:04:36 -04:00
parent b44e9a08d5
commit d29827433d
3 changed files with 47 additions and 30 deletions

View file

@ -1,6 +1,13 @@
module Account
module Account
# Returns a string for use as a Gitolite user identifier
#
# Note that Gitolite 2.x requires the following pattern for users:
#
# ^@?[0-9a-zA-Z][0-9a-zA-Z._\@+-]*$
def identifier
email.gsub /[^[:alnum:]]/, "_"
# Replace non-word chars with underscores, then make sure it starts with
# valid chars
email.gsub(/\W/, '_').gsub(/\A([\W\_])+/, '')
end
def is_admin?