6a6a37a67b
fixes: #3853 - Introduced DISABLE_GRAVATAR Global Config, which will stop chatwoot from making API requests to gravatar - Cleaned up avatar-related logic and centralized it into the avatarable concern - Added specs for the missing cases - Added migration for existing installations to move the avatar to attachment, rather than making the API that results in 404.
20 lines
861 B
Ruby
20 lines
861 B
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Avatar::AvatarFromUrlJob, type: :job do
|
|
let(:avatarable) { create(:contact) }
|
|
let(:avatar_url) { 'https://example.com/avatar.png' }
|
|
|
|
it 'enqueues the job' do
|
|
expect { described_class.perform_later(avatarable, avatar_url) }.to have_enqueued_job(described_class)
|
|
.on_queue('default')
|
|
end
|
|
|
|
it 'will attach avatar from url' do
|
|
expect(avatarable.avatar).not_to be_attached
|
|
expect(Down).to receive(:download).with(avatar_url,
|
|
max_size: 15 * 1024 * 1024).and_return(fixture_file_upload(Rails.root.join('spec/assets/avatar.png'),
|
|
'image/png'))
|
|
described_class.perform_now(avatarable, avatar_url)
|
|
expect(avatarable.avatar).to be_attached
|
|
end
|
|
end
|