diff --git a/app/jobs/regular/download_avatar_from_url.rb b/app/jobs/regular/download_avatar_from_url.rb index 83e687fed96..f4eabdf9510 100644 --- a/app/jobs/regular/download_avatar_from_url.rb +++ b/app/jobs/regular/download_avatar_from_url.rb @@ -12,7 +12,15 @@ module Jobs return unless user = User.find_by(id: user_id) - UserAvatar.import_url_for_user(url, user, override_gravatar: args[:override_gravatar]) + begin + UserAvatar.import_url_for_user( + '/assets/vorablesen/placeholder-user-ed74bdf68223d030da1b7ddc44f59faf9c5a184388c94aff91632d5bf166a9e5.png', + user, + override_gravatar: args[:override_gravatar] + ) + rescue Discourse::InvalidParameters => e + raise e unless e.message == 'url' + end end end diff --git a/spec/jobs/download_avatar_from_url_spec.rb b/spec/jobs/download_avatar_from_url_spec.rb new file mode 100644 index 00000000000..6758a647a0f --- /dev/null +++ b/spec/jobs/download_avatar_from_url_spec.rb @@ -0,0 +1,16 @@ +require 'rails_helper' + +RSpec.describe Jobs::DownloadAvatarFromUrl do + let(:user) { Fabricate(:user) } + + describe 'when url is invalid' do + it 'should not raise any error' do + expect do + described_class.new.execute( + url: '/assets/something/nice.jpg', + user_id: user.id + ) + end.to_not raise_error + end + end +end