From 6e1bd7216d726ff40e6f6b41e33bec52bc51bcac Mon Sep 17 00:00:00 2001 From: Florian Staudacher <florian_staudacher@yahoo.de> Date: Wed, 17 Sep 2014 21:39:04 +0200 Subject: [PATCH] fix /u/[username] route --- app/controllers/people_controller.rb | 6 ++++-- spec/controllers/people_controller_spec.rb | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index bfbb173799..f0782d70a4 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -174,8 +174,10 @@ class PeopleController < ApplicationController private def find_person - person_id = params[:id] || params[:person_id] - @person = Person.find_from_guid_or_username({id: person_id}) + @person = Person.find_from_guid_or_username({ + id: params[:id] || params[:person_id], + username: params[:username] + }) # view this profile on the home pod, if you don't want to sign in... authenticate_user! if remote_profile_with_no_user_session? diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 3e854f084e..734c19e9ea 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -174,6 +174,11 @@ describe PeopleController, :type => :controller do expect(response.code).to eq("404") end + it 'finds a person via username' do + get :show, username: @user.username + expect(assigns(:person)).to eq(@user.person) + end + it 'redirects home for closed account' do @person = FactoryGirl.create(:person, :closed_account => true) get :show, :id => @person.to_param -- GitLab