PeopleController#update handles getting an empty string for :image

This commit is contained in:
Sarah Mei 2010-10-31 17:49:47 -07:00
parent 0817409e9a
commit ce213513eb
2 changed files with 7 additions and 21 deletions

View file

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

View file

@ -39,30 +39,16 @@ describe PeopleController do
user.person.profile.save
params = { "profile" =>
{"image_url" => "",
{ "image" => "",
"last_name" => user.person.profile.last_name,
"first_name" => user.person.profile.first_name }}
image_url = user.person.profile.image_url
put("update", :id => user.person.id, "person" => params)
put :update, "id" => user.person.id.to_s, "person" => params
user.person.reload
user.person.profile.image_url.should == image_url
end
it "doesn't prepend (https?://) if already present in image_url" do
params = {:profile=>
{:image_url => "https://google.com/image.png",
:last_name => user.person.profile.last_name,
:first_name => user.person.profile.first_name}}
put("update", :id => user.person.id, "person" => params)
user.person.reload
user.person.profile.image_url.should == params[:profile][:image_url]
end
end
end
end