griddler-mandrill 1.0.0 → 1.0.1

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: c2197b9fa59d9e6c1006d3083dd0563653ea5cda
4
- data.tar.gz: 68d153dde2a5762904f4bc445d252f2b46c32a24
3
+ metadata.gz: 7cd7048b321e79882c0e7f57e2d0cc5b64a0c18b
4
+ data.tar.gz: d543a55548ddcadcb6117d60d899fa02c74b5290
5
5
  SHA512:
6
- metadata.gz: 52aa06aaabeb9b813b737c3024f8187c799fd5b050b2c42908e31d6a44c4f1fb702039501047ed36b2abb6d2abb64f6c139a928234a1ebefa1c69c52d64933d6
7
- data.tar.gz: 13979ab10338f143699a488afa39f92ea892e7fc2cc09a65b15a1e85c586798f1bec980c8c1b465c4359dd03c892d40c551a5149e9727dd017605e80ddf5e29d
6
+ metadata.gz: 613a1f438bccfc844e0f71a4a9e084aa1c705ff896b20682c77719b337017f10cc17fc55715506f0c0a04eb143aeeb44899a7736f0aa5907ea0f8c2662d8a737
7
+ data.tar.gz: 467dacb9b6103436c45c578940e27c6cd6b774df9f1a3505445bdfeb17131a79de38750cea67f2790664cc5bd6c57f03be825e2db5c52a44ebf260e7f3a95d17
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 1.0.1
2
+ * Respect Mandrill's base64 flag to determine whether text attachments should be
3
+ base64 decoded. #4 via [bdmac](https://github.com/bdmac)
4
+
5
+ ## 1.0.0
6
+ * Initial extraction of the Mandrill adapter from griddler
@@ -62,7 +62,9 @@ module Griddler
62
62
  def create_tempfile(attachment)
63
63
  filename = attachment[:name]
64
64
  tempfile = Tempfile.new(filename, Dir::tmpdir, encoding: 'ascii-8bit')
65
- tempfile.write(Base64.decode64(attachment[:content]))
65
+ content = attachment[:content]
66
+ content = Base64.decode64(content) if attachment[:base64]
67
+ tempfile.write(content)
66
68
  tempfile.rewind
67
69
  tempfile
68
70
  end
@@ -1,5 +1,5 @@
1
1
  module Griddler
2
2
  module Mandrill
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
5
5
  end
@@ -44,6 +44,17 @@ describe Griddler::Mandrill::Adapter, '.normalize_params' do
44
44
  expect(normalized_params[0][:attachments]).to be_empty
45
45
  end
46
46
 
47
+ it 'works with non-base64 encoded files' do
48
+ params = params_with_csv_attachment
49
+
50
+ normalized_params = Griddler::Mandrill::Adapter.normalize_params(params)
51
+
52
+ file, = *normalized_params[0][:attachments]
53
+
54
+ expect(file.original_filename).to eq('file.csv')
55
+ expect(file.size).to eq(upload_3_params[:length])
56
+ end
57
+
47
58
  describe 'when the email has no text part' do
48
59
  before do
49
60
  @params = params_hash
@@ -135,6 +146,14 @@ describe Griddler::Mandrill::Adapter, '.normalize_params' do
135
146
  mandrill_events params.to_json
136
147
  end
137
148
 
149
+ def params_with_csv_attachment
150
+ params = params_hash
151
+ params[0][:msg][:attachments] = {
152
+ 'file.csv' => upload_3_params
153
+ }
154
+ mandrill_events params.to_json
155
+ end
156
+
138
157
  def text_body
139
158
  <<-EOS.strip_heredoc.strip
140
159
  Dear bob
@@ -163,7 +182,8 @@ describe Griddler::Mandrill::Adapter, '.normalize_params' do
163
182
  name: 'photo1.jpg',
164
183
  content: Base64.encode64(file.read),
165
184
  type: 'image/jpeg',
166
- length: size
185
+ length: size,
186
+ base64: true
167
187
  }
168
188
  end
169
189
  end
@@ -176,7 +196,21 @@ describe Griddler::Mandrill::Adapter, '.normalize_params' do
176
196
  name: 'photo2.jpg',
177
197
  content: Base64.encode64(file.read),
178
198
  type: 'image/jpeg',
179
- length: size
199
+ length: size,
200
+ base64: true
201
+ }
202
+ end
203
+ end
204
+
205
+ def upload_3_params
206
+ @upload_2_params ||= begin
207
+ content = 'Some | csv | file | here'
208
+ {
209
+ name: 'file.csv',
210
+ content: content,
211
+ type: 'text/plain',
212
+ length: content.length,
213
+ base64: false
180
214
  }
181
215
  end
182
216
  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.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stafford Brunk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-30 00:00:00.000000000 Z
11
+ date: 2014-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: griddler
@@ -76,6 +76,7 @@ files:
76
76
  - ".gitignore"
77
77
  - ".rspec"
78
78
  - ".travis.yml"
79
+ - CHANGELOG.md
79
80
  - CONTRIBUTING.md
80
81
  - Gemfile
81
82
  - LICENSE.txt