Skip to content

Commit

Permalink
fix issue #97
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorel committed May 26, 2017
1 parent e3a357a commit 442d5f4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mailjet/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def save(options)
end

if options[:perform_api_call]
if self.resource_path == 'send/'
if self.resource_path.include? 'send'
self.attributes = ActiveSupport::JSON.decode(response)
return true
end
Expand Down
1 change: 1 addition & 0 deletions spec/mailjet-spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Mailjet.configure do |config|
config.api_key = API_KEY
config.secret_key = API_SECRET
config.api_version = "v3"
end
end

Expand Down
52 changes: 52 additions & 0 deletions spec/mailjet/mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,57 @@ module Mailjet
}]
)
end

it 'should return data in attribute "Sent" using API v3' 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 = 'albert@bar.com'
recipient = { 'Email': 'test@test.com' }

message = Mailjet::Send.create(
from_email: from_email,
from_name: 'Mailjet Pilot',
subject: 'Your email flight plan!',
text_part: 'Dear passenger, welcome to Mailjet! May the delivery force be with you!',
html_part: '<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!',
recipients: [recipient]
)

expect(message.attributes['Sent'].first).to include(recipient)
end

it 'should return data in attribute "Sent" using API v3.1' do

Mailjet.configure do |config|
config.api_key = ENV['MJ_APIKEY_PUBLIC']
config.secret_key = ENV['MJ_APIKEY_PRIVATE']
config.api_version = "v3.1"
end

message = Mailjet::Send.create(
messages: [{
'From' => {
'Email' => 'albert@bar.com',
'Name' => 'Albert'
},
'To' => [
{
'Email' => 'test@test.com',
'Name' => 'test'
}
],
'Subject' => 'Your email flight plan!',
'TextPart' => 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',
'HTMLPart' => '<h3>Dear passenger 1, welcome to Mailjet!</h3><br />May the delivery force be with you!'
}]
)

expect(message.attributes['Sent'].first).to include(recipient)
end
end
end

0 comments on commit 442d5f4

Please sign in to comment.