PeopleController#update handles getting an empty string for :image
This commit is contained in:
parent
0817409e9a
commit
ce213513eb
2 changed files with 7 additions and 21 deletions
|
|
@ -56,7 +56,7 @@ class PeopleController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# upload and set new profile photo
|
# upload and set new profile photo
|
||||||
if params[:person][:profile][:image]
|
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" }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,32 +37,18 @@ describe PeopleController do
|
||||||
it "doesn't overwrite the profile photo when an empty string is passed in" 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.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg"
|
||||||
user.person.profile.save
|
user.person.profile.save
|
||||||
|
|
||||||
params = {"profile"=>
|
params = { "profile" =>
|
||||||
{"image_url" => "",
|
{ "image" => "",
|
||||||
"last_name" => user.person.profile.last_name,
|
"last_name" => user.person.profile.last_name,
|
||||||
"first_name" => user.person.profile.first_name}}
|
"first_name" => user.person.profile.first_name }}
|
||||||
|
|
||||||
image_url = user.person.profile.image_url
|
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.reload
|
||||||
user.person.profile.image_url.should == image_url
|
user.person.profile.image_url.should == image_url
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue