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
Jérome Perrin
gitlab-ce
Commits
a364d426
Commit
a364d426
authored
Jul 18, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make username parameter for Users#show case-insensitive
Closes #2012
parent
26a9faab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
11 deletions
+26
-11
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+1
-1
spec/controllers/users_controller_spec.rb
spec/controllers/users_controller_spec.rb
+25
-10
No files found.
app/controllers/users_controller.rb
View file @
a364d426
...
@@ -50,7 +50,7 @@ class UsersController < ApplicationController
...
@@ -50,7 +50,7 @@ class UsersController < ApplicationController
private
private
def
set_user
def
set_user
@user
=
User
.
find_by
_username!
(
params
[
:username
]
)
@user
=
User
.
find_by
!
(
'lower(username) = ?'
,
params
[
:username
].
downcase
)
unless
current_user
||
@user
.
public_profile?
unless
current_user
||
@user
.
public_profile?
return
authenticate_user!
return
authenticate_user!
...
...
spec/controllers/users_controller_spec.rb
View file @
a364d426
require
'spec_helper'
require
'spec_helper'
describe
UsersController
do
describe
UsersController
do
let
(
:user
)
{
create
(
:user
,
username:
'user1'
,
name:
'User 1'
,
email:
'user1@gitlab.com'
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
sign_in
(
user
)
end
describe
'GET #show'
do
describe
'GET #show'
do
render_views
it
'is case-insensitive'
do
user
=
create
(
:user
,
username:
'CamelCaseUser'
)
sign_in
(
user
)
get
:show
,
username:
user
.
username
.
downcase
it
'renders the show template'
do
expect
(
response
).
to
be_success
get
:show
,
username:
user
.
username
end
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
).
to
render_template
(
'show'
)
context
'with rendered views'
do
render_views
it
'renders the show template'
do
sign_in
(
user
)
get
:show
,
username:
user
.
username
expect
(
response
).
to
be_success
expect
(
response
).
to
render_template
(
'show'
)
end
end
end
end
end
describe
'GET #calendar'
do
describe
'GET #calendar'
do
it
'renders calendar'
do
it
'renders calendar'
do
sign_in
(
user
)
get
:calendar
,
username:
user
.
username
get
:calendar
,
username:
user
.
username
expect
(
response
).
to
render_template
(
'calendar'
)
expect
(
response
).
to
render_template
(
'calendar'
)
end
end
end
end
...
@@ -30,6 +43,8 @@ describe UsersController do
...
@@ -30,6 +43,8 @@ describe UsersController do
before
do
before
do
allow_any_instance_of
(
User
).
to
receive
(
:contributed_projects_ids
).
and_return
([
project
.
id
])
allow_any_instance_of
(
User
).
to
receive
(
:contributed_projects_ids
).
and_return
([
project
.
id
])
sign_in
(
user
)
project
.
team
<<
[
user
,
:developer
]
project
.
team
<<
[
user
,
:developer
]
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