Add a spec to people_controller, make those specs a little clearer

This commit is contained in:
Raphael 2010-11-02 17:10:19 -07:00
parent ccd92fb850
commit 5cdeed6c54
2 changed files with 12 additions and 2 deletions

View file

@ -56,6 +56,7 @@ class PeopleController < ApplicationController
end end
# upload and set new profile photo # upload and set new profile photo
params[:person][:profile] ||= {}
if params[:person][:profile][:image].present? if params[:person][:profile][:image].present?
raw_image = params[:person][:profile].delete(:image) raw_image = params[:person][:profile].delete(:image)
params[:profile_image_hash] = { :user_file => raw_image, :to => "all" } params[:profile_image_hash] = { :user_file => raw_image, :to => "all" }

View file

@ -22,14 +22,17 @@ 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
response.should be_success
end end
it "doesn't error out on an invalid id" do it "redirects on an invalid id" do
get :show, :id => 'delicious' get :show, :id => 'delicious'
response.should redirect_to people_path
end end
it "doesn't error out on a nonexistent person" do it "redirects on a nonexistent person" do
get :show, :id => user.id get :show, :id => user.id
response.should redirect_to people_path
end end
describe '#update' do describe '#update' do
@ -50,5 +53,11 @@ describe PeopleController do
user.person.profile.image_url.should == image_url user.person.profile.image_url.should == image_url
end end
end end
it 'does not allow mass assignment' do
new_user = make_user
put :update, :id => user.person.id, :person => {
:owner_id => new_user.id}
user.person.reload.owner_id.should_not == new_user.id
end
end end
end end