griddler-mandrill 1.1.3 → 1.1.4

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: 11fa381ea4f4b1865823cf93565cbbaa98ed5f40
4
- data.tar.gz: f1810eaf5c1295420f384a2647371bf493b75d87
3
+ metadata.gz: e54f49517c557c787003b280e2fae8b99d6aec51
4
+ data.tar.gz: 34c8d7d4b71c7f1ce1b4e1136a51affb7e7a148f
5
5
  SHA512:
6
- metadata.gz: 41142c12a3bfc6034c850e3503424ea7c911bccd5c43d74875d2f955a8d0507059365f0824df0c8907d8c16f74336aef42050f584f8354016bf7bc25b73eff0a
7
- data.tar.gz: 00d30dc2c0c3a05699df71924d75272871eee113f23d19afa575279c666195a9f33bea2503ead1a3fba471008473686a6e3021e4201c1eba0ab8561489e7e19c
6
+ metadata.gz: 7b722cc50ee0fca025414fffadc6c2d240bd464a7bf237d168d903efbb281f8855a78eeb209ebb16d7076b787a804408548433d4b13904579726103239164fbf
7
+ data.tar.gz: 75a760631eb0439407fdf10cbbadfc8b69fd29ddeb2f3ff366d2f0565a3f85271ab9cf293238db81ed7c3f5e286e78e7837fcbaf57b147835e5ea0a64a0dd2e9
@@ -1,5 +1,9 @@
1
1
  ## master
2
2
 
3
+ ## 1.1.4
4
+ * Add support for inline images. #27 and #29 [MicTech](https://github.com/MicTech)
5
+ * Do not map non-existant to to bcc. #24
6
+
3
7
  ## 1.1.3
4
8
  * Protect against SPF spoofing. #22 via [arunthampi](https://github.com/arunthampi)
5
9
 
@@ -46,11 +46,8 @@ module Griddler
46
46
 
47
47
  def resolve_bcc(event)
48
48
  email = event[:email]
49
- if !event[:to].map(&:first).include?(email) && event[:cc] && !event[:cc].map(&:first).include?(email)
50
- [full_email([email, email.split("@")[0]])]
51
- else
52
- []
53
- end
49
+ to_and_cc = (event[:to].to_a + event[:cc].to_a).compact.map(&:first)
50
+ to_and_cc.include?(email) ? [] : [full_email([email, email.split("@")[0]])]
54
51
  end
55
52
 
56
53
  def full_email(contact_info)
@@ -63,12 +60,19 @@ module Griddler
63
60
  end
64
61
 
65
62
  def attachment_files(event)
66
- attachments = event[:attachments] || Array.new
67
- attachments.map do |key, attachment|
63
+ files(event, :attachments) + files(event, :images)
64
+ end
65
+
66
+ def files(event, key)
67
+ files = event[key] || Hash.new
68
+
69
+ files.map do |key, file|
70
+ file[:base64] = true if !file.has_key?(:base64)
71
+
68
72
  ActionDispatch::Http::UploadedFile.new({
69
- filename: attachment[:name],
70
- type: attachment[:type],
71
- tempfile: create_tempfile(attachment)
73
+ filename: file[:name],
74
+ type: file[:type],
75
+ tempfile: create_tempfile(file)
72
76
  })
73
77
  end
74
78
  end
@@ -1,5 +1,5 @@
1
1
  module Griddler
2
2
  module Mandrill
3
- VERSION = '1.1.3'
3
+ VERSION = '1.1.4'
4
4
  end
5
5
  end
@@ -74,6 +74,20 @@ describe Griddler::Mandrill::Adapter, '.normalize_params' do
74
74
  expect{adapter.normalize_params}.to_not raise_error
75
75
  end
76
76
 
77
+ it 'works with inline images' do
78
+ params = params_with_inline_images
79
+
80
+ normalized_params = Griddler::Mandrill::Adapter.normalize_params(params)
81
+
82
+ first, second = *normalized_params[0][:attachments]
83
+
84
+ expect(first.original_filename).to eq('ii_111ecfcf901e123c')
85
+ expect(first.size).to eq(upload_6_params[:length])
86
+
87
+ expect(second.original_filename).to eq('ii_151ecfcf901e828c')
88
+ expect(second.size).to eq(upload_7_params[:length])
89
+ end
90
+
77
91
  describe 'when the email has no text part' do
78
92
  before do
79
93
  @params = params_hash
@@ -315,6 +329,15 @@ describe Griddler::Mandrill::Adapter, '.normalize_params' do
315
329
  mandrill_events params.to_json
316
330
  end
317
331
 
332
+ def params_with_inline_images
333
+ params = params_hash
334
+ params[0][:msg][:images] = {
335
+ 'ii_151ecfcf901e828c' => upload_6_params,
336
+ 'ii_111ecfcf901e123c' => upload_7_params
337
+ }
338
+ mandrill_events params.to_json
339
+ end
340
+
318
341
  def text_body
319
342
  <<-EOS.strip_heredoc.strip
320
343
  Dear bob
@@ -400,4 +423,31 @@ describe Griddler::Mandrill::Adapter, '.normalize_params' do
400
423
  }
401
424
  end
402
425
  end
426
+
427
+ def upload_6_params
428
+ @upload_6_params ||= begin
429
+ file = upload_1
430
+ size = file.size
431
+ {
432
+ name: 'ii_111ecfcf901e123c',
433
+ content: Base64.encode64(file.read),
434
+ type: 'image/jpeg',
435
+ length: size
436
+ }
437
+ end
438
+ end
439
+
440
+ def upload_7_params
441
+ @upload_7_params ||= begin
442
+ file = upload_2
443
+ size = file.size
444
+ {
445
+ name: 'ii_151ecfcf901e828c',
446
+ content: Base64.encode64(file.read),
447
+ type: 'image/jpeg',
448
+ length: size
449
+ }
450
+ end
451
+ end
452
+
403
453
  end
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.3
4
+ version: 1.1.4
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-08-19 00:00:00.000000000 Z
11
+ date: 2016-06-18 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.5
112
+ rubygems_version: 2.5.1
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Mandrill adapter for Griddler