From 7acc138a210972f478b0f99b398c7ffa9c985a38 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 29 Oct 2010 14:56:41 -0700 Subject: [PATCH] resolved issue regarding profile images referenced at https:// locations. --- app/controllers/people_controller.rb | 6 +++--- spec/controllers/people_controller_spec.rb | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) 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