How to test attachments in ActionMailbox?
I'm trying to test attachments using receive_inbound_email_from_mail, but when inspecting mail.attachments I get an empty array. Is there another way around this?
receive_inbound_email_from_mail(
from: 'some_email@example.com',
to: 'some_email@example.com',
subject: 'Logo',
body: 'Hi, See the logo attached.',
attachments: [ fixture_file_upload("files/logo.png") ]
)
It turns out this is the way to go
mail = Mail.new(
from: 'some_email@example.com',
to: 'some_email@example.com',
subject: 'Logo',
body: 'Hi, See the logo attached.',
)
mail.add_file filename: 'sample.txt', content: StringIO.new('Sample Logo')
create_inbound_email_from_source(mail.to_s, status: :processing).tap(&:route)
Thanks for posting the solution! I'm going to be covering this soon so I might use your example here. 🙌