2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2014-12-16 05:10:27 +08:00
|
|
|
|
|
|
|
describe Jobs::UpdateGravatar do
|
|
|
|
|
|
|
|
it "picks gravatar if system avatar is picked and gravatar was just downloaded" do
|
|
|
|
user = User.create!(username: "bob", name: "bob", email: "a@a.com")
|
2014-12-31 22:55:03 +08:00
|
|
|
expect(user.uploaded_avatar_id).to eq(nil)
|
|
|
|
expect(user.user_avatar.gravatar_upload_id).to eq(nil)
|
2014-12-16 05:10:27 +08:00
|
|
|
|
|
|
|
png = Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==")
|
2017-09-28 14:35:27 +08:00
|
|
|
url = "https://www.gravatar.com/avatar/d10ca8d11301c2f4993ac2279ce4b930.png?s=360&d=404"
|
2017-05-26 15:19:09 +08:00
|
|
|
stub_request(:head, url).to_return(status: 200)
|
|
|
|
stub_request(:get, url).to_return(body: png)
|
2014-12-16 05:10:27 +08:00
|
|
|
|
|
|
|
SiteSetting.automatically_download_gravatars = true
|
|
|
|
|
|
|
|
user.refresh_avatar
|
|
|
|
user.reload
|
|
|
|
|
2014-12-31 22:55:03 +08:00
|
|
|
expect(user.uploaded_avatar_id).to eq(user.user_avatar.gravatar_upload_id)
|
2014-12-16 05:10:27 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|