mandrill_mailer 1.4.0 → 1.8.0

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
- SHA1:
3
- metadata.gz: f49c59c5f497b38f55180880f6f32101ab993cf1
4
- data.tar.gz: 041619bafe686899e7f6e63fa4f0aa8b41960ab8
2
+ SHA256:
3
+ metadata.gz: 440fbc8df529fb6d5818f2a4dc241d23dcabbfc70dc42416145ac587546ac2b5
4
+ data.tar.gz: 5fd3ce65fd871a8990a4e9a566a513d9b1783771a72d29bdffcbb0eeecd783e9
5
5
  SHA512:
6
- metadata.gz: e6c7baeff76a0fefb88d27af5452348e52676c28da4c5557a1a3b153f669153231a0118bf058b6c8f4bf0640576ef175c4618def99e2ed1d459b977dfddb81f5
7
- data.tar.gz: 42092ee4de2138c8d416dc6d16c9c31ebe98791f85b5aa7ce8dadcb1457ba86927e98f066bd59992cdc343dd39f2258489f55682551a5eab6825c35d43f69c79
6
+ metadata.gz: a5688e873e80045743da3b417cf5c4d21d877cf8d8c7c32840fb0b9a9e3249638e80a03fc6e2d2b8599b36f959105f8f94825ba8c8530900f999ff53b575898a
7
+ data.tar.gz: 46dd668deff79e85426447c26049fd77408708abdd658da273bb11a10c8e60622bee3fd6cf536f7972918597e0a0805cd5aa2c8b9df24744a2a77e38f9774412
@@ -0,0 +1,28 @@
1
+ name: build
2
+ on: [push, pull_request]
3
+ jobs:
4
+ build:
5
+ runs-on: ubuntu-latest
6
+ strategy:
7
+ matrix:
8
+ os: [ubuntu]
9
+ ruby:
10
+ - 2.0
11
+ - 2.1
12
+ - 2.2
13
+ - 2.3
14
+ - 2.4
15
+ - 2.5
16
+ - 2.6
17
+ - 2.7
18
+ - 3.0
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ bundler-cache: true
25
+ - name: "bundle install"
26
+ run: bundle install --jobs 4 --retry 3
27
+ - name: "rspec"
28
+ run: bundle exec rspec spec/
data/.travis.yml CHANGED
@@ -2,9 +2,14 @@ language: ruby
2
2
  sudo: false
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.0.0-p598
5
+ - 2.0.0-p648
6
6
  - 2.1.0
7
7
  - 2.2.0
8
+ - 2.3.8
9
+ - 2.4.5
10
+ - 2.5.3
11
+ - 2.6.1
12
+ - 2.7.1
8
13
 
9
14
  script:
10
15
  - bundle exec rspec spec/
data/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ # Unreleased
6
+
7
+ ## 1.8.0 - 2021-03-18
8
+ - Support Ruby 3.0.0 [#142](https://github.com/renz45/mandrill_mailer/pull/142) (via @berkos)
9
+ - Allow symbols in vars [#140](https://github.com/renz45/mandrill_mailer/pull/140) (via @raphaelpra)
10
+
11
+ ## 1.7.1 - 2018-10-06
12
+ - Fix rspec matcher: https://github.com/renz45/mandrill_mailer/pull/136
13
+
14
+ ## 1.7.0 - 2018-10-06
15
+ - Switch to mandrillus fork of the mandrill-api gem to allow for newer
16
+ json gem support
17
+
18
+ ## 1.6.0 - 2017-03-23
19
+ - Add support for attaching unencoded content via @brunomperes
20
+
21
+ ## 1.5.0 - 2017-03-20
22
+ - Update offline adapter for testing to be more compatible with Rails 5 via @eric1234
23
+
5
24
  ## 1.4.0 - 2016-04-28
6
25
  ### Changed
7
26
  - Update deprecated RSpec failure methods in RSpec helpers.
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Mandrill Mailer
2
- [![Build Status](https://travis-ci.org/renz45/mandrill_mailer.svg)](https://travis-ci.org/renz45/mandrill_mailer) [![Gem Version](http://img.shields.io/gem/v/mandrill_mailer.svg)](https://rubygems.org/gems/mandrill_mailer)
3
- [![Code Climate](http://img.shields.io/codeclimate/github/renz45/mandrill_mailer.svg)](https://codeclimate.com/github/renz45/mandrill_mailer)
4
- [![Dependencies](http://img.shields.io/gemnasium/renz45/mandrill_mailer.svg)](https://gemnasium.com/renz45/mandrill_mailer) [![Inline Documentation](http://inch-ci.org/github/renz45/mandrill_mailer.svg?branch=master)](http://inch-ci.org/github/renz45/mandrill_mailer)
2
+ [![Build Status](https://img.shields.io/github/workflow/status/renz45/mandrill_mailer/build.svg)](https://github.com/renz45/mandrill_mailer/actions/workflows/tests.yml) [![Gem Version](http://img.shields.io/gem/v/mandrill_mailer.svg)](https://rubygems.org/gems/mandrill_mailer)
3
+ [![Inline Documentation](http://inch-ci.org/github/renz45/mandrill_mailer.svg?branch=master)](http://inch-ci.org/github/renz45/mandrill_mailer)
5
4
 
6
5
  Inherit the MandrillMailer class in your existing Rails mailers to send transactional emails through Mandrill using their template-based emails.
7
6
 
@@ -153,11 +152,13 @@ end
153
152
 
154
153
  * `:attachments` - An array of file objects with the following keys:
155
154
  * `content`: The file contents, this will be encoded into a base64 string internally
155
+ * `encoded_content` (optional): File content already encoded into base64 string. Overrides `content`
156
156
  * `name`: The name of the file
157
157
  * `type`: This is the mimetype of the file. Ex. png = image/png, pdf = application/pdf, txt = text/plain etc etc
158
158
 
159
159
  * `:images` - An array of embedded images to add to the message:
160
160
  * `content`: The file contents, this will be encoded into a base64 string internally
161
+ * `encoded_content` (optional): File content already encoded into base64 string. Overrides `content`
161
162
  * `name`: The name of the file
162
163
  * `type`: This is the mimetype of the file. Ex. png = image/png, pdf = application/pdf, txt = text/plain etc etc etc
163
164
 
@@ -220,7 +221,7 @@ You can send the email by using the familiar syntax:
220
221
 
221
222
  `InvitationMailer.invite(invitation).deliver_now`
222
223
  `InvitationMailer.invite(invitation).deliver_later(wait: 1.hour)`
223
- For deliver_later, Active Job will need to be configured
224
+ For deliver_later, Active Job will need to be configured
224
225
 
225
226
  ## Creating a test method
226
227
  When switching over to Mandrill for transactional emails we found that it was hard to setup a mailer in the console to send test emails easily (those darn designers), but really, you don't want to have to setup test objects everytime you want to send a test email. You can set up a testing 'mock' once and then call the `.test` method to send the test email.
@@ -270,7 +271,7 @@ require 'mandrill_mailer/offline'
270
271
  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:
271
272
 
272
273
  ```ruby
273
- email = MandrillMailer::deliveries.detect { |mail|
274
+ email = MandrillMailer.deliveries.detect { |mail|
274
275
  mail.template_name == 'my-template' &&
275
276
  mail.message['to'].any? { |to| to[:email] == 'my@email.com' }
276
277
  }
@@ -284,7 +285,7 @@ before :each { MandrillMailer.deliveries.clear }
284
285
  ```
285
286
 
286
287
  ## Using Delayed Job
287
- 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:
288
+ The typical Delayed Job mailer syntax won't work with this as of now. Either create a custom job or queue the mailer as you would queue a method. Take a look at the following examples:
288
289
 
289
290
  ```ruby
290
291
  def send_hallpass_expired_mailer
@@ -369,11 +370,11 @@ Example that adds multiple bcc recipients:
369
370
  MandrillMailer.configure do |config|
370
371
  config.interceptor = Proc.new {|params|
371
372
 
372
- params[:to] = [
373
- params[:to],
374
- { email: "bccEmailThatWillBeUsedInAll@emailsSent1.com", name: "name", type: "bcc" },
375
- { email: "bccEmailThatWillBeUsedInAll@emailsSent2.com", name: "name", type: "bcc" },
376
- { email: "bccEmailThatWillBeUsedInAll@emailsSent3.com", name: "name", type: "bcc" }
373
+ params["to"] = [
374
+ params["to"],
375
+ { "email" => "bccEmailThatWillBeUsedInAll@emailsSent1.com", "name" => "name", "type" => "bcc" },
376
+ { "email" => "bccEmailThatWillBeUsedInAll@emailsSent2.com", "name" => "name", "type" => "bcc" },
377
+ { "email" => "bccEmailThatWillBeUsedInAll@emailsSent3.com", "name" => "name", "type" => "bcc" }
377
378
  ].flatten
378
379
  }
379
380
  end
@@ -11,7 +11,9 @@ module MandrillMailer
11
11
  type = attachment[:mimetype] || attachment[:type]
12
12
  name = attachment[:filename] || attachment[:name]
13
13
  file = attachment[:file] || attachment[:content]
14
- {"type" => type, "name" => name, "content" => Base64.encode64(file)}
14
+ encoded_file = attachment[:encoded_file] || attachment[:encoded_content]
15
+ next {"type" => type, "name" => name, "content" => encoded_file} if encoded_file
16
+ next {"type" => type, "name" => name, "content" => Base64.encode64(file)}
15
17
  end
16
18
  end
17
19
 
@@ -23,7 +25,7 @@ module MandrillMailer
23
25
  # convert a normal hash into the format mandrill needs
24
26
  def self.mandrill_args(args)
25
27
  return [] unless args
26
- args.map do |k,v|
28
+ args.stringify_keys.map do |k,v|
27
29
  {'name' => k, 'content' => v}
28
30
  end
29
31
  end
@@ -290,11 +290,16 @@ module MandrillMailer
290
290
  end
291
291
 
292
292
  # Makes this class act as a singleton without it actually being a singleton
293
- # This keeps the syntax the same as the orginal mailers so we can swap quickly if something
293
+ # This keeps the syntax the same as the original mailers so we can swap quickly if something
294
294
  # goes wrong.
295
- def self.method_missing(method, *args)
296
- return super unless respond_to?(method)
297
- new.method(method).call(*args)
295
+
296
+ class << self
297
+ def method_missing(method, *args, &block)
298
+ return super unless respond_to?(method)
299
+ new.method(method).call(*args, &block)
300
+ end
301
+
302
+ ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
298
303
  end
299
304
 
300
305
  def self.respond_to?(method, include_private = false)
@@ -26,10 +26,6 @@ module MandrillMailer
26
26
  end
27
27
 
28
28
  class TemplateMailer
29
- def deliver
30
- deliver_now
31
- end
32
-
33
29
  def deliver_now
34
30
  MandrillMailer::Mock.new({
35
31
  :template_name => template_name,
@@ -42,24 +38,9 @@ module MandrillMailer
42
38
  MandrillMailer.deliveries << mock
43
39
  end
44
40
  end
45
- def deliver_later
46
- MandrillMailer::Mock.new({
47
- :template_name => template_name,
48
- :template_content => template_content,
49
- :message => message,
50
- :async => async,
51
- :ip_pool => ip_pool,
52
- :send_at => send_at
53
- }).tap do |mock|
54
- MandrillMailer.deliveries << mock
55
- end
56
- end
57
41
  end
58
42
 
59
43
  class MessageMailer
60
- def deliver
61
- deliver_now
62
- end
63
44
  def deliver_now
64
45
  MandrillMailer::Mock.new({
65
46
  :message => message,
@@ -70,15 +51,5 @@ module MandrillMailer
70
51
  MandrillMailer.deliveries << mock
71
52
  end
72
53
  end
73
- def deliver_later
74
- MandrillMailer::Mock.new({
75
- :message => message,
76
- :async => async,
77
- :ip_pool => ip_pool,
78
- :send_at => send_at
79
- }).tap do |mock|
80
- MandrillMailer.deliveries << mock
81
- end
82
- end
83
54
  end
84
55
  end
@@ -30,7 +30,7 @@ RSpec::Matchers.define :have_merge_data do |expected_data|
30
30
  MESSAGE
31
31
  end
32
32
 
33
- failure_message do |actual|
33
+ failure_message_when_negated do |actual|
34
34
  <<-MESSAGE.strip_heredoc
35
35
  Expected merge variables: #{merge_vars_from(actual).inspect} to not include data: #{expected_data.inspect} but it does.
36
36
  MESSAGE
@@ -1,3 +1,3 @@
1
1
  module MandrillMailer
2
- VERSION = "1.4.0"
2
+ VERSION = "1.8.0"
3
3
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = MandrillMailer::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Adam Rensel"]
10
- s.email = ["adamrensel@codeschool.com"]
10
+ s.email = ["adamrensel@gmail.com"]
11
11
  s.homepage = "https://github.com/renz45/mandrill_mailer"
12
12
  s.summary = %q{Transactional Mailer for Mandrill}
13
13
  s.description = %q{Transactional Mailer for Mandrill}
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'activesupport'
22
22
  s.add_dependency 'actionpack'
23
23
  s.add_dependency 'activejob'
24
- s.add_runtime_dependency 'mandrill-api', '~> 1.0.9'
24
+ s.add_runtime_dependency 'mandrillus', '~> 2.0.0'
25
25
 
26
26
  s.add_development_dependency 'pry'
27
27
  s.add_development_dependency 'rspec'
@@ -10,6 +10,13 @@ describe MandrillMailer::ArgFormatter do
10
10
  content: "testing some test test file"
11
11
  }
12
12
  end
13
+ let(:encoded_api_args) do
14
+ {
15
+ type: "some/type",
16
+ name: 'test',
17
+ encoded_content: Base64.encode64("testing some test test file")
18
+ }
19
+ end
13
20
 
14
21
  let(:file_args) do
15
22
  {
@@ -18,6 +25,13 @@ describe MandrillMailer::ArgFormatter do
18
25
  file: "testing some test test file"
19
26
  }
20
27
  end
28
+ let(:encoded_file_args) do
29
+ {
30
+ mimetype: "some/type",
31
+ filename: 'test',
32
+ encoded_file: Base64.encode64("testing some test test file")
33
+ }
34
+ end
21
35
 
22
36
 
23
37
  describe 'attachment_args' do
@@ -35,6 +49,16 @@ describe MandrillMailer::ArgFormatter do
35
49
  'content' => Base64.encode64("testing some test test file")
36
50
  }])
37
51
  end
52
+
53
+ describe "passing an encoded string" do
54
+ it "formats the correct attachment data" do
55
+ expect(formatter.attachment_args([encoded_file_args])).to eq([{
56
+ 'type' => "some/type",
57
+ 'name' => 'test',
58
+ 'content' => Base64.encode64("testing some test test file")
59
+ }])
60
+ end
61
+ end
38
62
  end
39
63
 
40
64
  context "with api syntax" do
@@ -45,6 +69,16 @@ describe MandrillMailer::ArgFormatter do
45
69
  'content' => Base64.encode64("testing some test test file")
46
70
  }])
47
71
  end
72
+
73
+ describe "passing an encoded string" do
74
+ it "formats the correct attachment data" do
75
+ expect(formatter.attachment_args([encoded_api_args])).to eq([{
76
+ 'type' => "some/type",
77
+ 'name' => 'test',
78
+ 'content' => Base64.encode64("testing some test test file")
79
+ }])
80
+ end
81
+ end
48
82
  end
49
83
  end
50
84
 
@@ -233,4 +267,4 @@ describe MandrillMailer::ArgFormatter do
233
267
  end
234
268
  end
235
269
  end
236
- end
270
+ end
@@ -121,7 +121,7 @@ describe MandrillMailer::CoreMailer do
121
121
  expect(new_unique_mailer.message['from_email']).to eq default_from_email
122
122
  expect(new_unique_mailer.message['view_content_link']).to eq default_view_content_link
123
123
 
124
- global_merge_vars = [{ "name" => :foo, "content" => "bar" }]
124
+ global_merge_vars = [{ "name" => "foo", "content" => "bar" }]
125
125
  expect(new_unique_mailer.message['global_merge_vars']).to eq global_merge_vars
126
126
  end
127
127
 
@@ -179,7 +179,7 @@ describe MandrillMailer::CoreMailer do
179
179
 
180
180
  context 'Rails is not defined' do
181
181
  it 'should raise an exception' do
182
- expect{subject}.to raise_error
182
+ expect{subject}.to raise_error NoMethodError
183
183
  end
184
184
  end
185
185
  end
@@ -212,7 +212,7 @@ describe MandrillMailer::CoreMailer do
212
212
 
213
213
  context 'Rails does not exist' do
214
214
  it 'should raise exception' do
215
- expect{ subject }.to raise_error
215
+ expect{ subject }.to raise_error NoMethodError
216
216
  end
217
217
  end
218
218
  end
data/spec/spec_helper.rb CHANGED
@@ -8,6 +8,9 @@ require 'pry'
8
8
  # in ./support/ and its subdirectories.
9
9
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
10
10
 
11
+ ActiveJob::Base.queue_adapter = :inline
12
+ ActiveJob::Base.logger.level = Logger::WARN
13
+
11
14
  RSpec.configure do |config|
12
15
  config.mock_with :rspec
13
- end
16
+ 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: 1.4.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Rensel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2021-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: mandrill-api
56
+ name: mandrillus
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.0.9
61
+ version: 2.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.0.9
68
+ version: 2.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -96,11 +96,12 @@ dependencies:
96
96
  version: '0'
97
97
  description: Transactional Mailer for Mandrill
98
98
  email:
99
- - adamrensel@codeschool.com
99
+ - adamrensel@gmail.com
100
100
  executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
+ - ".github/workflows/tests.yml"
104
105
  - ".gitignore"
105
106
  - ".rspec"
106
107
  - ".travis.yml"
@@ -137,7 +138,7 @@ homepage: https://github.com/renz45/mandrill_mailer
137
138
  licenses:
138
139
  - MIT
139
140
  metadata: {}
140
- post_install_message:
141
+ post_install_message:
141
142
  rdoc_options: []
142
143
  require_paths:
143
144
  - lib
@@ -152,9 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
153
  - !ruby/object:Gem::Version
153
154
  version: '0'
154
155
  requirements: []
155
- rubyforge_project:
156
- rubygems_version: 2.4.5.1
157
- signing_key:
156
+ rubygems_version: 3.2.3
157
+ signing_key:
158
158
  specification_version: 4
159
159
  summary: Transactional Mailer for Mandrill
160
160
  test_files: