Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
fd178c1e
Commit
fd178c1e
authored
Jan 02, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent duplicate "username has already been taken" validation message
Closes #201 - two-year-old bug, woo!
💥
🎉
parent
de6b6ccc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
app/models/user.rb
app/models/user.rb
+4
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+1
-1
No files found.
app/models/user.rb
View file @
fd178c1e
...
...
@@ -352,10 +352,13 @@ class User < ActiveRecord::Base
end
def
namespace_uniq
# Return early if username already failed the first uniqueness validation
return
if
self
.
errors
[
:username
].
include?
(
'has already been taken'
)
namespace_name
=
self
.
username
existing_namespace
=
Namespace
.
by_path
(
namespace_name
)
if
existing_namespace
&&
existing_namespace
!=
self
.
namespace
self
.
errors
.
add
:username
,
"already exists"
self
.
errors
.
add
(
:username
,
'has already been taken'
)
end
end
...
...
spec/models/user_spec.rb
View file @
fd178c1e
...
...
@@ -106,7 +106,7 @@ describe User, models: true do
end
it
'validates uniqueness'
do
expect
(
subject
).
to
validate_uniqueness_of
(
:username
)
expect
(
subject
).
to
validate_uniqueness_of
(
:username
)
.
case_insensitive
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment