FIX: Don't raise error when trying to download avatar from URL.

This commit is contained in:
Guo Xiang Tan 2017-10-02 12:58:27 +08:00
parent 974836962d
commit 0f2c5f5fc9
2 changed files with 25 additions and 1 deletions

View File

@ -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

View File

@ -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