spec/lib/sendgrid_actionmailer_spec.rb in sendgrid-actionmailer-0.1.1 vs spec/lib/sendgrid_actionmailer_spec.rb in sendgrid-actionmailer-0.2.0
- old
+ new
@@ -63,10 +63,37 @@
mailer.deliver!(mail)
expect(client.sent_mail.bcc).to eq(%w[nachos@cat.limo])
end
end
+ context 'there is a reply to' do
+ before { mail.reply_to = 'nachos@cat.limo' }
+
+ it 'sets reply_to' do
+ mailer.deliver!(mail)
+ expect(client.sent_mail.reply_to).to eq('nachos@cat.limo')
+ end
+ end
+
+ context 'there is a reply to with a friendly name' do
+ before { mail.reply_to = 'Taco Cat <nachos@cat.limo>' }
+
+ it 'sets reply_to' do
+ mailer.deliver!(mail)
+ expect(client.sent_mail.reply_to).to eq('nachos@cat.limo')
+ end
+ end
+
+ context 'there is a date' do
+ before { mail.date = Time.utc(2016) }
+
+ it 'sets date' do
+ mailer.deliver!(mail)
+ expect(client.sent_mail.date).to eq("Fri, 01 Jan 2016 00:00:00 +0000")
+ end
+ end
+
it 'sets from' do
mailer.deliver!(mail)
expect(client.sent_mail.from).to eq('taco@cat.limo')
end
@@ -358,9 +385,21 @@
end
it 'gets attached' do
mailer.deliver!(mail)
expect(client.sent_mail.smtpapi.ip_pool).to eq("pool_name")
+ end
+ end
+
+ context 'multiple X-SMTPAPI headers are present' do
+ before do
+ mail['X-SMTPAPI'] = { category: 'food_canine' }.to_json
+ mail['X-SMTPAPI'] = { category: 'food_feline' }.to_json
+ end
+
+ it 'uses the last header' do
+ mailer.deliver!(mail)
+ expect(client.sent_mail.smtpapi.category).to eq('food_canine')
end
end
end
end
end