mandrill_mailer 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 066d9d8a41e15e942635771fdef695a54a71a667
4
- data.tar.gz: c1dddaf88be75ed2ddab9165767145aace80dc1b
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWI2NjAwM2QwM2Q4OWFmZWUyNjQwNjFiOTBlOWYyMWI2NGJmNDEwZQ==
5
+ data.tar.gz: !binary |-
6
+ NTg4NzVlMGU0NjFhNGY4MWM3ZTc4YmM3ZjNlODI3N2EzMjRkMmY0YQ==
5
7
  SHA512:
6
- metadata.gz: 768bfe2d37ea0b516bead42c089ffdb5d2a077bb8e0300a5e721f8ec656f1fc9717e068877e5b6d5c190c2b73e6c09fdea9e67a74b47f8a2332e74a77ac8a05e
7
- data.tar.gz: df0ea1de244c30e78cb3b5c8de329c2f8bc017abb01e56369dab9c7c715a280a8da9d4ada95f1538d2b8d4bcad9455868cfb07ed48cd165f3429e98d9af85e52
8
+ metadata.gz: !binary |-
9
+ Y2NhMWM5ZTMwNjNiZmNhNmU1ZDVhYjJiMzkxY2VkNzNiOTQyZDRhZjU5ZmFk
10
+ NWJmZjFlYTdkYjJiY2FhNzNjMWZkMGNlN2Q3Y2QyNTQyOTNlNWY4OTQxZGY0
11
+ ZDY0ZTgyNWNhYjA0Yzc5ZDdlNzQ5MDdlZTkwYzBjMWFmMjk2ZmY=
12
+ data.tar.gz: !binary |-
13
+ MWE2ODc4OTI2YzgyZmIyMDQ5NjAxYjQ5ZDhlMWY2ODU0MTNmOThkMTE5N2Jk
14
+ YTNmMTBjNWVhOWQ5N2UxMWU1YmFiMGQ0NWExMGE4MmE3NjlmZmE3MzZhYzJl
15
+ OGU2ODM2ZTc1NmNkYTU1OWQzNGU5YzQ1ZjMwNzZkMzNhNjc0MTk=
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # 0.4.3
2
+ - [FEATURE] Add the ability to look at deliveries for offline testing.
3
+
4
+ # 0.4.2
5
+ - [FEATURE] Add the ability to intercept emails before they are sent in the config (see the specs for more info).
6
+
7
+ # 0.4.1
8
+ - [FEATURE] Add subaccount parameter.
9
+
10
+ # 0.4.0
11
+ - Default setting for preserve_recipients no longer defaults to true. Bumping a minor version since this might have been assumed to be default and not set by some.
12
+
13
+ # 0.3.8
14
+ - Changelog created.
data/README.md CHANGED
@@ -176,7 +176,7 @@ And then if you wish you can look at the contents of `MandrillMailer.deliveries`
176
176
  ```ruby
177
177
  email = MandrillMailer::deliveries.detect { |mail|
178
178
  mail.template_name == 'my-template' &&
179
- mail.message['to'].any? { |to| to['email'] == 'my@email.com' }
179
+ mail.message['to'].any? { |to| to[:email] == 'my@email.com' }
180
180
  }
181
181
  expect(email).to_not be_nil
182
182
  ```
@@ -215,6 +215,17 @@ class UpdateEmailJob < Struct.new(:user_id)
215
215
  end
216
216
  ```
217
217
 
218
+ ## Using Sidekiq
219
+
220
+ To use this gem with Sidekiq, add `config/initializers/mandrill_mailer_sidekiq.rb`
221
+
222
+ ```ruby
223
+ ::MandrillMailer::TemplateMailer.extend(Sidekiq::Extensions::ActionMailer)
224
+ ```
225
+
226
+ Use the same way you use ActionMailer. More info: https://github.com/mperham/sidekiq/wiki/Delayed-Extensions#actionmailer
227
+
228
+
218
229
  ## Using an interceptor
219
230
  You can set a mailer interceptor to override any params used when you deliver an e-mail.
220
231
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Example usage:
5
5
 
6
- # class InvitationMailer < MandrillMailer
6
+ # class InvitationMailer < MandrillMailer::TemplateMailer
7
7
  # default from: 'support@codeschool.com'
8
8
 
9
9
  # def invite(invitation)
@@ -292,6 +292,18 @@ module MandrillMailer
292
292
  }
293
293
  end
294
294
 
295
+ def from
296
+ self.message && self.message['from_email']
297
+ end
298
+
299
+ def to
300
+ self.message && self.message['to']
301
+ end
302
+
303
+ def bcc
304
+ self.message && self.message['bcc_address']
305
+ end
306
+
295
307
  protected
296
308
 
297
309
  def mandrill_attachment_args(args)
@@ -314,7 +326,7 @@ module MandrillMailer
314
326
  end
315
327
 
316
328
  def self.respond_to?(method, include_private = false)
317
- super || instance_methods.include?(method)
329
+ super || instance_methods.include?(method.to_sym)
318
330
  end
319
331
 
320
332
  # Proxy route helpers to rails if Rails exists. Doing routes this way
@@ -1,3 +1,3 @@
1
1
  module MandrillMailer
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
@@ -7,10 +7,57 @@ describe MandrillMailer::TemplateMailer do
7
7
  let(:mailer) { described_class.new }
8
8
  let(:api_key) { '1237861278' }
9
9
 
10
+ let(:template_content_name) { 'edit' }
11
+ let(:template_content_content) { 'edit_content' }
12
+ let(:from_email) { 'from@email.com' }
13
+ let(:from_name) { 'Example Name' }
14
+ let(:var_name) { 'USER_NAME' }
15
+ let(:var_content) { 'bobert' }
16
+ let(:var_rcpt_name) { 'USER_INFO' }
17
+ let(:var_rcpt_content) { 'boboblacksheep' }
18
+ let(:to_email) { 'bob@email.com' }
19
+ let(:to_name) { 'bob' }
20
+ let(:attachment_file) { File.read(File.expand_path('spec/support/test_image.png')) }
21
+ let(:attachment_filename) { 'test_image.png' }
22
+ let(:attachment_mimetype) { 'image/png' }
23
+ let(:send_at) { Time.utc(2020, 1, 1, 8, 0) }
24
+ let(:bcc) { "bcc@email.com" }
25
+
26
+ let(:args) do
27
+ {
28
+ from: from_email,
29
+ template: 'Email Template',
30
+ subject: "super secret",
31
+ to: {'email' => to_email, 'name' => to_name},
32
+ preserve_recipients: false,
33
+ vars: {
34
+ var_name => var_content
35
+ },
36
+ recipient_vars: [
37
+ { to_email => { var_rcpt_name => var_rcpt_content } }
38
+ ],
39
+ template_content: {template_content_name => template_content_content},
40
+ headers: {"Reply-To" => "support@email.com"},
41
+ bcc: bcc,
42
+ tags: ['tag1'],
43
+ subaccount: "subaccount1",
44
+ google_analytics_domains: ["http://site.com"],
45
+ google_analytics_campaign: '1237423474',
46
+ attachments: [{file: attachment_file, filename: attachment_filename, mimetype: attachment_mimetype}],
47
+ inline_css: true,
48
+ important: true,
49
+ send_at: send_at,
50
+ track_opens: false,
51
+ track_clicks: false,
52
+ url_strip_qs: false
53
+ }
54
+ end
55
+
10
56
  before do
11
57
  MandrillMailer.config.api_key = api_key
12
58
  MandrillMailer.config.default_url_options = { host: default_host }
13
59
  MandrillMailer.config.stub(:image_path).and_return(image_path)
60
+ MandrillMailer::TemplateMailer.default from: from_email, from_name: from_name
14
61
  end
15
62
 
16
63
  describe '#image_path' do
@@ -116,56 +163,8 @@ describe MandrillMailer::TemplateMailer do
116
163
  end
117
164
 
118
165
  describe '#mandrill_mail' do
119
- let(:template_content_name) { 'edit' }
120
- let(:template_content_content) { 'edit_content' }
121
- let(:from_email) { 'from@email.com' }
122
- let(:from_name) { 'Example Name' }
123
- let(:var_name) { 'USER_NAME' }
124
- let(:var_content) { 'bobert' }
125
- let(:var_rcpt_name) { 'USER_INFO' }
126
- let(:var_rcpt_content) { 'boboblacksheep' }
127
- let(:to_email) { 'bob@email.com' }
128
- let(:to_name) { 'bob' }
129
- let(:attachment_file) { File.read(File.expand_path('spec/support/test_image.png')) }
130
- let(:attachment_filename) { 'test_image.png' }
131
- let(:attachment_mimetype) { 'image/png' }
132
- let(:send_at) { Time.utc(2020, 1, 1, 8, 0) }
133
-
134
- let(:args) do
135
- {
136
- template: 'Email Template',
137
- subject: "super secret",
138
- to: {'email' => to_email, 'name' => to_name},
139
- preserve_recipients: false,
140
- vars: {
141
- var_name => var_content
142
- },
143
- recipient_vars: [
144
- { to_email => { var_rcpt_name => var_rcpt_content } }
145
- ],
146
- template_content: {template_content_name => template_content_content},
147
- headers: {"Reply-To" => "support@email.com"},
148
- bcc: 'email@email.com',
149
- tags: ['tag1'],
150
- subaccount: "subaccount1",
151
- google_analytics_domains: ["http://site.com"],
152
- google_analytics_campaign: '1237423474',
153
- attachments: [{file: attachment_file, filename: attachment_filename, mimetype: attachment_mimetype}],
154
- inline_css: true,
155
- important: true,
156
- send_at: send_at,
157
- track_opens: false,
158
- track_clicks: false,
159
- url_strip_qs: false
160
- }
161
- end
162
-
163
166
  subject { mailer.mandrill_mail(args) }
164
167
 
165
- before do
166
- MandrillMailer::TemplateMailer.default from: from_email, from_name: from_name
167
- end
168
-
169
168
  it 'should return the current class instance' do
170
169
  should eq mailer
171
170
  end
@@ -232,6 +231,10 @@ describe MandrillMailer::TemplateMailer do
232
231
  MandrillMailer.config.interceptor_params = @intercepted_params
233
232
  end
234
233
 
234
+ after do
235
+ MandrillMailer.config.interceptor_params = nil
236
+ end
237
+
235
238
  it "should raise an error if interceptor params is not a Hash" do
236
239
  MandrillMailer.config.interceptor_params = "error"
237
240
  expect { subject }.to raise_error(MandrillMailer::TemplateMailer::InvalidInterceptorParams, "The interceptor_params config must be a Hash")
@@ -319,4 +322,49 @@ describe MandrillMailer::TemplateMailer do
319
322
  klassB.mandrill_mail({vars: {}}).message['from_name'].should eq 'ClassB'
320
323
  end
321
324
  end
325
+
326
+ describe '#respond_to' do
327
+ it 'can respond to a symbol' do
328
+ klassA = Class.new(MandrillMailer::TemplateMailer) do
329
+ def test_method
330
+
331
+ end
332
+ end
333
+
334
+ klassA.respond_to?(:test_method).should be_true
335
+ end
336
+ it 'can respond to a string' do
337
+ klassA = Class.new(MandrillMailer::TemplateMailer) do
338
+ def test_method
339
+
340
+ end
341
+ end
342
+
343
+ klassA.respond_to?('test_method').should be_true
344
+ end
345
+ end
346
+
347
+ describe "#from" do
348
+ subject { mailer.mandrill_mail(args) }
349
+
350
+ it "returns the from email" do
351
+ subject.from.should eq from_email
352
+ end
353
+ end
354
+
355
+ describe "#to" do
356
+ subject { mailer.mandrill_mail(args) }
357
+
358
+ it "returns the to email data" do
359
+ subject.to.should eq [{"email" => to_email, "name" => to_name}]
360
+ end
361
+ end
362
+
363
+ describe "#bcc" do
364
+ subject { mailer.mandrill_mail(args) }
365
+
366
+ it "returns the bcc email/s" do
367
+ subject.bcc.should eq bcc
368
+ end
369
+ end
322
370
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mandrill_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Rensel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-28 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actionpack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
@@ -56,28 +56,28 @@ dependencies:
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ! '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ! '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Transactional Mailer for Mandrill
@@ -89,9 +89,9 @@ extra_rdoc_files: []
89
89
  files:
90
90
  - .gitignore
91
91
  - .rspec
92
+ - CHANGELOG.md
92
93
  - Gemfile
93
94
  - README.md
94
- - change_log.md
95
95
  - lib/mandrill_mailer.rb
96
96
  - lib/mandrill_mailer/mock.rb
97
97
  - lib/mandrill_mailer/offline.rb
@@ -113,12 +113,12 @@ require_paths:
113
113
  - lib
114
114
  required_ruby_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - '>='
116
+ - - ! '>='
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - '>='
121
+ - - ! '>='
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0'
124
124
  requirements: []
data/change_log.md DELETED
@@ -1,16 +0,0 @@
1
- * 0.4.3
2
- Add the ability to look at deliveries for offline testing.
3
-
4
- * 0.4.2
5
- Add the ability to intercept emails before they are sent in the config
6
- see the specs for more info
7
-
8
- * 0.4.1
9
- add subaccount parameter
10
-
11
- * 0.4.0
12
- Default setting for preserve_recipients no longer defaults to true. Bumping a minor
13
- version since this might have been assumed to be default and not set by some.
14
-
15
- * 0.3.8
16
- Change log created