mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 09:33:44 +08:00
4ea21fa2d0
This change both speeds up specs (less strings to allocate) and helps catch cases where methods in Discourse are mutating inputs. Overall we will be migrating everything to use #frozen_string_literal: true it will take a while, but this is the first and safest move in this direction
25 lines
830 B
Ruby
25 lines
830 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
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")
|
|
expect(user.uploaded_avatar_id).to eq(nil)
|
|
expect(user.user_avatar.gravatar_upload_id).to eq(nil)
|
|
|
|
png = Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==")
|
|
url = "https://www.gravatar.com/avatar/d10ca8d11301c2f4993ac2279ce4b930.png?s=360&d=404"
|
|
stub_request(:get, url).to_return(body: png)
|
|
|
|
SiteSetting.automatically_download_gravatars = true
|
|
|
|
user.refresh_avatar
|
|
user.reload
|
|
|
|
expect(user.uploaded_avatar_id).to eq(user.user_avatar.gravatar_upload_id)
|
|
end
|
|
|
|
end
|