Skip to content

Commit

Permalink
Merge branch 'fix-issue-97' into fix-issue-96
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorel committed May 26, 2017
2 parents 2fc4bcc + 5c75df1 commit f0aa4c7
Show file tree
Hide file tree
Showing 3 changed files with 55 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 @@ -254,7 +254,7 @@ def save(options)

if options[:perform_api_call] && !persisted?
# get attributes only for entity creation
self.attributes = if self.resource_path == 'send/'
self.attributes = if self.resource_path == 'send'
ActiveSupport::JSON.decode(response)
else
parse_api_json(response).first
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
53 changes: 53 additions & 0 deletions spec/mailjet/mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,58 @@ module Mailjet
}]
)
end

it 'should return data in attribute "Sent" using Send 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

recipient = { 'Email': ENV['TEST_EMAIL'] }

message = Mailjet::Send.create(
from_email: ENV['TEST_EMAIL'],
from_name: 'Mailjet Ruby Wrapper CI',
subject: 'Mailjet Ruby Wrapper CI Send API v3.0 spec',
text_part: 'Mailjet Ruby Wrapper CI content',
html_part: '<h3>Mailjet Ruby Wrapper CI content</h3>',
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

recipient = {
'Email' => ENV['TEST_EMAIL'],
'Name' => 'test'
}

message = Mailjet::Send.create(
messages: [{
'From' => {
'Email' => ENV['TEST_EMAIL'],
'Name' => 'Mailjet Ruby Wrapper CI'
},
'To' => [
recipient
],
'Subject' => 'Mailjet Ruby Wrapper CI Send API v3.1 spec',
'TextPart' => 'Mailjet Ruby Wrapper CI content',
'HTMLPart' => '<h3>Mailjet Ruby Wrapper CI content</h3>'
}]
)

expect(message.attributes['Messages'].first['To'].first['Email']).to eq(ENV['TEST_EMAIL'])
end
end
end

0 comments on commit f0aa4c7

Please sign in to comment.