checking on the attribute not the method
This commit is contained in:
parent
d51516fff3
commit
8b3c4f4cf2
2 changed files with 9 additions and 4 deletions
|
|
@ -27,7 +27,7 @@ class ServicesController < ApplicationController
|
|||
current_user.services << service
|
||||
|
||||
if service.persisted?
|
||||
fetch_photo = current_user.person.profile.image_url.blank?
|
||||
fetch_photo = current_user.person.profile[:image_url].blank?
|
||||
|
||||
current_user.update_profile(current_user.person.profile.from_omniauth_hash(user))
|
||||
Resque.enqueue(Jobs::FetchProfilePhoto, current_user.id, service.id, user["image"]) if fetch_photo
|
||||
|
|
@ -40,6 +40,7 @@ class ServicesController < ApplicationController
|
|||
flash[:error] << I18n.t('services.create.already_authorized',
|
||||
:diaspora_id => existing_service.user.person.profile.diaspora_handle,
|
||||
:service_name => provider.camelize )
|
||||
:A
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -87,8 +87,10 @@ describe ServicesController do
|
|||
request.env['omniauth.auth'] = omniauth_auth
|
||||
end
|
||||
|
||||
it 'does not queue a job if the profile photo is not updated' do
|
||||
@user.person.profile.stub(:image_url).and_return("/some/image_url.jpg")
|
||||
it 'does not queue a job if the profile photo is set' do
|
||||
profile = @user.person.profile
|
||||
profile[:image_url] = "/non/default/image.jpg"
|
||||
profile.save
|
||||
|
||||
Resque.should_not_receive(:enqueue)
|
||||
|
||||
|
|
@ -96,7 +98,9 @@ describe ServicesController do
|
|||
end
|
||||
|
||||
it 'queues a job to save user photo if the photo does not exist' do
|
||||
@user.person.profile.stub(:image_url).and_return(nil)
|
||||
profile = @user.person.profile
|
||||
profile[:image_url] = nil
|
||||
profile.save
|
||||
|
||||
Resque.should_receive(:enqueue).with(Jobs::FetchProfilePhoto, @user.id, anything(), "https://service.com/fallback_lowres.jpg")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue