mandrill_mailer 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bfa455214d0fad5180b76450327ac30b7ffcc74
4
- data.tar.gz: aaa9f37d06d8c32a1d3bb0ba33490c7ce4e3b36d
3
+ metadata.gz: 066d9d8a41e15e942635771fdef695a54a71a667
4
+ data.tar.gz: c1dddaf88be75ed2ddab9165767145aace80dc1b
5
5
  SHA512:
6
- metadata.gz: 3f5580807bc7f7a0c13c6bcdc8749719e7b638e141253025b93b7fb3fc33dfe5735bf5f80f1bef647b5530f971647a80f133bb054d620e84b615b727eb9b76b1
7
- data.tar.gz: 6dad0436a16f92014ac77929794d5e075a547be5ce19696f8a460e97af2589a34338a3b8c3c3f0e68c164ee2eeda95533e52eb54f42920a2db7a88d712e92a5d
6
+ metadata.gz: 768bfe2d37ea0b516bead42c089ffdb5d2a077bb8e0300a5e721f8ec656f1fc9717e068877e5b6d5c190c2b73e6c09fdea9e67a74b47f8a2332e74a77ac8a05e
7
+ data.tar.gz: df0ea1de244c30e78cb3b5c8de329c2f8bc017abb01e56369dab9c7c715a280a8da9d4ada95f1538d2b8d4bcad9455868cfb07ed48cd165f3429e98d9af85e52
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Mandrill Mailer gem
2
- MandrilMailer class for sending transactional emails through mandril.
2
+ MandrillMailer class for sending transactional emails through Mandrill.
3
3
  Only template based emails are supported at this time.
4
4
 
5
5
  ## Usage
@@ -10,7 +10,7 @@ You don't need to add the ActionMailer stuff unless your still using ActionMaile
10
10
  This just plugs into the Mandrill smtp servers. If your doing template based emails
11
11
  through the Mandrill api you really only need the `MandrillMailer.configure` part
12
12
 
13
- ```
13
+ ```ruby
14
14
  ActionMailer::Base.smtp_settings = {
15
15
  :address => "smtp.mandrillapp.com",
16
16
  :port => 587,
@@ -35,31 +35,31 @@ in your environment config files:
35
35
  ## Creating a new mailer
36
36
  Creating a new Mandrill Mailer is similar to a normal Rails mailer:
37
37
 
38
- ```
39
- class InvitationMailer < MandrillMailer::TemplateMailer
40
- default from: 'support@example.com'
41
-
42
- def invite(invitation)
43
- mandrill_mail template: 'Group Invite',
44
- subject: I18n.t('invitation_mailer.invite.subject'),
45
- to: invitation.invitees.map {|invitee| { email: invitee.email, name: invitee.name }},
46
- # to: {email: invitation.email, name: 'Honored Guest'},
47
- vars: {
48
- 'OWNER_NAME' => invitation.owner_name,
49
- 'PROJECT_NAME' => invitation.project_name
50
- },
51
- important: true,
52
- inline_css: true,
53
- recipient_vars: invitation.invitees.map do |invitee| # invitation.invitees is an Array ,
54
- { invitee.email =>
55
- {
56
- 'INVITEE_NAME' => invitee.name,
57
- 'INVITATION_URL' => new_invitation_url(invitee.email, secret: invitee.secret_code)
58
- }
59
- }
60
- end
61
- end
62
- end
38
+ ```ruby
39
+ class InvitationMailer < MandrillMailer::TemplateMailer
40
+ default from: 'support@example.com'
41
+
42
+ def invite(invitation)
43
+ mandrill_mail template: 'Group Invite',
44
+ subject: I18n.t('invitation_mailer.invite.subject'),
45
+ to: invitation.invitees.map {|invitee| { email: invitee.email, name: invitee.name }},
46
+ # to: {email: invitation.email, name: 'Honored Guest'},
47
+ vars: {
48
+ 'OWNER_NAME' => invitation.owner_name,
49
+ 'PROJECT_NAME' => invitation.project_name
50
+ },
51
+ important: true,
52
+ inline_css: true,
53
+ recipient_vars: invitation.invitees.map do |invitee| # invitation.invitees is an Array
54
+ { invitee.email =>
55
+ {
56
+ 'INVITEE_NAME' => invitee.name,
57
+ 'INVITATION_URL' => new_invitation_url(invitee.email, secret: invitee.secret_code)
58
+ }
59
+ }
60
+ end
61
+ end
62
+ end
63
63
  ```
64
64
 
65
65
  * `#default:`
@@ -133,7 +133,7 @@ You can test the above email by typing: `InvitationMailer.test(:invite, email:<y
133
133
 
134
134
  The test for this particular Mailer is setup like so:
135
135
 
136
- ```
136
+ ```ruby
137
137
  test_setup_for :invite do |mailer, options|
138
138
  invitation = MandrillMailer::Mock.new({
139
139
  email: options[:email],
@@ -150,7 +150,7 @@ If in order to represent a url within a mock, make sure there is a `url` or `pat
150
150
  for example, if I had a course mock and I was using the `course_url` route helper within the mailer
151
151
  I would create the mock like so:
152
152
 
153
- ```
153
+ ```ruby
154
154
  course = MandrillMailer::Mock.new({
155
155
  title: 'zombies',
156
156
  type: 'Ruby',
@@ -164,6 +164,29 @@ The mailer and options passed to the `.test` method are yielded to the block.
164
164
 
165
165
  The `:email` option is the only required option, make sure to add at least this to your test object.
166
166
 
167
+ ## Offline Testing
168
+ You can turn on offline testing by requiring this file (say, in your spec_helper.rb):
169
+
170
+ ```ruby
171
+ require 'mandrill_mailer/offline'
172
+ ```
173
+
174
+ And then if you wish you can look at the contents of `MandrillMailer.deliveries` to see whether an email was queued up by your test:
175
+
176
+ ```ruby
177
+ email = MandrillMailer::deliveries.detect { |mail|
178
+ mail.template_name == 'my-template' &&
179
+ mail.message['to'].any? { |to| to['email'] == 'my@email.com' }
180
+ }
181
+ expect(email).to_not be_nil
182
+ ```
183
+
184
+ Don't forget to clear out deliveries:
185
+
186
+ ```ruby
187
+ before :each { MandrillMailer.deliveries.clear }
188
+ ```
189
+
167
190
  ## Using Delayed Job
168
191
  The typical Delayed Job mailer syntax won't work with this as of now. Either create a custom job or que the mailer as you would que a method. Take a look at the following examples:
169
192
 
data/change_log.md CHANGED
@@ -1,3 +1,6 @@
1
+ * 0.4.3
2
+ Add the ability to look at deliveries for offline testing.
3
+
1
4
  * 0.4.2
2
5
  Add the ability to intercept emails before they are sent in the config
3
6
  see the specs for more info
@@ -0,0 +1,40 @@
1
+ # Offline modifications for using MandrillMailer without actually sending
2
+ # emails through Mandrill's API. Particularly useful for acceptance tests.
3
+ #
4
+ # To use, just require this file (say, in your spec_helper.rb):
5
+ #
6
+ # require 'mandrill_mailer/offline'
7
+ #
8
+ # And then if you wish you can look at the contents of
9
+ # MandrillMailer.deliveries to see whether an email was queued up by your test:
10
+ #
11
+ # email = MandrillMailer::deliveries.detect { |mail|
12
+ # mail.template_name == 'my-template' &&
13
+ # mail.message['to'].any? { |to| to['email'] == 'my@email.com' }
14
+ # }
15
+ # expect(email).to_not be_nil
16
+ #
17
+ # Don't forget to clear out deliveries:
18
+ #
19
+ # before :each { MandrillMailer.deliveries.clear }
20
+ #
21
+ require 'mandrill_mailer'
22
+
23
+ module MandrillMailer
24
+ def self.deliveries
25
+ @deliveries ||= []
26
+ end
27
+
28
+ class TemplateMailer
29
+ def deliver
30
+ MandrillMailer.deliveries << MandrillMailer::Mock.new({
31
+ :template_name => template_name,
32
+ :template_content => template_content,
33
+ :message => message,
34
+ :async => async,
35
+ :ip_pool => ip_pool,
36
+ :send_at => send_at
37
+ })
38
+ end
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  module MandrillMailer
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mandrill_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
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-13 00:00:00.000000000 Z
11
+ date: 2013-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -94,6 +94,7 @@ files:
94
94
  - change_log.md
95
95
  - lib/mandrill_mailer.rb
96
96
  - lib/mandrill_mailer/mock.rb
97
+ - lib/mandrill_mailer/offline.rb
97
98
  - lib/mandrill_mailer/railtie.rb
98
99
  - lib/mandrill_mailer/template_mailer.rb
99
100
  - lib/mandrill_mailer/version.rb