postmark 1.16.0 → 1.17.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 +4 -2
- data/CHANGELOG.rdoc +4 -0
- data/VERSION +1 -1
- data/lib/postmark/api_client.rb +1 -1
- data/lib/postmark/version.rb +1 -1
- data/spec/integration/api_client_hashes_spec.rb +9 -20
- data/spec/integration/api_client_messages_spec.rb +21 -40
- data/spec/integration/api_client_resources_spec.rb +1 -1
- data/spec/integration/mail_delivery_method_spec.rb +2 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f7b40fc4752d18a1e0c14357f256540b7324cf5eb5e919075f8970db47c88f2
|
4
|
+
data.tar.gz: 7169e072affbaced002b978a6b206723f6b494aa520dba8587bf01784e160139
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ab871fbf075102964bae2a5abb888e85514c1cd1e7d6b4a060bfeaf048ec021d0ea40ac389af785757e47b5fce9525bc2b926e7af63385cb0f2ee05d56d7890
|
7
|
+
data.tar.gz: 67d33ea5395c6c36d03a7081d8cf56d7517feb6877540aac7e5e612b57bd065ffc7932367ee175ea8999f125d2ead1b1377cfe4f5858f6ffcad5dfa0ce89e01f
|
data/.travis.yml
CHANGED
@@ -7,7 +7,7 @@ env:
|
|
7
7
|
# POSTMARK_CI_RECIPIENT=?
|
8
8
|
- secure: "V5GeJn1rch72qcAz/YI9tSEnZ2Zb4utWzq9ntr9gojRVFGpocgIbULmeslTKyIN7s5kF23qnhsGmPA9Olwz1ZqV9zhdWcsm4PUhUU/n3tVAnLWpUDjeneD5P+IOO6S+bCzVZX+Gk5/agBt2bQeAbVe+lVh5RZQJc3lsEvkVv7QM="
|
9
9
|
# POSTMARK_CI_SENDER=?
|
10
|
-
- secure: "
|
10
|
+
- secure: "qP1h4CajeKaVL7cUF3G9cKCm+KBjcTjTKRC3uOVN+X5dgQZFAuMQ9oJ3k1868AFMEJ2qqqfLCm177SlDXxqSisR7MEcCDIchiE+gUGH0YqZKLEYONyl00ts3/A6iMkQCODEB+kzLZAlByziO3CDZ6bHeLb6f7UJ4ExCSCQMYIyc="
|
11
11
|
language: ruby
|
12
12
|
rvm:
|
13
13
|
- 2.0.0
|
@@ -17,10 +17,12 @@ rvm:
|
|
17
17
|
matrix:
|
18
18
|
include:
|
19
19
|
- rvm: 1.8.7
|
20
|
+
dist: precise
|
20
21
|
gemfile: gemfiles/Gemfile.legacy
|
21
22
|
- rvm: 1.9.3
|
22
23
|
gemfile: gemfiles/Gemfile.legacy
|
23
24
|
- rvm: jruby-19mode
|
24
|
-
jdk: oraclejdk8
|
25
|
+
jdk: oraclejdk8
|
26
|
+
dist: trusty
|
25
27
|
gemfile: gemfiles/Gemfile.legacy
|
26
28
|
script: bundle exec rake spec
|
data/CHANGELOG.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.17.0
|
data/lib/postmark/api_client.rb
CHANGED
@@ -323,7 +323,7 @@ module Postmark
|
|
323
323
|
|
324
324
|
def update_message(message, response)
|
325
325
|
response ||= {}
|
326
|
-
message['Message-
|
326
|
+
message['X-PM-Message-Id'] = response['MessageID']
|
327
327
|
message.delivered = response['ErrorCode'] && response['ErrorCode'].zero?
|
328
328
|
message.postmark_response = response
|
329
329
|
end
|
data/lib/postmark/version.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Sending messages as Ruby hashes with Postmark::ApiClient" do
|
4
|
+
let(:message_id_format) { /<.+@.+>/ }
|
4
5
|
let(:postmark_message_id_format) { /\w{8}\-\w{4}-\w{4}-\w{4}-\w{12}/ }
|
5
|
-
let(:api_client) {
|
6
|
-
Postmark::ApiClient.new('POSTMARK_API_TEST',
|
7
|
-
:http_open_timeout => 15,
|
8
|
-
:http_read_timeout => 15)
|
9
|
-
}
|
6
|
+
let(:api_client) { Postmark::ApiClient.new('POSTMARK_API_TEST', :http_open_timeout => 15, :http_read_timeout => 15) }
|
10
7
|
|
11
8
|
let(:message) {
|
12
9
|
{
|
@@ -49,33 +46,29 @@ describe "Sending messages as Ruby hashes with Postmark::ApiClient" do
|
|
49
46
|
end
|
50
47
|
|
51
48
|
it 'updates a message object with Message-ID' do
|
52
|
-
api_client.deliver(message)[:message_id].
|
53
|
-
should =~ postmark_message_id_format
|
49
|
+
expect(api_client.deliver(message)[:message_id]).to be =~ postmark_message_id_format
|
54
50
|
end
|
55
51
|
|
56
52
|
it 'returns full Postmark response' do
|
57
|
-
api_client.deliver(message).
|
53
|
+
expect(api_client.deliver(message)).to be_a Hash
|
58
54
|
end
|
59
55
|
|
60
56
|
it 'delivers a message with attachment' do
|
61
|
-
api_client.deliver(message_with_attachment).
|
62
|
-
should have_key(:message_id)
|
57
|
+
expect(api_client.deliver(message_with_attachment)).to have_key(:message_id)
|
63
58
|
end
|
64
59
|
|
65
60
|
it 'fails to deliver a message without body' do
|
66
|
-
expect { api_client.deliver(message_with_no_body) }.
|
67
|
-
to raise_error(Postmark::InvalidMessageError)
|
61
|
+
expect { api_client.deliver(message_with_no_body) }.to raise_error(Postmark::InvalidMessageError)
|
68
62
|
end
|
69
63
|
|
70
64
|
it 'fails to deliver a message with invalid To address' do
|
71
|
-
expect { api_client.deliver(message_with_invalid_to) }.
|
72
|
-
to raise_error(Postmark::InvalidMessageError)
|
65
|
+
expect { api_client.deliver(message_with_invalid_to) }.to raise_error(Postmark::InvalidMessageError)
|
73
66
|
end
|
74
67
|
end
|
75
68
|
|
76
69
|
context "in batches" do
|
77
70
|
it 'returns as many responses as many messages were sent' do
|
78
|
-
api_client.deliver_in_batches(valid_messages).count.
|
71
|
+
expect(api_client.deliver_in_batches(valid_messages).count).to eq valid_messages.count
|
79
72
|
end
|
80
73
|
|
81
74
|
context "given custom max_batch_size" do
|
@@ -84,7 +77,7 @@ describe "Sending messages as Ruby hashes with Postmark::ApiClient" do
|
|
84
77
|
end
|
85
78
|
|
86
79
|
it 'returns as many responses as many messages were sent' do
|
87
|
-
api_client.deliver_in_batches(valid_messages).count.
|
80
|
+
expect(api_client.deliver_in_batches(valid_messages).count).to eq valid_messages.count
|
88
81
|
end
|
89
82
|
end
|
90
83
|
|
@@ -95,11 +88,7 @@ describe "Sending messages as Ruby hashes with Postmark::ApiClient" do
|
|
95
88
|
|
96
89
|
it "doesn't deliver a batch of invalid Mail::Message objects" do
|
97
90
|
response = api_client.deliver_in_batches(invalid_messages)
|
98
|
-
|
99
91
|
expect(response).to satisfy { |r| r.all? { |mr| !!mr[:error_code] } }
|
100
92
|
end
|
101
93
|
end
|
102
|
-
|
103
|
-
|
104
|
-
|
105
94
|
end
|
@@ -2,11 +2,7 @@ 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) {
|
6
|
-
Postmark::ApiClient.new('POSTMARK_API_TEST',
|
7
|
-
:http_open_timeout => 15,
|
8
|
-
:http_read_timeout => 15)
|
9
|
-
}
|
5
|
+
let(:api_client) { Postmark::ApiClient.new('POSTMARK_API_TEST', :http_open_timeout => 15, :http_read_timeout => 15) }
|
10
6
|
|
11
7
|
let(:message) {
|
12
8
|
Mail.new do
|
@@ -25,11 +21,7 @@ describe "Sending Mail::Messages with Postmark::ApiClient" do
|
|
25
21
|
end
|
26
22
|
}
|
27
23
|
|
28
|
-
let(:message_with_attachment) {
|
29
|
-
message.tap do |msg|
|
30
|
-
msg.attachments["test.gif"] = File.read(empty_gif_path)
|
31
|
-
end
|
32
|
-
}
|
24
|
+
let(:message_with_attachment) { message.tap { |msg| msg.attachments["test.gif"] = File.read(empty_gif_path) } }
|
33
25
|
|
34
26
|
let(:message_with_invalid_to) {
|
35
27
|
Mail.new do
|
@@ -52,57 +44,48 @@ describe "Sending Mail::Messages with Postmark::ApiClient" do
|
|
52
44
|
|
53
45
|
context "message by message" do
|
54
46
|
it 'delivers a plain text message' do
|
55
|
-
api_client.deliver_message(message).
|
47
|
+
expect(api_client.deliver_message(message)).to have_key(:message_id)
|
56
48
|
end
|
57
49
|
|
58
50
|
it 'updates a message object with Message-ID' do
|
59
|
-
api_client.deliver_message(message)[:message_id].
|
60
|
-
should =~ postmark_message_id_format
|
51
|
+
expect(api_client.deliver_message(message)[:message_id]).to be =~ postmark_message_id_format
|
61
52
|
end
|
62
53
|
|
63
54
|
it 'returns full Postmark response' do
|
64
|
-
api_client.deliver_message(message).
|
55
|
+
expect(api_client.deliver_message(message)).to be_a Hash
|
65
56
|
end
|
66
57
|
|
67
58
|
it 'delivers a message with attachment' do
|
68
|
-
api_client.deliver_message(message_with_attachment).
|
69
|
-
should have_key(:message_id)
|
59
|
+
expect(api_client.deliver_message(message_with_attachment)).to have_key(:message_id)
|
70
60
|
end
|
71
61
|
|
72
62
|
it 'fails to deliver a message without body' do
|
73
|
-
expect { api_client.deliver_message(message_with_no_body) }.
|
74
|
-
to raise_error(Postmark::InvalidMessageError)
|
63
|
+
expect { api_client.deliver_message(message_with_no_body) }.to raise_error(Postmark::InvalidMessageError)
|
75
64
|
end
|
76
65
|
|
77
66
|
it 'fails to deliver a message with invalid To address' do
|
78
|
-
expect { api_client.deliver_message(message_with_invalid_to) }.
|
79
|
-
to raise_error(Postmark::InvalidMessageError)
|
67
|
+
expect { api_client.deliver_message(message_with_invalid_to) }.to raise_error(Postmark::InvalidMessageError)
|
80
68
|
end
|
81
69
|
end
|
82
70
|
|
83
71
|
context "in batches" do
|
84
72
|
it 'delivers a batch of valid Mail::Message objects' do
|
85
73
|
expect { api_client.deliver_messages(valid_messages) }.
|
86
|
-
to change{valid_messages.all? { |m| m.delivered? }}.
|
87
|
-
to true
|
74
|
+
to change{valid_messages.all? { |m| m.delivered? }}.to true
|
88
75
|
end
|
89
76
|
|
90
|
-
it 'updates delivered messages with Message-
|
77
|
+
it 'updates delivered messages with X-PM-Message-Ids' do
|
91
78
|
api_client.deliver_messages(valid_messages)
|
92
|
-
|
93
|
-
expect(valid_messages.all? { |m| m.message_id =~ postmark_message_id_format }).
|
94
|
-
to be true
|
79
|
+
expect(valid_messages.all? { |m| m['X-PM-Message-Id'].to_s =~ postmark_message_id_format }).to be true
|
95
80
|
end
|
96
81
|
|
97
82
|
it 'updates delivered messages with related Postmark responses' do
|
98
83
|
api_client.deliver_messages(valid_messages)
|
99
|
-
|
100
|
-
expect(valid_messages.all? { |m| m.postmark_response["To"] == m.to[0] }).
|
101
|
-
to be true
|
84
|
+
expect(valid_messages.all? { |m| m.postmark_response["To"] == m.to[0] }).to be true
|
102
85
|
end
|
103
86
|
|
104
87
|
it 'returns as many responses as many messages were sent' do
|
105
|
-
api_client.deliver_messages(valid_messages).count.
|
88
|
+
expect(api_client.deliver_messages(valid_messages).count).to eq valid_messages.count
|
106
89
|
end
|
107
90
|
|
108
91
|
context "given custom max_batch_size" do
|
@@ -112,28 +95,26 @@ describe "Sending Mail::Messages with Postmark::ApiClient" do
|
|
112
95
|
|
113
96
|
it 'updates delivered messages with related Postmark responses' do
|
114
97
|
api_client.deliver_messages(valid_messages)
|
115
|
-
|
116
|
-
expect(valid_messages.all? { |m| m.postmark_response["To"] == m.to[0] }).
|
117
|
-
to be true
|
98
|
+
expect(valid_messages.all? { |m| m.postmark_response["To"] == m.to[0] }).to be true
|
118
99
|
end
|
119
100
|
|
120
101
|
it 'returns as many responses as many messages were sent' do
|
121
|
-
api_client.deliver_messages(valid_messages).count.
|
102
|
+
expect(api_client.deliver_messages(valid_messages).count).to eq valid_messages.count
|
122
103
|
end
|
123
104
|
end
|
124
105
|
|
125
106
|
it 'partially delivers a batch of partially valid Mail::Message objects' do
|
126
107
|
expect { api_client.deliver_messages(partially_valid_messages) }.
|
127
|
-
to change{partially_valid_messages.select { |m| m.delivered? }.count}.
|
128
|
-
to 2
|
108
|
+
to change{partially_valid_messages.select { |m| m.delivered? }.count}.to 2
|
129
109
|
end
|
130
110
|
|
131
111
|
it "doesn't deliver a batch of invalid Mail::Message objects" do
|
132
|
-
|
133
|
-
|
134
|
-
|
112
|
+
aggregate_failures do
|
113
|
+
expect { api_client.deliver_messages(invalid_messages) }.
|
114
|
+
to change{invalid_messages.all? { |m| m.delivered? == false }}.to true
|
135
115
|
|
136
|
-
|
116
|
+
expect(invalid_messages).to satisfy { |ms| ms.all? { |m| !!m.postmark_response }}
|
117
|
+
end
|
137
118
|
end
|
138
119
|
end
|
139
120
|
end
|
@@ -8,7 +8,7 @@ describe 'Accessing server resources using the API' do
|
|
8
8
|
let(:recipient) { ENV['POSTMARK_CI_RECIPIENT'] }
|
9
9
|
let(:message) {
|
10
10
|
{
|
11
|
-
:from =>
|
11
|
+
:from => ENV['POSTMARK_CI_SENDER'],
|
12
12
|
:to => recipient,
|
13
13
|
:subject => "Mail::Message object",
|
14
14
|
:text_body => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " \
|
@@ -53,9 +53,9 @@ describe "Sending Mail::Messages with delivery_method Mail::Postmark" do
|
|
53
53
|
expect { message.deliver }.to change{message.delivered?}.to(true)
|
54
54
|
end
|
55
55
|
|
56
|
-
it 'updates a message object with Message-
|
56
|
+
it 'updates a message object with X-PM-Message-Id' do
|
57
57
|
expect { message.deliver }.
|
58
|
-
to change{message['Message-
|
58
|
+
to change{message['X-PM-Message-Id'].to_s}.to(postmark_message_id_format)
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'updates a message object with full postmark response' 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.
|
4
|
+
version: 1.17.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: 2019-
|
13
|
+
date: 2019-08-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -146,8 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: 1.3.7
|
148
148
|
requirements: []
|
149
|
-
|
150
|
-
rubygems_version: 2.7.8
|
149
|
+
rubygems_version: 3.0.1
|
151
150
|
signing_key:
|
152
151
|
specification_version: 4
|
153
152
|
summary: Official Postmark API wrapper.
|