mail-notify 1.0.3 → 1.1.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
2
  SHA256:
3
- metadata.gz: 7c7e4e16f5be488db0fadd5e7bda04b7225eed92367f509ddf34a8c5bcc34ece
4
- data.tar.gz: 804d693e50559e07ae4c9dd15ba60fe5219dffb7f323f35d5021726152752021
3
+ metadata.gz: c1e5893affa4bb0f98698a2ff745ebec9ff8c637da1d8616a407b1c57820e953
4
+ data.tar.gz: 06e00d14c455fb04ac66802a921d8c2bb3bcb897b3ace8122a78336846d38692
5
5
  SHA512:
6
- metadata.gz: '019defa225ca4c55a8ab208708e4635ef55777f4e8a5d0a7ce1650d2b56271df1dd1595083bb8a1c245ec1578a4fc835c39de3139ad54b249cd183a8ffd55998'
7
- data.tar.gz: ff993d41bcc0b050f3a0874e7d391023dcbfb0abfee33c112334e3d8906909c466300b5f5d12fe490c7ee5d1ee70ca808de744ce46a5fc52618b337d3ad91ec8
6
+ metadata.gz: 7d04bd5e92d40e4c8e6f02ce966941c1692462906ffe24c7e56cdc0a126dfe7b6ad0cbfeb8e240bfeab51dffe5bcddd46de794b979d41004a9cbfd61a96d99f4
7
+ data.tar.gz: efeb7d10d1b43019a1cbb075afebf5197a5a29c22767ac54abdcc8226c46294d020435d334824d93c85c0beb64bdde864afc5df42c9a5d40210f58db082c25b8
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
7
+ - package-ecosystem: "github-actions"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "daily"
@@ -1,6 +1,6 @@
1
1
  #!/bin/bash
2
2
  set -e
3
3
 
4
- mkdir ~/.gem
4
+ mkdir -p ~/.gem
5
5
  echo -e "---\r\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials
6
6
  chmod 0600 ~/.gem/credentials
@@ -8,11 +8,9 @@ jobs:
8
8
  runs-on: ubuntu-latest
9
9
 
10
10
  steps:
11
- - uses: actions/checkout@v1
12
- - name: Set up Ruby 2.6
13
- uses: actions/setup-ruby@v1
14
- with:
15
- ruby-version: 2.6.x
11
+ - uses: actions/checkout@v3
12
+ - name: Set up Ruby
13
+ uses: ruby/setup-ruby@v1
16
14
  - name: Set up cache
17
15
  uses: actions/cache@preview
18
16
  with:
@@ -9,11 +9,9 @@ jobs:
9
9
  build:
10
10
  runs-on: ubuntu-latest
11
11
  steps:
12
- - uses: actions/checkout@v1
13
- - name: Set up Ruby 2.6
14
- uses: actions/setup-ruby@v1
15
- with:
16
- ruby-version: 2.6.x
12
+ - uses: actions/checkout@v3
13
+ - name: Set up Ruby
14
+ uses: ruby/setup-ruby@v1
17
15
  - name: Setup Rubygems
18
16
  env:
19
17
  RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.0
1
+ 2.7.6
data/CHANGELOG.md CHANGED
@@ -6,6 +6,21 @@ The format is based on [Keep a Changelog]
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.1.0] - 2022-09-09
10
+
11
+ - Revert previous Zeitwerk fix
12
+ - Specifically require `rails/mailers_controller` in the Railtie
13
+
14
+ ## [1.0.5] - 2022-08-31
15
+
16
+ - Allow explicitly blank personalisations (https://github.com/dxw/mail-notify/pull/30)
17
+ - Fix Zeitwerk compatibility issue (https://github.com/dxw/mail-notify/pull/58)
18
+ - Dependency updates
19
+
20
+ ## [1.0.4] - 2021-01-28
21
+
22
+ - Remove pessimistic constraint on Rails version
23
+
9
24
  ## [1.0.3] - 2020-12-14
10
25
 
11
26
  - Add support for ActionMailer 6.1
@@ -51,6 +66,8 @@ The format is based on [Keep a Changelog]
51
66
  - Initial release
52
67
 
53
68
  [unreleased]: https://github.com/DFE-Digital/dfe-teachers-payment-service/compare/1.0.3...HEAD
69
+ [1.0.5]: https://github.com/dxw/mail-notify/compare/1.0.4...1.0.5
70
+ [1.0.4]: https://github.com/dxw/mail-notify/compare/1.0.3...1.0.4
54
71
  [1.0.3]: https://github.com/dxw/mail-notify/compare/1.0.2...1.0.3
55
72
  [1.0.2]: https://github.com/dxw/mail-notify/compare/1.0.1...1.0.2
56
73
  [1.0.1]: https://github.com/dxw/mail-notify/compare/1.0...1.0.1
data/README.md CHANGED
@@ -91,6 +91,23 @@ class MyMailer < Mail::Notify::Mailer
91
91
  end
92
92
  ```
93
93
 
94
+ By default, any blank personalisation are removed from the request, which will trigger mail template validation. This is to avoid accidental blanks in the email. If you want to send a blank value, you need to explicitly state that the personalization can be blank:
95
+
96
+ ```ruby
97
+ class MyMailer < Mail::Notify::Mailer
98
+ def send_email
99
+ template_mail('YOUR_TEMPLATE_ID_GOES_HERE',
100
+ to: 'mail@somewhere.com',
101
+ personalisation: {
102
+ foo: foo.name, # This will trigger template validation error when blank
103
+ bar: blank_allowed(bar.name) # This will inject empty string in the template when blank
104
+ }
105
+ )
106
+ end
107
+ end
108
+ ```
109
+
110
+
94
111
  #### With optional Notify arguments
95
112
 
96
113
  It's possible to pass two optional arguments to Notify:
@@ -113,13 +130,34 @@ class MyMailer < Mail::Notify::Mailer
113
130
  end
114
131
  ```
115
132
 
133
+ #### With Devise
134
+
135
+ If you're using [Devise](https://github.com/heartcombo/devise), you can overwrite your Devise mailer to use mail-notify for password reset emails etc.
136
+
137
+ In `config/initializers/devise.rb`:
138
+
139
+ ```ruby
140
+ config.mailer = 'DeviseMailer'
141
+ ```
142
+
143
+ in `app/mailers/devise_mailer.rb`:
144
+
145
+ ```ruby
146
+ class DeviseMailer < Devise::Mailer
147
+ def devise_mail(record, action, opts = {}, &block)
148
+ initialize_from_record(record)
149
+ view_mail(ENV['NOTIFY_TEMPLATE_ID'], headers_for(action, opts))
150
+ end
151
+ end
152
+ ```
153
+
116
154
  ## Previews
117
155
 
118
156
  If you're using ActionMailer with Rails, [previews](https://guides.rubyonrails.org/action_mailer_basics.html#previewing-emails) are supported too, and work in the same way as standard previews. Currently they're shown without any branding, but this may change in future.
119
157
 
120
158
  ## Development
121
159
 
122
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
160
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
123
161
 
124
162
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
125
163
 
@@ -14,6 +14,10 @@ module Mail
14
14
 
15
15
  mail(headers.merge(body: "", subject: "", template_id: template_id))
16
16
  end
17
+
18
+ def blank_allowed(value)
19
+ value.presence || Personalisation::BLANK
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -33,7 +33,7 @@ module Mail
33
33
  end
34
34
 
35
35
  def notify?
36
- @email.delivery_method.class == Mail::Notify::DeliveryMethod
36
+ @email.delivery_method.instance_of?(Mail::Notify::DeliveryMethod)
37
37
  end
38
38
  end
39
39
  end
@@ -3,6 +3,8 @@
3
3
  module Mail
4
4
  module Notify
5
5
  class Personalisation
6
+ BLANK = Object.new
7
+
6
8
  def initialize(mail)
7
9
  @body = mail.body.raw_source
8
10
  @subject = mail.subject
@@ -10,7 +12,9 @@ module Mail
10
12
  end
11
13
 
12
14
  def to_h
13
- merged_options.reject { |_k, v| v.blank? }
15
+ merged_options
16
+ .reject { |_k, v| v.blank? }
17
+ .transform_values { |value| value == BLANK ? "" : value }
14
18
  end
15
19
 
16
20
  private
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "rails/mailers_controller"
4
+
3
5
  module Mail
4
6
  module Notify
5
7
  class Railtie < Rails::Railtie
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mail
4
4
  module Notify
5
- VERSION = "1.0.3"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
data/mail-notify.gemspec CHANGED
@@ -25,18 +25,18 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 2.0"
27
27
  spec.add_development_dependency "coveralls", "~> 0.8.22"
28
- spec.add_development_dependency "pry", "~> 0.12.0"
28
+ spec.add_development_dependency "pry", "~> 0.14.1"
29
29
  spec.add_development_dependency "rails", "~> 6.0"
30
- spec.add_development_dependency "rake", "~> 12.3.3"
31
- spec.add_development_dependency "rspec-rails", "~> 3.8"
32
- spec.add_development_dependency "standard", "0.4.7"
30
+ spec.add_development_dependency "rake", "~> 13.0.6"
31
+ spec.add_development_dependency "rspec-rails", "~> 5.1"
32
+ spec.add_development_dependency "standard", "1.16.1"
33
33
  spec.add_development_dependency "sqlite3", "~> 1.4.1"
34
- spec.add_development_dependency "webmock", "~> 3.7.6"
34
+ spec.add_development_dependency "webmock", "~> 3.18.1"
35
35
 
36
- spec.add_dependency "actionmailer", ">= 5.2.4.2", "< 6.2"
37
- spec.add_dependency "activesupport", ">= 5.2.4.3"
38
- spec.add_dependency "actionpack", ">= 5.2.4.3"
39
- spec.add_dependency "actionview", ">= 5.2.4.3"
36
+ spec.add_dependency "actionmailer", ">= 5.2.4.6"
37
+ spec.add_dependency "activesupport", ">= 5.2.4.6"
38
+ spec.add_dependency "actionpack", ">= 5.2.7.1"
39
+ spec.add_dependency "actionview", ">= 5.2.7.1"
40
40
  spec.add_dependency "notifications-ruby-client", "~> 5.1"
41
- spec.add_dependency "rack", ">= 2.1.4"
41
+ spec.add_dependency "rack", ">= 2.1.4.1"
42
42
  end
data/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:base"
5
+ ]
6
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail-notify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Harrison
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-14 00:00:00.000000000 Z
11
+ date: 2022-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.12.0
47
+ version: 0.14.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.12.0
54
+ version: 0.14.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rails
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,42 +72,42 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 12.3.3
75
+ version: 13.0.6
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 12.3.3
82
+ version: 13.0.6
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec-rails
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.8'
89
+ version: '5.1'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.8'
96
+ version: '5.1'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: standard
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 0.4.7
103
+ version: 1.16.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 0.4.7
110
+ version: 1.16.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: sqlite3
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -128,76 +128,70 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 3.7.6
131
+ version: 3.18.1
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 3.7.6
138
+ version: 3.18.1
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: actionmailer
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 5.2.4.2
146
- - - "<"
147
- - !ruby/object:Gem::Version
148
- version: '6.2'
145
+ version: 5.2.4.6
149
146
  type: :runtime
150
147
  prerelease: false
151
148
  version_requirements: !ruby/object:Gem::Requirement
152
149
  requirements:
153
150
  - - ">="
154
151
  - !ruby/object:Gem::Version
155
- version: 5.2.4.2
156
- - - "<"
157
- - !ruby/object:Gem::Version
158
- version: '6.2'
152
+ version: 5.2.4.6
159
153
  - !ruby/object:Gem::Dependency
160
154
  name: activesupport
161
155
  requirement: !ruby/object:Gem::Requirement
162
156
  requirements:
163
157
  - - ">="
164
158
  - !ruby/object:Gem::Version
165
- version: 5.2.4.3
159
+ version: 5.2.4.6
166
160
  type: :runtime
167
161
  prerelease: false
168
162
  version_requirements: !ruby/object:Gem::Requirement
169
163
  requirements:
170
164
  - - ">="
171
165
  - !ruby/object:Gem::Version
172
- version: 5.2.4.3
166
+ version: 5.2.4.6
173
167
  - !ruby/object:Gem::Dependency
174
168
  name: actionpack
175
169
  requirement: !ruby/object:Gem::Requirement
176
170
  requirements:
177
171
  - - ">="
178
172
  - !ruby/object:Gem::Version
179
- version: 5.2.4.3
173
+ version: 5.2.7.1
180
174
  type: :runtime
181
175
  prerelease: false
182
176
  version_requirements: !ruby/object:Gem::Requirement
183
177
  requirements:
184
178
  - - ">="
185
179
  - !ruby/object:Gem::Version
186
- version: 5.2.4.3
180
+ version: 5.2.7.1
187
181
  - !ruby/object:Gem::Dependency
188
182
  name: actionview
189
183
  requirement: !ruby/object:Gem::Requirement
190
184
  requirements:
191
185
  - - ">="
192
186
  - !ruby/object:Gem::Version
193
- version: 5.2.4.3
187
+ version: 5.2.7.1
194
188
  type: :runtime
195
189
  prerelease: false
196
190
  version_requirements: !ruby/object:Gem::Requirement
197
191
  requirements:
198
192
  - - ">="
199
193
  - !ruby/object:Gem::Version
200
- version: 5.2.4.3
194
+ version: 5.2.7.1
201
195
  - !ruby/object:Gem::Dependency
202
196
  name: notifications-ruby-client
203
197
  requirement: !ruby/object:Gem::Requirement
@@ -218,14 +212,14 @@ dependencies:
218
212
  requirements:
219
213
  - - ">="
220
214
  - !ruby/object:Gem::Version
221
- version: 2.1.4
215
+ version: 2.1.4.1
222
216
  type: :runtime
223
217
  prerelease: false
224
218
  version_requirements: !ruby/object:Gem::Requirement
225
219
  requirements:
226
220
  - - ">="
227
221
  - !ruby/object:Gem::Version
228
- version: 2.1.4
222
+ version: 2.1.4.1
229
223
  description:
230
224
  email:
231
225
  - pezholio@gmail.com
@@ -234,6 +228,7 @@ extensions: []
234
228
  extra_rdoc_files: []
235
229
  files:
236
230
  - ".coveralls.yml"
231
+ - ".github/dependabot.yml"
237
232
  - ".github/setup-rubygems.sh"
238
233
  - ".github/workflows/build.yml"
239
234
  - ".github/workflows/publish.yml"
@@ -261,6 +256,7 @@ files:
261
256
  - lib/mail/notify/railtie.rb
262
257
  - lib/mail/notify/version.rb
263
258
  - mail-notify.gemspec
259
+ - renovate.json
264
260
  homepage: https://github.com/dxw/mail-notify
265
261
  licenses:
266
262
  - MIT
@@ -280,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
276
  - !ruby/object:Gem::Version
281
277
  version: '0'
282
278
  requirements: []
283
- rubygems_version: 3.0.3
279
+ rubygems_version: 3.1.6
284
280
  signing_key:
285
281
  specification_version: 4
286
282
  summary: ActionMailer support for the GOV.UK Notify API