Commit a364d426 authored by Robert Speicher's avatar Robert Speicher

Make username parameter for Users#show case-insensitive

Closes #2012
parent 26a9faab
Pipeline #69619 failed with stage
......@@ -50,7 +50,7 @@ class UsersController < ApplicationController
private
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?
return authenticate_user!
......
require 'spec_helper'
describe UsersController do
let(:user) { create(:user, username: 'user1', name: 'User 1', email: 'user1@gitlab.com') }
before do
sign_in(user)
end
let(:user) { create(:user) }
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
get :show, username: user.username
expect(response.status).to eq(200)
expect(response).to render_template('show')
expect(response).to be_success
end
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
describe 'GET #calendar' do
it 'renders calendar' do
sign_in(user)
get :calendar, username: user.username
expect(response).to render_template('calendar')
end
end
......@@ -30,6 +43,8 @@ describe UsersController do
before do
allow_any_instance_of(User).to receive(:contributed_projects_ids).and_return([project.id])
sign_in(user)
project.team << [user, :developer]
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment