Skip to content

Commit

Permalink
add test for email with raw body content and attachment against API v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorel authored and arnaudbreton committed Jun 30, 2017
1 parent 5676360 commit 4979f47
Showing 1 changed file with 59 additions and 3 deletions.
62 changes: 59 additions & 3 deletions spec/mailjet/mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,62 @@ module Mailjet
)
end

it "should send email with HTML body and an attachment with API v3.0" do
Mailjet.configure do |config|
config.api_key = ENV['MJ_APIKEY_PUBLIC']
config.secret_key = ENV['MJ_APIKEY_PRIVATE']
config.api_version = "v3"
end

from_email = ENV['TEST_EMAIL']
recipient = ENV['TEST_EMAIL']

message = Mail.new do
from from_email
to recipient
subject "This is a nice welcome email (API v3.0)"
body "Test"
content_type "text/html"
end

message.attachments['filename.txt'] = {
mime_type: 'text/plain',
content: "hello world"
}

sent = APIMailer.new.deliver!(message)

expect(sent.attributes["Sent"].first["Email"]).to eq(ENV['TEST_EMAIL'])
end

it "should send email with Text body and an attachment with API v3.0" do
Mailjet.configure do |config|
config.api_key = ENV['MJ_APIKEY_PUBLIC']
config.secret_key = ENV['MJ_APIKEY_PRIVATE']
config.api_version = "v3"
end

from_email = ENV['TEST_EMAIL']
recipient = ENV['TEST_EMAIL']

message = Mail.new do
from from_email
to recipient
subject "This is a nice welcome email (API v3.0)"
body "Test"
content_type "text/plain"
end

message.attachments['filename.txt'] = {
mime_type: 'text/plain',
content: "hello world"
}

sent = APIMailer.new.deliver!(message)

expect(sent.attributes["Sent"].first["Email"]).to eq(ENV['TEST_EMAIL'])
end

it "should send email with HTML body and an attachment with API v3.1" do
Mailjet.configure do |config|
config.api_key = ENV['MJ_APIKEY_PUBLIC']
Expand All @@ -268,7 +324,7 @@ module Mailjet
message = Mail.new do
from from_email
to recipient
subject "This is a nice welcome email"
subject "This is a nice welcome email (API v3.1)"
body "Test"
content_type "text/html"
end
Expand Down Expand Up @@ -296,7 +352,7 @@ module Mailjet
message = Mail.new do
from from_email
to recipient
subject "This is a nice welcome email"
subject "This is a nice welcome email (API v3.1)"
body "Test"
content_type "text/plain"
end
Expand Down Expand Up @@ -324,7 +380,7 @@ module Mailjet
message = Mail.new do
from from_email
to recipient
subject "This is a nice welcome email"
subject "This is a nice welcome email (API v3.1)"
end

message.attachments['filename.txt'] = {
Expand Down

0 comments on commit 4979f47

Please sign in to comment.