Skip to content
Extraits de code Groupes Projets
Valider 1d463d22 rédigé par Raphael's avatar Raphael
Parcourir les fichiers

Person show for a nonexistent person now redirects to people index page, rather than giving a 500

parent 1fd3aeab
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -17,7 +17,19 @@ class PeopleController < ApplicationController ...@@ -17,7 +17,19 @@ class PeopleController < ApplicationController
end end
def show def show
@person = current_user.visible_person_by_id(params[:id]) 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 @profile = @person.profile
@aspects_with_person = current_user.aspects_with_person(@person) @aspects_with_person = current_user.aspects_with_person(@person)
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]} @aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
......
...@@ -22,4 +22,12 @@ describe PeopleController do ...@@ -22,4 +22,12 @@ describe PeopleController do
it 'should go to the current_user show page' do it 'should go to the current_user show page' do
get :show, :id => @user.person.id get :show, :id => @user.person.id
end 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 end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter