Avoid RecordNotFound exception thrown by find method when invalid person_id

This commit is contained in:
Gonzalo Rodriguez 2011-08-27 02:45:58 -03:00
parent d084c708b6
commit cc1add81b0
2 changed files with 7 additions and 1 deletions

View file

@ -141,7 +141,7 @@ class PeopleController < ApplicationController
end
def contacts
@person = Person.find(params[:person_id])
@person = Person.find_by_id(params[:person_id])
if @person
@contact = current_user.contact_for(@person)
@aspect = :profile

View file

@ -322,6 +322,12 @@ describe PeopleController do
assigns(:contacts_of_contact).should == contacts
response.should be_success
end
it 'shows an error when invalid person id' do
get :contacts, :person_id => 'foo'
flash[:error].should be_present
response.should redirect_to people_path
end
end
describe '#webfinger' do