mailgun-ruby
mailgun-ruby copied to clipboard
BatchMessage modifies stored test deliveries
Description
When using Mailgun::Client in test mode with batch messages, the reset_message method in BatchMessage modifies the original hash stored in Mailgun::Client.deliveries. This causes the stored test deliveries to lose their :to, :cc, :bcc and recipient-variables data after the batch is processed.
Steps to Reproduce
- Enable test mode on Mailgun client
- Create a batch message with recipients (to, cc, bcc)
- Send the message
- Check the stored delivery in
Mailgun::Client.deliveries - The stored hash is modified after
reset_messageis called
Code Example
client = Mailgun::Client.new('key')
client.enable_test_mode!
batch = Mailgun::BatchMessage.new(client, 'domain.com')
batch.add_recipient(:to, '[email protected]')
batch.add_recipient(:cc, '[email protected]')
batch.add_recipient(:bcc, '[email protected]')
batch.finalize
# At this point, checking `Mailgun::Client.deliveries` the to/cc/bcc/recipient-variables fields are gone