postmark 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -7
- data/CHANGELOG.rdoc +5 -0
- data/README.md +49 -3
- data/VERSION +1 -1
- data/lib/postmark/api_client.rb +26 -0
- data/lib/postmark/message_extensions/mail.rb +6 -3
- data/lib/postmark/version.rb +1 -1
- data/spec/integration/api_client_hashes_spec.rb +3 -1
- data/spec/integration/api_client_messages_spec.rb +3 -1
- data/spec/integration/api_client_resources_spec.rb +66 -0
- data/spec/integration/mail_delivery_method_spec.rb +4 -3
- data/spec/unit/postmark/api_client_spec.rb +84 -0
- data/spec/unit/postmark/message_extensions/mail_spec.rb +27 -9
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43ae963225ea68dd15633af53a029cfd01a786b5
|
4
|
+
data.tar.gz: 99b445605debe412833a560b4baedcfec0a37ea1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90e0fcef06267ce2ad965391348e3786a1999f4d0e889f5a5ab284ce13cd0816e31bdd6818886afdf2e0abc3d38cb716a65529cc592e1d0f80d82f5ce40b52b6
|
7
|
+
data.tar.gz: f553e8b2b973f75b46812a6e7dcf3fb0b86fe2cf07c1128067de8a129d0b1f1108080ece56a298a3c913b58399425d3a5ae55a2334704b8e301df661f669535f
|
data/.travis.yml
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
secure: MV+nKlzuLJ5CEoEfCmzwRMlnBOudgB1fTxBYI6aDV9vUkwYRzkcpCPS+Ik6jdCzNEFK+L2dTfv/IfDOvxnK3cZpMi1sp0po04m3Pg+ZhzYoANS1KY6V4sFIFaPtx+x2DVStxjFch4WQV8ktzdoUI0POlCdJrD6GYXLh1aTgbAGU=
|
1
4
|
language: ruby
|
2
5
|
before_install:
|
3
|
-
|
4
|
-
|
6
|
+
- gem update --system 2.1.11
|
7
|
+
- gem --version
|
5
8
|
rvm:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
- 1.8.7
|
10
|
+
- 1.9.2
|
11
|
+
- 1.9.3
|
12
|
+
- 2.0.0
|
13
|
+
- jruby-19mode
|
11
14
|
script: bundle exec rake spec
|
data/CHANGELOG.rdoc
CHANGED
data/README.md
CHANGED
@@ -83,17 +83,23 @@ client.deliver(from: 'sheldon@bigbangtheory.com',
|
|
83
83
|
|
84
84
|
You can add
|
85
85
|
[attachments](http://developer.postmarkapp.com/developer-build.html#attachments)
|
86
|
-
to your messages. Keep in mind message size limit (contents and attachment) is currently 10 MB.
|
86
|
+
to your messages. Keep in mind message size limit (contents and attachment) is currently 10 MB. For inline attachments it is possible to specify content IDs via the `content_id` attribute.
|
87
87
|
|
88
88
|
``` ruby
|
89
89
|
client.deliver(from: 'leonard@bigbangtheory.com',
|
90
90
|
to: 'Dr. Sheldon Cooper <sheldon@bigbangtheory.com>',
|
91
91
|
subject: 'Have you seen these pictures of yours?',
|
92
92
|
text_body: 'You look like a real geek!',
|
93
|
+
html_body: '<p>You look like a real geek!</p><center><img src="cid:42"></center>',
|
93
94
|
attachments: [File.open('1.jpeg'),
|
94
95
|
{name: 'sheldon.jpeg',
|
95
96
|
content: [File.read('2.jpeg')].pack('m'),
|
96
|
-
content_type: 'image/jpeg'}
|
97
|
+
content_type: 'image/jpeg'},
|
98
|
+
{name: 'logo.png',
|
99
|
+
content: [File.read('1.png')].pack('m'),
|
100
|
+
content_type: 'image/png',
|
101
|
+
content_id: 'cid:42'}])
|
102
|
+
|
97
103
|
# => {:to=>"Dr. Sheldon Cooper <sheldon@bigbangtheory.com>", :submitted_at=>"2013-05-09T02:56:12.2828813-04:00", :message_id=>"8ec0d283-8b93-xxxx-9d65-241d1777cf0f", :error_code=>0, :message=>"OK"}
|
98
104
|
```
|
99
105
|
|
@@ -221,6 +227,34 @@ ruby_hash = Postmark::Inbound.to_ruby_hash(postmark_hash)
|
|
221
227
|
# => {:from=>"myUser@theirDomain.com", :from_full=>{:email=>"myUser@theirDomain.com", :name=>"John Doe"}, :to=>"451d9b70cf9364d23ff6f9d51d870251569e+ahoy@inbound.postmarkapp.com", :to_full=>[{:email=>"451d9b70cf9364d23ff6f9d51d870251569e+ahoy@inbound.postmarkapp.com", :name=>""}], :cc=>"\"Full name\" <sample.cc@emailDomain.com>, \"Another Cc\" <another.cc@emailDomain.com>", :cc_full=>[{:email=>"sample.cc@emailDomain.com", :name=>"Full name"}, {:email=>"another.cc@emailDomain.com", :name=>"Another Cc"}], :reply_to=>"myUsersReplyAddress@theirDomain.com", :subject=>"This is an inbound message", :message_id=>"22c74902-a0c1-4511-804f2-341342852c90", :date=>"Thu, 5 Apr 2012 16:59:01 +0200", :mailbox_hash=>"ahoy", :text_body=>"[ASCII]", :html_body=>"[HTML(encoded)]", :tag=>"", :headers=>[{:name=>"X-Spam-Checker-Version", :value=>"SpamAssassin 3.3.1 (2010-03-16) onrs-ord-pm-inbound1.wildbit.com"}, {:name=>"X-Spam-Status", :value=>"No"}, {:name=>"X-Spam-Score", :value=>"-0.1"}, {:name=>"X-Spam-Tests", :value=>"DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_PASS"}, {:name=>"Received-SPF", :value=>"Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.160.180; helo=mail-gy0-f180.google.com; envelope-from=myUser@theirDomain.com; receiver=451d9b70cf9364d23ff6f9d51d870251569e+ahoy@inbound.postmarkapp.com"}, {:name=>"DKIM-Signature", :value=>"v=1; a=rsa-sha256; c=relaxed/relaxed; d=wildbit.com; s=google; h=mime-version:reply-to:date:message-id:subject:from:to:cc :content-type; bh=cYr/+oQiklaYbBJOQU3CdAnyhCTuvemrU36WT7cPNt0=; b=QsegXXbTbC4CMirl7A3VjDHyXbEsbCUTPL5vEHa7hNkkUTxXOK+dQA0JwgBHq5C+1u iuAJMz+SNBoTqEDqte2ckDvG2SeFR+Edip10p80TFGLp5RucaYvkwJTyuwsA7xd78NKT Q9ou6L1hgy/MbKChnp2kxHOtYNOrrszY3JfQM="}, {:name=>"MIME-Version", :value=>"1.0"}, {:name=>"Message-ID", :value=>"<CAGXpo2WKfxHWZ5UFYCR3H_J9SNMG+5AXUovfEFL6DjWBJSyZaA@mail.gmail.com>"}], :attachments=>[{:name=>"myimage.png", :content=>"[BASE64-ENCODED CONTENT]", :content_type=>"image/png", :content_length=>4096}, {:name=>"mypaper.doc", :content=>"[BASE64-ENCODED CONTENT]", :content_type=>"application/msword", :content_length=>16384}]}
|
222
228
|
```
|
223
229
|
|
230
|
+
## Working with messages
|
231
|
+
|
232
|
+
Use `#get_messages` to retrieve messages (`:count` and `:offset` parameters
|
233
|
+
control pagination). Access inbound messages by passing `:inbound => true` as
|
234
|
+
a parameter.
|
235
|
+
|
236
|
+
``` ruby
|
237
|
+
client.get_messages(count: 1, offset: 0)
|
238
|
+
# => [{:message_id=>"41f03342-xxxx-xxxx-xxxx-558caedb5e82", :to=>[{"Email"=>"info@wildbit.com", "Name"=>nil}], :cc=>[], :bcc=>[], :recipients=>["info@wildbit.com"], :received_at=>"2014-01-15T16:41:22.4533537-05:00", :from=>"\"Postmark\" <support@postmarkapp.com>", :subject=>"Good Luck With The Gem", :attachments=>[]}]
|
239
|
+
```
|
240
|
+
|
241
|
+
Use `#get_message` to get details for a specific message using ID:
|
242
|
+
|
243
|
+
``` ruby
|
244
|
+
client.get_message('41f03342-xxxx-xxxx-xxxx-558caedb5e82')
|
245
|
+
# => {:text_body=>"...", :body=>"...", :message_id=>"41f03342-xxxx-xxxx-xxxx-558caedb5e82", :to=>[{"Email"=>"info@wildbit.com", "Name"=>nil}], :cc=>[], :bcc=>[], :recipients=>["info@wildbit.com"], :received_at=>"2014-01-15T16:41:22.4533537-05:00", :from=>"\"Postmark\" <support@postmarkapp.com>", :subject=>"Good Luck With The Gem", :attachments=>[]}
|
246
|
+
```
|
247
|
+
|
248
|
+
Use `#dump_message` to get the full message body:
|
249
|
+
|
250
|
+
``` ruby
|
251
|
+
client.dump_message('41f03342-xxxx-xxxx-xxxx-558caedb5e82')
|
252
|
+
# => {:body=>"..."}
|
253
|
+
```
|
254
|
+
|
255
|
+
You can get more details about the underlying endpoints and parameters they
|
256
|
+
accept in [Postmark Developer Docs](http://developer.postmarkapp.com/developer-messages.html).
|
257
|
+
|
224
258
|
## Working with bounces
|
225
259
|
|
226
260
|
Use `#get_bounces` to retrieve a list of bounces (use `:count` and `:offset`
|
@@ -374,6 +408,18 @@ message.deliver
|
|
374
408
|
# => #<Mail::Message:70185826686240, Multipart: true, Headers: <From: leonard@bigbangtheory.com>, <To: sheldon@bigbangtheory.com>, <Message-ID: ba644cc1-b5b1-4bcb-aaf8-2f290b5aad80>, <Subject: Have you seen these pictures of yours?>, <Content-Type: multipart/mixed; boundary=--==_mimepart_5121f9f1ec653_12c53fd569035ad817726>>
|
375
409
|
```
|
376
410
|
|
411
|
+
You can also make an attachment inline:
|
412
|
+
|
413
|
+
``` ruby
|
414
|
+
message.attachments.inline['sheldon.jpeg'] = File.read('2.jpeg')
|
415
|
+
```
|
416
|
+
|
417
|
+
Then simply use `Mail::Part#url` method to reference it from your email body.
|
418
|
+
|
419
|
+
``` erb
|
420
|
+
<p><img src="<%= message.attachments['sheldon.jpeg'].url %>" alt="Dr. Sheldon Cooper"></p>
|
421
|
+
```
|
422
|
+
|
377
423
|
## Multipart message
|
378
424
|
|
379
425
|
You can send multipart messages containing both text and HTML using the Postmark gem.
|
@@ -574,4 +620,4 @@ Postmark.response_parser_class = :Json # :ActiveSupport or :Yajl are also suppor
|
|
574
620
|
|
575
621
|
## Copyright
|
576
622
|
|
577
|
-
Copyright ©
|
623
|
+
Copyright © 2014 Wildbit LLC. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/lib/postmark/api_client.rb
CHANGED
@@ -65,6 +65,21 @@ module Postmark
|
|
65
65
|
response
|
66
66
|
end
|
67
67
|
|
68
|
+
def get_messages(options = {})
|
69
|
+
path, params = extract_messages_path_and_params(options)
|
70
|
+
params[:offset] ||= 0
|
71
|
+
params[:count] ||= 50
|
72
|
+
format_response http_client.get(path, params)['Messages']
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_message(id, options = {})
|
76
|
+
get_for_message('details', id, options)
|
77
|
+
end
|
78
|
+
|
79
|
+
def dump_message(id, options = {})
|
80
|
+
get_for_message('dump', id, options)
|
81
|
+
end
|
82
|
+
|
68
83
|
def get_bounces(options = {})
|
69
84
|
format_response http_client.get("bounces", options)["Bounces"]
|
70
85
|
end
|
@@ -136,6 +151,11 @@ module Postmark
|
|
136
151
|
[e.full_response || {}, e]
|
137
152
|
end
|
138
153
|
|
154
|
+
def get_for_message(action, id, options = {})
|
155
|
+
path, params = extract_messages_path_and_params(options)
|
156
|
+
format_response http_client.get("#{path}/#{id}/#{action}", params)
|
157
|
+
end
|
158
|
+
|
139
159
|
def format_response(response, compatible = false)
|
140
160
|
return {} unless response
|
141
161
|
|
@@ -146,5 +166,11 @@ module Postmark
|
|
146
166
|
end
|
147
167
|
end
|
148
168
|
|
169
|
+
def extract_messages_path_and_params(options = {})
|
170
|
+
options = options.dup
|
171
|
+
path = options.delete(:inbound) ? 'messages/inbound' : 'messages/outbound'
|
172
|
+
[path, options]
|
173
|
+
end
|
174
|
+
|
149
175
|
end
|
150
176
|
end
|
@@ -47,9 +47,12 @@ module Mail
|
|
47
47
|
|
48
48
|
def export_native_attachments
|
49
49
|
attachments.map do |attachment|
|
50
|
-
{"Name" => attachment.filename,
|
51
|
-
|
52
|
-
|
50
|
+
basics = {"Name" => attachment.filename,
|
51
|
+
"Content" => pack_attachment_data(attachment.body.decoded),
|
52
|
+
"ContentType" => attachment.mime_type}
|
53
|
+
specials = attachment.inline? ? {'ContentID' => attachment.url} : {}
|
54
|
+
|
55
|
+
basics.update(specials)
|
53
56
|
end
|
54
57
|
end
|
55
58
|
|
data/lib/postmark/version.rb
CHANGED
@@ -2,7 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "Sending messages as Ruby hashes with Postmark::ApiClient" do
|
4
4
|
let(:postmark_message_id_format) { /\w{8}\-\w{4}-\w{4}-\w{4}-\w{12}/ }
|
5
|
-
let(:api_client) {
|
5
|
+
let(:api_client) {
|
6
|
+
Postmark::ApiClient.new('POSTMARK_API_TEST', :http_open_timeout => 15)
|
7
|
+
}
|
6
8
|
|
7
9
|
let(:message) {
|
8
10
|
{
|
@@ -2,7 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "Sending Mail::Messages with Postmark::ApiClient" do
|
4
4
|
let(:postmark_message_id_format) { /\w{8}\-\w{4}-\w{4}-\w{4}-\w{12}/ }
|
5
|
-
let(:api_client) {
|
5
|
+
let(:api_client) {
|
6
|
+
Postmark::ApiClient.new('POSTMARK_API_TEST', :http_open_timeout => 15)
|
7
|
+
}
|
6
8
|
|
7
9
|
let(:message) {
|
8
10
|
Mail.new do
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Accessing server resources using the API' do
|
4
|
+
|
5
|
+
let(:api_client) {
|
6
|
+
Postmark::ApiClient.new(ENV['POSTMARK_API_KEY'], :http_open_timeout => 15)
|
7
|
+
}
|
8
|
+
let(:recipient) { ENV['POSTMARK_CI_RECIPIENT'] }
|
9
|
+
let(:message) {
|
10
|
+
{
|
11
|
+
:from => "tema+ci@wildbit.com",
|
12
|
+
:to => recipient,
|
13
|
+
:subject => "Mail::Message object",
|
14
|
+
:text_body => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " \
|
15
|
+
"sed do eiusmod tempor incididunt ut labore et dolore " \
|
16
|
+
"magna aliqua."
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
context 'Messages API' do
|
21
|
+
|
22
|
+
def with_retries(max_retries = 20, wait_seconds = 3)
|
23
|
+
yield
|
24
|
+
rescue => e
|
25
|
+
retries = retries ? retries + 1 : 1
|
26
|
+
if retries < max_retries
|
27
|
+
sleep wait_seconds
|
28
|
+
retry
|
29
|
+
else
|
30
|
+
raise e
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'is possible to send a message and access its details via the Messages API' do
|
35
|
+
response = api_client.deliver(message)
|
36
|
+
message = with_retries {
|
37
|
+
api_client.get_message(response[:message_id])
|
38
|
+
}
|
39
|
+
expect(message[:recipients]).to include(recipient)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'is possible to send a message and dump it via the Messages API' do
|
43
|
+
response = api_client.deliver(message)
|
44
|
+
dump = with_retries {
|
45
|
+
api_client.dump_message(response[:message_id])
|
46
|
+
}
|
47
|
+
expect(dump[:body]).to include('Mail::Message object')
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'is possible to send a message and find it via the Messages API' do
|
51
|
+
response = api_client.deliver(message)
|
52
|
+
expect {
|
53
|
+
with_retries {
|
54
|
+
messages = api_client.get_messages(:recipient => recipient,
|
55
|
+
:fromemail => message[:from],
|
56
|
+
:subject => message[:subject])
|
57
|
+
unless messages.map { |m| m[:message_id] }.include?(response[:message_id])
|
58
|
+
raise 'Message not found'
|
59
|
+
end
|
60
|
+
}
|
61
|
+
}.not_to raise_error
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -10,7 +10,8 @@ describe "Sending Mail::Messages with delivery_method Mail::Postmark" do
|
|
10
10
|
subject "Mail::Message object"
|
11
11
|
body "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do "
|
12
12
|
"eiusmod tempor incididunt ut labore et dolore magna aliqua."
|
13
|
-
delivery_method Mail::Postmark, :api_key => "POSTMARK_API_TEST"
|
13
|
+
delivery_method Mail::Postmark, :api_key => "POSTMARK_API_TEST", :http_open_timeout => 15
|
14
|
+
|
14
15
|
end
|
15
16
|
}
|
16
17
|
|
@@ -24,7 +25,7 @@ describe "Sending Mail::Messages with delivery_method Mail::Postmark" do
|
|
24
25
|
Mail.new do
|
25
26
|
from "sender@postmarkapp.com"
|
26
27
|
to "recipient@postmarkapp.com"
|
27
|
-
delivery_method Mail::Postmark, :api_key => "POSTMARK_API_TEST"
|
28
|
+
delivery_method Mail::Postmark, :api_key => "POSTMARK_API_TEST", :http_open_timeout => 15
|
28
29
|
end
|
29
30
|
}
|
30
31
|
|
@@ -38,7 +39,7 @@ describe "Sending Mail::Messages with delivery_method Mail::Postmark" do
|
|
38
39
|
Mail.new do
|
39
40
|
from "sender@postmarkapp.com"
|
40
41
|
to "@postmarkapp.com"
|
41
|
-
delivery_method Mail::Postmark, :api_key => "POSTMARK_API_TEST"
|
42
|
+
delivery_method Mail::Postmark, :api_key => "POSTMARK_API_TEST", :http_open_timeout => 15
|
42
43
|
end
|
43
44
|
}
|
44
45
|
|
@@ -170,6 +170,90 @@ describe Postmark::ApiClient do
|
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
|
+
describe '#get_messages' do
|
174
|
+
let(:http_client) { subject.http_client }
|
175
|
+
let(:response) { {"TotalCount" => 1, "Messages" => [{}]} }
|
176
|
+
|
177
|
+
context 'given outbound' do
|
178
|
+
|
179
|
+
it 'requests data at /messages/outbound' do
|
180
|
+
http_client.should_receive(:get).
|
181
|
+
with('messages/outbound', :offset => 50, :count => 50).
|
182
|
+
and_return(response)
|
183
|
+
subject.get_messages(:offset => 50, :count => 50)
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
context 'given inbound' do
|
189
|
+
|
190
|
+
it 'requests data at /messages/inbound' do
|
191
|
+
http_client.should_receive(:get).
|
192
|
+
with('messages/inbound', :offset => 50, :count => 50).
|
193
|
+
and_return(response)
|
194
|
+
subject.get_messages(:inbound => true, :offset => 50, :count => 50).
|
195
|
+
should be_an(Array)
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe '#get_message' do
|
202
|
+
let(:id) { '8ad0e8b0-xxxx-xxxx-951d-223c581bb467' }
|
203
|
+
let(:http_client) { subject.http_client }
|
204
|
+
let(:response) { {"To" => "leonard@bigbangtheory.com"} }
|
205
|
+
|
206
|
+
context 'given outbound' do
|
207
|
+
|
208
|
+
it 'requests a single message by id at /messages/outbound/:id/details' do
|
209
|
+
http_client.should_receive(:get).
|
210
|
+
with("messages/outbound/#{id}/details", {}).
|
211
|
+
and_return(response)
|
212
|
+
subject.get_message(id).should have_key(:to)
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
context 'given inbound' do
|
218
|
+
|
219
|
+
it 'requests a single message by id at /messages/inbound/:id/details' do
|
220
|
+
http_client.should_receive(:get).
|
221
|
+
with("messages/inbound/#{id}/details", {}).
|
222
|
+
and_return(response)
|
223
|
+
subject.get_message(id, :inbound => true).should have_key(:to)
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
describe '#dump_message' do
|
230
|
+
let(:id) { '8ad0e8b0-xxxx-xxxx-951d-223c581bb467' }
|
231
|
+
let(:http_client) { subject.http_client }
|
232
|
+
let(:response) { {"Body" => "From: <leonard@bigbangtheory.com> \r\n ..."} }
|
233
|
+
|
234
|
+
context 'given outbound' do
|
235
|
+
|
236
|
+
it 'requests a single message by id at /messages/outbound/:id/dump' do
|
237
|
+
http_client.should_receive(:get).
|
238
|
+
with("messages/outbound/#{id}/dump", {}).
|
239
|
+
and_return(response)
|
240
|
+
subject.dump_message(id).should have_key(:body)
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
context 'given inbound' do
|
246
|
+
|
247
|
+
it 'requests a single message by id at /messages/inbound/:id/dump' do
|
248
|
+
http_client.should_receive(:get).
|
249
|
+
with("messages/inbound/#{id}/dump", {}).
|
250
|
+
and_return(response)
|
251
|
+
subject.dump_message(id, :inbound => true).should have_key(:body)
|
252
|
+
end
|
253
|
+
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
173
257
|
describe "#get_bounces" do
|
174
258
|
let(:http_client) { subject.http_client }
|
175
259
|
let(:options) { {:foo => :bar} }
|
@@ -106,22 +106,40 @@ describe Mail::Message do
|
|
106
106
|
|
107
107
|
describe "#export_attachments" do
|
108
108
|
let(:file_data) { 'binarydatahere' }
|
109
|
-
let(:exported_data)
|
109
|
+
let(:exported_data) {
|
110
110
|
{'Name' => 'face.jpeg',
|
111
111
|
'Content' => "YmluYXJ5ZGF0YWhlcmU=\n",
|
112
112
|
'ContentType' => 'image/jpeg'}
|
113
|
-
|
113
|
+
}
|
114
|
+
|
115
|
+
context 'given a regular attachment' do
|
116
|
+
|
117
|
+
it "exports native attachments" do
|
118
|
+
mail_message.attachments["face.jpeg"] = file_data
|
119
|
+
mail_message.export_attachments.should include(exported_data)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "still supports the deprecated attachments API" do
|
123
|
+
mail_message.attachments["face.jpeg"] = file_data
|
124
|
+
mail_message.postmark_attachments = exported_data
|
125
|
+
mail_message.export_attachments.should == [exported_data, exported_data]
|
126
|
+
end
|
114
127
|
|
115
|
-
it "exports native attachments" do
|
116
|
-
mail_message.attachments["face.jpeg"] = file_data
|
117
|
-
mail_message.export_attachments.should include(exported_data)
|
118
128
|
end
|
119
129
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
130
|
+
context 'given an inline attachment' do
|
131
|
+
|
132
|
+
it "exports the attachment with related content id" do
|
133
|
+
mail_message.attachments.inline["face.jpeg"] = file_data
|
134
|
+
attachments = mail_message.export_attachments
|
135
|
+
attachments.count.should_not be_zero
|
136
|
+
attachments.first.should include(exported_data)
|
137
|
+
attachments.first.should have_key('ContentID')
|
138
|
+
attachments.first['ContentID'].should start_with('cid:')
|
139
|
+
end
|
140
|
+
|
124
141
|
end
|
142
|
+
|
125
143
|
end
|
126
144
|
|
127
145
|
describe "#export_headers" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postmark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petyo Ivanov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-01-
|
13
|
+
date: 2014-01-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- spec/data/empty.gif
|
125
125
|
- spec/integration/api_client_hashes_spec.rb
|
126
126
|
- spec/integration/api_client_messages_spec.rb
|
127
|
+
- spec/integration/api_client_resources_spec.rb
|
127
128
|
- spec/integration/mail_delivery_method_spec.rb
|
128
129
|
- spec/spec_helper.rb
|
129
130
|
- spec/support/helpers.rb
|
@@ -172,6 +173,7 @@ test_files:
|
|
172
173
|
- spec/data/empty.gif
|
173
174
|
- spec/integration/api_client_hashes_spec.rb
|
174
175
|
- spec/integration/api_client_messages_spec.rb
|
176
|
+
- spec/integration/api_client_resources_spec.rb
|
175
177
|
- spec/integration/mail_delivery_method_spec.rb
|
176
178
|
- spec/spec_helper.rb
|
177
179
|
- spec/support/helpers.rb
|