fix: handle active storage preview error for password protected pdfs (#11888)

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Vishnu Narayanan
2025-08-11 12:41:37 +05:30
committed by GitHub
parent f3bc2476fc
commit 6cab741392
4 changed files with 28 additions and 6 deletions

View File

@@ -68,6 +68,22 @@ RSpec.describe Attachment do
end
end
describe 'thumb_url' do
it 'returns empty string for non-image attachments' do
attachment = message.attachments.new(account_id: message.account_id, file_type: :file)
attachment.file.attach(io: StringIO.new('fake pdf'), filename: 'test.pdf', content_type: 'application/pdf')
expect(attachment.thumb_url).to eq('')
end
it 'generates thumb_url for image attachments' do
attachment = message.attachments.create!(account_id: message.account_id, file_type: :image)
attachment.file.attach(io: StringIO.new('fake image'), filename: 'test.jpg', content_type: 'image/jpeg')
expect(attachment.thumb_url).to be_present
end
end
describe 'meta data handling' do
let(:message) { create(:message) }