diff --git a/Changelog.md b/Changelog.md index 4eab24864..96ee4f128 100644 --- a/Changelog.md +++ b/Changelog.md @@ -113,6 +113,7 @@ diaspora.yml file**. The existing settings from 0.4.x and before will not work a * Improve consistency of poll answer ordering [#5471](https://github.com/diaspora/diaspora/pull/5471) * Fix broken aspect selectbox on asynchronous search results [#5488](https://github.com/diaspora/diaspora/pull/5488) * Replace %{third_party_tools} by the appropriate hyperlink in tags FAQ [#5509](https://github.com/diaspora/diaspora/pull/5509) +* Repair downloading the profile image from Facebook [#5493](https://github.com/diaspora/diaspora/pull/5493) ## Features * Don't pull jQuery from a CDN by default [#5105](https://github.com/diaspora/diaspora/pull/5105) diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 8baa56cfd..abfd50782 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -23,9 +23,9 @@ class ServicesController < ApplicationController service = Service.initialize_from_omniauth( omniauth_hash ) if current_user.services << service - current_user.update_profile_with_omniauth( service.info ) - - fetch_photo(service) if no_profile_image? + no_profile_image_before_update = no_profile_image? + current_user.update_profile_with_omniauth(service.info) + fetch_photo(service) if no_profile_image_before_update flash[:notice] = I18n.t 'services.create.success' else diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index 1dd5396c6..d7bd50e92 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -8,7 +8,7 @@ describe ServicesController, :type => :controller do let(:omniauth_auth) do { 'provider' => 'facebook', 'uid' => '2', - 'info' => { 'nickname' => 'grimmin' }, + 'info' => { 'nickname' => 'grimmin', 'image' => 'http://graph.facebook.com/2/picture' }, 'credentials' => { 'token' => 'tokin', 'secret' =>"not_so_much" }} end let(:user) { alice } @@ -46,6 +46,15 @@ describe ServicesController, :type => :controller do expect(user.reload.services.first.class.name).to eq("Services::Facebook") end + context "when the user hasn't got a profile photo on Diaspora" do + before { user.person.profile.update_attribute :image_url, nil } + + it "imports the profile photo from the service" do + expect(Workers::FetchProfilePhoto).to receive(:perform_async) + post :create, :provider => 'facebook' + end + end + context 'when service exists with the same uid' do before { Services::Twitter.create!(uid: omniauth_auth['uid'], user_id: user.id) }