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
|
||||
|
||||
# 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" }
|
||||
|
||||
|
|
|
|||
|
|
@ -38,31 +38,17 @@ describe PeopleController 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
|
||||
|
|
|
|||
Loading…
Reference in a new issue