diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 89ed4bc9a..ea56ed81b 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -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" } diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index c83bf221b..16b0968a4 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -37,32 +37,18 @@ describe PeopleController do it "doesn't overwrite the profile photo when an empty string is passed in" do user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg" user.person.profile.save - - params = {"profile"=> - {"image_url" => "", - "last_name" => user.person.profile.last_name, - "first_name" => user.person.profile.first_name}} + + params = { "profile" => + { "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