griddler-mandrill 1.1.1 → 1.1.2

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,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 986e391f3565a7f5189859a92a3c939b69c0c6e2
4
- data.tar.gz: 8f4c5abcec2a7b26503f101bac709bb32ca918eb
3
+ metadata.gz: 86dc4de8f452cac033829217d59a4c6bc9f773b9
4
+ data.tar.gz: dce4fb18f34941f751aba6f71a6de09088cdfa83
5
5
  SHA512:
6
- metadata.gz: 22c435ceb3b901cb4f5c867150dd8f7352292a67eb3c65c6de005cd99f34ffe9a94f9ea8c6f6c56176cc204e8bb4d43c23ac2a8412ff77c00be64bb656885879
7
- data.tar.gz: 05073ddb3cbd1c4513174979e4ce5b318badc2a67362b1dd18c96044704059c927d4cdeecbd498afc793046e632a0379fa16ac251d638c987d7c61814450c024
6
+ metadata.gz: 9b6f95562127f589899a0074386cde554ca8ab3357698504fa633106a25bde17f7eb4743c9011a0ff92f5166fc4f78133b3dfeea6d4cf0218ec5348f6ddd8757
7
+ data.tar.gz: a42ada7733a4480f76f56cc3144632428d937ffdbb53558a0d3e5cdf02a4758166b5756a691bbe600bd9b10ccc829a74d7f1da6f3242012de73e9d0d429546da
data/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
- ## 1.0.3 (master)
1
+ ## master
2
+
3
+ ## 1.1.2
4
+ * Use Mandrill's `email` attribute to populate bcc if to and cc don't contain it. #19 and #20 via [Uelb](https://github.com/Uelb)
5
+
6
+ ## 1.1.1
7
+ * Pin minimum Griddler version to >= 1.2.1 to resolve #18
8
+
9
+ ## 1.1.0
10
+ * Allow email headers to be accessed. #12, #13, #14, and #17
2
11
  * Replace `nil` for email text/html values with empty strings. #10 via [calleerlandsson](https://github.com/calleerlandsson)
3
12
 
4
13
  ## 1.0.2
@@ -15,14 +15,15 @@ module Griddler
15
15
  {
16
16
  to: recipients(:to, event),
17
17
  cc: recipients(:cc, event),
18
- bcc: recipients(:bcc, event),
18
+ bcc: resolve_bcc(event),
19
19
  headers: event[:headers],
20
20
  from: full_email([ event[:from_email], event[:from_name] ]),
21
21
  subject: event[:subject],
22
22
  text: event[:text] || '',
23
23
  html: event[:html] || '',
24
24
  raw_body: event[:raw_msg],
25
- attachments: attachment_files(event)
25
+ attachments: attachment_files(event),
26
+ email: event[:email] # the email address where Mandrill received the message
26
27
  }
27
28
  end
28
29
  end
@@ -41,6 +42,15 @@ module Griddler
41
42
  Array.wrap(event[field]).map { |recipient| full_email(recipient) }
42
43
  end
43
44
 
45
+ def resolve_bcc(event)
46
+ email = event[:email]
47
+ if !event[:to].map(&:first).include?(email) && event[:cc] && !event[:cc].map(&:first).include?(email)
48
+ [full_email([email, email.split("@")[0]])]
49
+ else
50
+ []
51
+ end
52
+ end
53
+
44
54
  def full_email(contact_info)
45
55
  email = contact_info[0]
46
56
  if contact_info[1]
@@ -1,5 +1,5 @@
1
1
  module Griddler
2
2
  module Mandrill
3
- VERSION = '1.1.1'
3
+ VERSION = '1.1.2'
4
4
  end
5
5
  end
@@ -149,6 +149,27 @@ describe Griddler::Mandrill::Adapter, '.normalize_params' do
149
149
  end
150
150
  end
151
151
 
152
+ describe 'when there the reception email is not in the TO nor the CCrecipients' do
153
+ before do
154
+ @params = params_hash
155
+ @params.first[:msg][:email] = "hidden@example.com"
156
+ end
157
+ it 'passes the email as a bcc recipient' do
158
+ params = default_params(@params)
159
+ normalized_params = Griddler::Mandrill::Adapter.normalize_params(params)
160
+ normalized_params.each do |p|
161
+ expect(p[:bcc]).to eq ['hidden <hidden@example.com>']
162
+ end
163
+ end
164
+ it 'passes the email in the email param' do
165
+ params = default_params(@params)
166
+ normalized_params = Griddler::Mandrill::Adapter.normalize_params(params)
167
+ normalized_params.each do |p|
168
+ expect(p[:email]).to eq 'hidden@example.com'
169
+ end
170
+ end
171
+ end
172
+
152
173
  def default_params(params = params_hash)
153
174
  mandrill_events (params * 2).to_json
154
175
  end
@@ -197,7 +218,6 @@ describe Griddler::Mandrill::Adapter, '.normalize_params' do
197
218
  to: [['token@reply.example.com', 'The Token']],
198
219
  cc: [['emily@example.mandrillapp.com', 'Emily'],
199
220
  ['joey@example.mandrillapp.com', 'Joey']],
200
- bcc: [['hidden@example.mandrillapp.com', 'Roger']],
201
221
  subject: "hello",
202
222
  spam_report: {
203
223
  score: -0.8,
@@ -217,7 +237,7 @@ describe Griddler::Mandrill::Adapter, '.normalize_params' do
217
237
  to: ['The Token <token@reply.example.com>'],
218
238
  cc: ['Emily <emily@example.mandrillapp.com>',
219
239
  'Joey <joey@example.mandrillapp.com>'],
220
- bcc: ['Roger <hidden@example.mandrillapp.com>'],
240
+ bcc: [],
221
241
  from: 'Hernan Example <hernan@example.com>',
222
242
  headers: {"X-Mailer" => "Airmail (271)",
223
243
  "Mime-Version" => "1.0",
@@ -225,7 +245,8 @@ describe Griddler::Mandrill::Adapter, '.normalize_params' do
225
245
  subject: 'hello',
226
246
  text: %r{Dear bob},
227
247
  html: %r{<p>Dear bob</p>},
228
- raw_body: %r{raw}
248
+ raw_body: %r{raw},
249
+ email: "token@reply.example.com"
229
250
  }
230
251
  end
231
252
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: griddler-mandrill
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stafford Brunk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: griddler
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.4.8
112
+ rubygems_version: 2.4.5
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Mandrill adapter for Griddler