Person show for a nonexistent person now redirects to people index page, rather than giving a 500
This commit is contained in:
parent
1fd3aeabd9
commit
1d463d22a1
2 changed files with 21 additions and 1 deletions
|
|
@ -17,7 +17,19 @@ class PeopleController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
begin
|
||||
@person = current_user.visible_person_by_id(params[:id])
|
||||
rescue BSON::InvalidObjectId
|
||||
flash[:error] = "Person not found."
|
||||
redirect_to people_path
|
||||
return
|
||||
end
|
||||
unless @person
|
||||
flash[:error] = "Person not found."
|
||||
redirect_to people_path
|
||||
return
|
||||
end
|
||||
|
||||
@profile = @person.profile
|
||||
@aspects_with_person = current_user.aspects_with_person(@person)
|
||||
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,12 @@ describe PeopleController do
|
|||
it 'should go to the current_user show page' do
|
||||
get :show, :id => @user.person.id
|
||||
end
|
||||
|
||||
it "doesn't error out on an invalid id" do
|
||||
get :show, :id => 'delicious'
|
||||
end
|
||||
|
||||
it "doesn't error out on a nonexistent person" do
|
||||
get :show, :id => @user.id
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue