Chatwoot/spec/models/attachment_spec.rb
Sojan Jose 2c73df4292
Chore: Provide fixed attachment URLs for Channels (#4507)
Prior to this change, The attachment URL sent from Chatwoot to 3rd party integrations like Whatsapp and Facebook
involved a 301 redirect before the original content is served. This causes intermittent breakages for the sent attachments.

fixes: #3632
ref: https://blog.saeloun.com/2021/09/14/rails-7-adds-expiring-urls-to-active-storage.html
2022-04-20 22:42:13 +05:30

12 lines
470 B
Ruby

require 'rails_helper'
RSpec.describe Attachment, type: :model do
describe 'download_url' do
it 'returns valid download url' do
message = create(:message)
attachment = message.attachments.new(account_id: message.account_id, file_type: :image)
attachment.file.attach(io: File.open(Rails.root.join('spec/assets/avatar.png')), filename: 'avatar.png', content_type: 'image/png')
expect(attachment.download_url).not_to eq nil
end
end
end