mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 16:52:45 +08:00
FIX: stop logging every 404 error when searching for gravatars
This commit is contained in:
parent
adab7a3a48
commit
b74dd7d379
|
@ -51,6 +51,10 @@ class UserAvatar < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
end
|
||||
rescue OpenURI::HTTPError => e
|
||||
if e.io&.status[0].to_i != 404
|
||||
raise e
|
||||
end
|
||||
ensure
|
||||
tempfile&.close!
|
||||
end
|
||||
|
|
|
@ -83,6 +83,23 @@ describe UserAvatar do
|
|||
|
||||
end
|
||||
|
||||
describe "404 should be silent, nothing to do really" do
|
||||
|
||||
it "does nothing when avatar is 404" do
|
||||
|
||||
freeze_time Time.now
|
||||
|
||||
stub_request(:get, "https://www.gravatar.com/avatar/#{avatar.user.email_hash}.png?d=404&s=360").
|
||||
to_return(status: 404, body: "", headers: {})
|
||||
|
||||
expect do
|
||||
avatar.update_gravatar!
|
||||
end.to_not change { Upload.count }
|
||||
|
||||
expect(avatar.last_gravatar_download_attempt).to eq(Time.now)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context '.import_url_for_user' do
|
||||
|
|
Loading…
Reference in New Issue
Block a user