postmark 0.9.17 → 0.9.18

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,12 @@
1
1
  = Changelog
2
2
 
3
+ == 0.9.18
4
+
5
+ * Fixed regression introduced by removing ActiveSupport#wrap in case when a Hash instance is passed.
6
+ * Fixed broken Ruby 1.8.7 support (uninitialized constant Postmark::HttpClient::Mutex (NameError)).
7
+ * Added unit tests for attachments handling.
8
+ * Removed unneeded debug output from shared RSpec examples.
9
+
3
10
  == 0.9.17
4
11
 
5
12
  * Removed date from gemspec.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.17
1
+ 0.9.18
@@ -1,3 +1,4 @@
1
+ require 'thread' unless defined? Mutex # For Ruby 1.8.7
1
2
  require 'cgi'
2
3
 
3
4
  module Postmark
@@ -10,7 +10,7 @@ module Postmark
10
10
  end
11
11
 
12
12
  def postmark_attachments=(value)
13
- @_attachments = Array[*value]
13
+ @_attachments = wrap_in_array(value)
14
14
  end
15
15
 
16
16
  def postmark_attachments
@@ -29,5 +29,18 @@ module Postmark
29
29
  end
30
30
  end
31
31
 
32
+ protected
33
+
34
+ # From ActiveSupport (Array#wrap)
35
+ def wrap_in_array(object)
36
+ if object.nil?
37
+ []
38
+ elsif object.respond_to?(:to_ary)
39
+ object.to_ary || [object]
40
+ else
41
+ [object]
42
+ end
43
+ end
44
+
32
45
  end
33
46
  end
@@ -1,3 +1,3 @@
1
1
  module Postmark
2
- VERSION = "0.9.17"
2
+ VERSION = "0.9.18"
3
3
  end
@@ -20,7 +20,7 @@ describe Postmark do
20
20
  mail.content_type = "text/html"
21
21
  end
22
22
  end
23
-
23
+
24
24
  let :mail_message do
25
25
  Mail.new do
26
26
  from "sheldon@bigbangtheory.com"
@@ -40,7 +40,7 @@ describe Postmark do
40
40
  end
41
41
  end
42
42
  end
43
-
43
+
44
44
  let :mail_multipart_message do
45
45
  mail = Mail.new do
46
46
  from "sheldon@bigbangtheory.com"
@@ -103,7 +103,7 @@ describe Postmark do
103
103
 
104
104
  it "should retry 3 times" do
105
105
  FakeWeb.register_uri(:post, "http://api.postmarkapp.com/email",
106
- [
106
+ [
107
107
  { :status => [ 500, "Internal Server Error" ], :body => response_body(500, 'Internal Server Error') },
108
108
  { :status => [ 500, "Internal Server Error" ], :body => response_body(500, 'Internal Server Error') },
109
109
  { :body => response_body(500, 'Internal Server Error') }
@@ -134,9 +134,9 @@ describe Postmark do
134
134
  context "tmail parse", :ruby => 1.8 do
135
135
  require 'tmail'
136
136
  subject { tmail_message }
137
- it_behaves_like :mail
137
+ it_behaves_like :mail
138
138
  end
139
-
139
+
140
140
  context "when mail parse" do
141
141
  subject { mail_message }
142
142
  it_behaves_like :mail
@@ -148,21 +148,21 @@ describe Postmark do
148
148
  it "should encode custom headers properly" do
149
149
  subject.header["CUSTOM-HEADER"] = "header"
150
150
  subject.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!", "Headers":[{"Name":"Custom-Header", "Value":"header"}]}]
151
- end
151
+ end
152
152
  end
153
-
153
+
154
154
  context "mail delivery method" do
155
155
  it "should be able to set delivery_method" do
156
156
  mail_message.delivery_method Mail::Postmark
157
157
  end
158
-
158
+
159
159
  it "should wrap Postmark.send_through_postmark" do
160
160
  message = mail_message
161
161
  Postmark.should_receive(:send_through_postmark).with(message)
162
162
  mail_message.delivery_method Mail::Postmark
163
163
  mail_message.deliver
164
164
  end
165
-
165
+
166
166
  it "should allow setting of api_key" do
167
167
  mail_message.delivery_method Mail::Postmark, {:api_key => 'api-key'}
168
168
  mail_message.delivery_method.settings[:api_key].should == 'api-key'
@@ -182,11 +182,33 @@ describe Postmark do
182
182
  mail_message.deliver!
183
183
  end
184
184
 
185
- it "should run postmark attachments hook when using deliver method" do
185
+ it "should run postmark attachments hook when using deliver method" do
186
186
  mail_message.deliver
187
187
  end
188
+ end
189
+
190
+ context "attachments setter", :ruby => 1.9 do
191
+ let(:attached_hash) { { "Name" => "picture.jpeg", "ContentType" => "image/jpeg" } }
192
+ let(:attached_file) { mock("file") }
193
+
194
+ it "should store attachments as array" do
195
+ mail_message.postmark_attachments = attached_hash
196
+ mail_message.postmark_attachments.should be_kind_of(Array)
197
+ end
188
198
 
189
-
199
+ it "should save the attachments in attachments array" do
200
+ mail_message.postmark_attachments = [attached_hash, attached_file]
201
+
202
+ attached_file.stub(:is_a?) { |arg| arg == File ? true : false }
203
+ attached_file.stub(:path) { '/tmp/file.jpeg' }
204
+ IO.should_receive(:read).with("/tmp/file.jpeg").and_return("")
205
+
206
+ mail_message.postmark_attachments = [attached_hash, attached_file]
207
+ attachments = mail_message.postmark_attachments.map { |a| a['Name'] }
208
+
209
+ attachments.should include('picture.jpeg')
210
+ attachments.should include('file.jpeg')
211
+ end
190
212
  end
191
213
 
192
214
  context "JSON library support" do
@@ -2,7 +2,7 @@ shared_examples :mail do
2
2
  it "should set text body for plain message" do
3
3
  Postmark.send(:convert_message_to_options_hash, subject)['TextBody'].should_not be_nil
4
4
  end
5
-
5
+
6
6
  it "should encode from properly when name is used" do
7
7
  subject.from = "Sheldon Lee Cooper <sheldon@bigbangtheory.com>"
8
8
  subject.should be_serialized_to %q[{"Subject":"Hello!", "From":"Sheldon Lee Cooper <sheldon@bigbangtheory.com>", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
@@ -12,22 +12,22 @@ shared_examples :mail do
12
12
  subject.reply_to = ['a@a.com', 'b@b.com']
13
13
  subject.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "ReplyTo":"a@a.com, b@b.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
14
14
  end
15
-
15
+
16
16
  it "should encode tag" do
17
17
  subject.tag = "invite"
18
18
  subject.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "Tag":"invite", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
19
19
  end
20
-
20
+
21
21
  it "should encode multiple recepients (TO)" do
22
22
  subject.to = ['a@a.com', 'b@b.com']
23
23
  subject.should be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"a@a.com, b@b.com", "TextBody":"Hello Sheldon!"}]
24
24
  end
25
-
25
+
26
26
  it "should encode multiple recepients (CC)" do
27
27
  subject.cc = ['a@a.com', 'b@b.com']
28
28
  subject.should be_serialized_to %q[{"Cc":"a@a.com, b@b.com", "Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
29
29
  end
30
-
30
+
31
31
  it "should encode multiple recepients (BCC)" do
32
32
  subject.bcc = ['a@a.com', 'b@b.com']
33
33
  subject.should be_serialized_to %q[{"Bcc":"a@a.com, b@b.com", "Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
@@ -35,7 +35,6 @@ shared_examples :mail do
35
35
 
36
36
  it "should accept string as reply_to field" do
37
37
  subject.reply_to = ['Anton Astashov <b@b.com>']
38
- puts subject.reply_to.inspect
39
38
  subject.should be_serialized_to %q[{"From": "sheldon@bigbangtheory.com", "ReplyTo": "b@b.com", "To": "lenard@bigbangtheory.com", "Subject": "Hello!", "TextBody": "Hello Sheldon!"}]
40
39
  end
41
40
  end
metadata CHANGED
@@ -1,187 +1,176 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: postmark
3
- version: !ruby/object:Gem::Version
4
- version: 0.9.17
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 9
9
+ - 18
10
+ version: 0.9.18
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Petyo Ivanov
9
14
  - Ilya Sabanin
10
15
  - Artem Chistyakov
11
16
  autorequire:
12
17
  bindir: bin
13
18
  cert_chain: []
14
- date: 2013-01-12 00:00:00.000000000 Z
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: rake
18
- requirement: !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ! '>='
22
- - !ruby/object:Gem::Version
23
- version: '0'
19
+
20
+ date: 2013-01-12 00:00:00 Z
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ prerelease: false
24
33
  type: :runtime
34
+ name: rake
35
+ requirement: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
25
46
  prerelease: false
26
- version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
- requirements:
29
- - - ! '>='
30
- - !ruby/object:Gem::Version
31
- version: '0'
32
- - !ruby/object:Gem::Dependency
33
- name: json
34
- requirement: !ruby/object:Gem::Requirement
35
- none: false
36
- requirements:
37
- - - ! '>='
38
- - !ruby/object:Gem::Version
39
- version: '0'
40
47
  type: :runtime
48
+ name: json
49
+ requirement: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ version_requirements: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
41
60
  prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
- requirements:
45
- - - ! '>='
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- - !ruby/object:Gem::Dependency
49
- name: tmail
50
- requirement: !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
53
- - - ! '>='
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
61
  type: :development
62
+ name: tmail
63
+ requirement: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
57
74
  prerelease: false
58
- version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
- requirements:
61
- - - ! '>='
62
- - !ruby/object:Gem::Version
63
- version: '0'
64
- - !ruby/object:Gem::Dependency
75
+ type: :development
65
76
  name: mail
66
- requirement: !ruby/object:Gem::Requirement
77
+ requirement: *id004
78
+ - !ruby/object:Gem::Dependency
79
+ version_requirements: &id005 !ruby/object:Gem::Requirement
67
80
  none: false
68
- requirements:
69
- - - ! '>='
70
- - !ruby/object:Gem::Version
71
- version: '0'
72
- type: :development
81
+ requirements:
82
+ - - ~>
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 2
87
+ - 0
88
+ version: "2.0"
73
89
  prerelease: false
74
- version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
- requirements:
77
- - - ! '>='
78
- - !ruby/object:Gem::Version
79
- version: '0'
80
- - !ruby/object:Gem::Dependency
90
+ type: :development
81
91
  name: rspec-core
82
- requirement: !ruby/object:Gem::Requirement
92
+ requirement: *id005
93
+ - !ruby/object:Gem::Dependency
94
+ version_requirements: &id006 !ruby/object:Gem::Requirement
83
95
  none: false
84
- requirements:
96
+ requirements:
85
97
  - - ~>
86
- - !ruby/object:Gem::Version
87
- version: '2.0'
88
- type: :development
98
+ - !ruby/object:Gem::Version
99
+ hash: 7
100
+ segments:
101
+ - 3
102
+ - 0
103
+ version: "3.0"
89
104
  prerelease: false
90
- version_requirements: !ruby/object:Gem::Requirement
91
- none: false
92
- requirements:
93
- - - ~>
94
- - !ruby/object:Gem::Version
95
- version: '2.0'
96
- - !ruby/object:Gem::Dependency
97
- name: activesupport
98
- requirement: !ruby/object:Gem::Requirement
99
- none: false
100
- requirements:
101
- - - ~>
102
- - !ruby/object:Gem::Version
103
- version: '3.0'
104
105
  type: :development
106
+ name: activesupport
107
+ requirement: *id006
108
+ - !ruby/object:Gem::Dependency
109
+ version_requirements: &id007 !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ hash: 3
115
+ segments:
116
+ - 0
117
+ version: "0"
105
118
  prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- none: false
108
- requirements:
109
- - - ~>
110
- - !ruby/object:Gem::Version
111
- version: '3.0'
112
- - !ruby/object:Gem::Dependency
113
- name: fakeweb
114
- requirement: !ruby/object:Gem::Requirement
115
- none: false
116
- requirements:
117
- - - ! '>='
118
- - !ruby/object:Gem::Version
119
- version: '0'
120
119
  type: :development
120
+ name: fakeweb
121
+ requirement: *id007
122
+ - !ruby/object:Gem::Dependency
123
+ version_requirements: &id008 !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ hash: 3
129
+ segments:
130
+ - 0
131
+ version: "0"
121
132
  prerelease: false
122
- version_requirements: !ruby/object:Gem::Requirement
123
- none: false
124
- requirements:
125
- - - ! '>='
126
- - !ruby/object:Gem::Version
127
- version: '0'
128
- - !ruby/object:Gem::Dependency
129
- name: fakeweb-matcher
130
- requirement: !ruby/object:Gem::Requirement
131
- none: false
132
- requirements:
133
- - - ! '>='
134
- - !ruby/object:Gem::Version
135
- version: '0'
136
133
  type: :development
134
+ name: fakeweb-matcher
135
+ requirement: *id008
136
+ - !ruby/object:Gem::Dependency
137
+ version_requirements: &id009 !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ hash: 3
143
+ segments:
144
+ - 0
145
+ version: "0"
137
146
  prerelease: false
138
- version_requirements: !ruby/object:Gem::Requirement
139
- none: false
140
- requirements:
141
- - - ! '>='
142
- - !ruby/object:Gem::Version
143
- version: '0'
144
- - !ruby/object:Gem::Dependency
145
- name: timecop
146
- requirement: !ruby/object:Gem::Requirement
147
- none: false
148
- requirements:
149
- - - ! '>='
150
- - !ruby/object:Gem::Version
151
- version: '0'
152
147
  type: :development
148
+ name: timecop
149
+ requirement: *id009
150
+ - !ruby/object:Gem::Dependency
151
+ version_requirements: &id010 !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ hash: 3
157
+ segments:
158
+ - 0
159
+ version: "0"
153
160
  prerelease: false
154
- version_requirements: !ruby/object:Gem::Requirement
155
- none: false
156
- requirements:
157
- - - ! '>='
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- - !ruby/object:Gem::Dependency
161
- name: yajl-ruby
162
- requirement: !ruby/object:Gem::Requirement
163
- none: false
164
- requirements:
165
- - - ! '>='
166
- - !ruby/object:Gem::Version
167
- version: '0'
168
161
  type: :development
169
- prerelease: false
170
- version_requirements: !ruby/object:Gem::Requirement
171
- none: false
172
- requirements:
173
- - - ! '>='
174
- - !ruby/object:Gem::Version
175
- version: '0'
176
- description: Use this gem to send emails through Postmark HTTP API and retrieve info
177
- about bounces.
162
+ name: yajl-ruby
163
+ requirement: *id010
164
+ description: Use this gem to send emails through Postmark HTTP API and retrieve info about bounces.
178
165
  email: ilya@wildbit.com
179
166
  executables: []
167
+
180
168
  extensions: []
181
- extra_rdoc_files:
169
+
170
+ extra_rdoc_files:
182
171
  - LICENSE
183
172
  - README.md
184
- files:
173
+ files:
185
174
  - .document
186
175
  - .gitignore
187
176
  - .rake_tasks
@@ -213,36 +202,40 @@ files:
213
202
  - spec/spec_helper.rb
214
203
  homepage: http://postmarkapp.com
215
204
  licenses: []
216
- post_install_message: ! "\n ==================\n Thanks for installing the postmark
217
- gem. If you don't have an account, please sign up at http://postmarkapp.com/.\n
218
- \ Review the README.md for implementation details and examples.\n ==================\n
219
- \ "
220
- rdoc_options:
205
+
206
+ post_install_message: "\n ==================\n Thanks for installing the postmark gem. If you don't have an account, please sign up at http://postmarkapp.com/.\n Review the README.md for implementation details and examples.\n ==================\n "
207
+ rdoc_options:
221
208
  - --charset=UTF-8
222
- require_paths:
209
+ require_paths:
223
210
  - lib
224
- required_ruby_version: !ruby/object:Gem::Requirement
211
+ required_ruby_version: !ruby/object:Gem::Requirement
225
212
  none: false
226
- requirements:
227
- - - ! '>='
228
- - !ruby/object:Gem::Version
229
- version: '0'
230
- segments:
213
+ requirements:
214
+ - - ">="
215
+ - !ruby/object:Gem::Version
216
+ hash: 3
217
+ segments:
231
218
  - 0
232
- hash: 153664990772119829
233
- required_rubygems_version: !ruby/object:Gem::Requirement
219
+ version: "0"
220
+ required_rubygems_version: !ruby/object:Gem::Requirement
234
221
  none: false
235
- requirements:
236
- - - ! '>='
237
- - !ruby/object:Gem::Version
222
+ requirements:
223
+ - - ">="
224
+ - !ruby/object:Gem::Version
225
+ hash: 21
226
+ segments:
227
+ - 1
228
+ - 3
229
+ - 7
238
230
  version: 1.3.7
239
231
  requirements: []
232
+
240
233
  rubyforge_project:
241
234
  rubygems_version: 1.8.24
242
235
  signing_key:
243
236
  specification_version: 3
244
237
  summary: Official Postmark API wrapper.
245
- test_files:
238
+ test_files:
246
239
  - spec/bounce_spec.rb
247
240
  - spec/postmark_spec.rb
248
241
  - spec/shared_examples.rb