diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 25fb5d0e4..e8af2f337 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -73,12 +73,12 @@ class PeopleController < ApplicationController private def prep_image_url(params) if params[:profile] && params[:profile][:image_url] - url = APP_CONFIG[:pod_url].dup - url.chop! if APP_CONFIG[:pod_url][-1,1] == '/' if params[:profile][:image_url].empty? params[:profile].delete(:image_url) else - if /^http:\/\// =~ params[:profile][:image_url] + url = APP_CONFIG[:pod_url].dup + url.chop! if APP_CONFIG[:pod_url][-1,1] == '/' + if params[:profile][:image_url].match(/^https?:\/\//) params[:profile][:image_url] = params[:profile][:image_url] else params[:profile][:image_url] = url + params[:profile][:image_url] diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 64e10b94e..7ed3ffbff 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -46,8 +46,23 @@ describe PeopleController do image_url = user.person.profile.image_url put("update", :id => user.person.id, "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