govuk_notify_rails 2.2.0 → 3.0.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: abdf654cc620b9c9aa426a4c4ba430b1b184ca520beefa3fba2ce757b3386bb4
4
- data.tar.gz: 5f5d4218fa5f5666223cde48afc80f270d7147cf3eba98cafe0937cc271cc551
3
+ metadata.gz: b7ae8e3403bc21d367702344fca21fdbccfb591089e9bfdaab0bef913345012e
4
+ data.tar.gz: 3f8ea35ea1389e0e420a73c9d698cb752b625254927a0e39b6114ab68ae6c820
5
5
  SHA512:
6
- metadata.gz: 8633e7d482581a0bd074dbe0fd829c07d1ad69bf9076a6bd4653543128601a5839fc2fd1388dea84331b017dba0d2167bc896903a1135fdde13a0a4b6daa138f
7
- data.tar.gz: 8837528eacad8ec681f1526ff7d9ce24f5097a42b39e503d1e8a9a1a4530eaf3e5c61ae6cd03d4754ff0eb73200f138f1a23d45eb3d2a0d8265aaea23a5c4b6b
6
+ metadata.gz: a3656b4fba827f8290881dbdd910152756c7b32c82809769244e20dcb84fbe2617464dadf78c897a6a1bf2fc59da778264ab1726210c1e0a759170a60ba94c7d
7
+ data.tar.gz: ea580374689d4755e68585a2e80dd135f92ae1ac9dba74404ae4b976b255b77c47aec514cd4909342176ae63e78e4480dcfe5253541ec2eb85fe515c02daaa49
@@ -34,7 +34,8 @@ module GovukNotifyRails
34
34
  template_id: message.govuk_notify_template,
35
35
  reference: message.govuk_notify_reference,
36
36
  personalisation: message.govuk_notify_personalisation,
37
- email_reply_to_id: message.govuk_notify_email_reply_to
37
+ email_reply_to_id: message.govuk_notify_email_reply_to,
38
+ one_click_unsubscribe_url: message.govuk_notify_one_click_unsubscribe_url
38
39
  }.compact
39
40
  end
40
41
 
@@ -2,9 +2,12 @@ module Mail
2
2
  class Message
3
3
  attr_accessor :govuk_notify_template
4
4
  attr_accessor :govuk_notify_reference
5
+ attr_accessor :govuk_notify_email_reply_to
6
+ attr_accessor :govuk_notify_one_click_unsubscribe_url
7
+
5
8
  attr_accessor :govuk_notify_personalisation
9
+
6
10
  attr_accessor :govuk_notify_response
7
11
  attr_accessor :govuk_notify_responses
8
- attr_accessor :govuk_notify_email_reply_to
9
12
  end
10
13
  end
@@ -6,6 +6,7 @@ module GovukNotifyRails
6
6
  attr_accessor :govuk_notify_reference
7
7
  attr_accessor :govuk_notify_personalisation
8
8
  attr_accessor :govuk_notify_email_reply_to
9
+ attr_accessor :govuk_notify_one_click_unsubscribe_url
9
10
 
10
11
  protected
11
12
 
@@ -19,6 +20,7 @@ module GovukNotifyRails
19
20
  message.govuk_notify_reference = govuk_notify_reference
20
21
  message.govuk_notify_personalisation = govuk_notify_personalisation
21
22
  message.govuk_notify_email_reply_to = govuk_notify_email_reply_to
23
+ message.govuk_notify_one_click_unsubscribe_url = govuk_notify_one_click_unsubscribe_url
22
24
  end
23
25
 
24
26
  def set_template(template)
@@ -37,6 +39,10 @@ module GovukNotifyRails
37
39
  self.govuk_notify_email_reply_to = address
38
40
  end
39
41
 
42
+ def set_one_click_unsubscribe_url(url)
43
+ self.govuk_notify_one_click_unsubscribe_url = url
44
+ end
45
+
40
46
  def _default_body
41
47
  'This is a GOV.UK Notify email with template %s and personalisation: %s' % [govuk_notify_template, govuk_notify_personalisation]
42
48
  end
@@ -1,3 +1,3 @@
1
1
  module GovukNotifyRails
2
- VERSION = '2.2.0'.freeze
2
+ VERSION = '3.0.0'.freeze
3
3
  end
@@ -2,6 +2,9 @@ class NotifyMailer < GovukNotifyRails::Mailer
2
2
  def test_email(user)
3
3
  set_template('9661d08a-486d-4c67-865e-ad976f17871d')
4
4
  set_reference('my_reference')
5
+ set_email_reply_to('527c131f-ef4b-4b5b-8f9b-3202581af277')
6
+ set_one_click_unsubscribe_url('https://example.com/unsubscribe?token=123456')
7
+
5
8
  set_personalisation(
6
9
  full_name: user.name
7
10
  )
@@ -385,3 +385,87 @@ NotifyMailer#test_email: processed outbound mail in 0.3ms
385
385
  NotifyMailer#test_email: processed outbound mail in 0.4ms
386
386
  NotifyMailer#test_email: processed outbound mail in 0.4ms
387
387
  NotifyMailer#test_email: processed outbound mail in 0.3ms
388
+ NotifyMailer#test_email: processed outbound mail in 26.1ms
389
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
390
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
391
+ NotifyMailer#test_email: processed outbound mail in 0.5ms
392
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
393
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
394
+ NotifyMailer#test_email: processed outbound mail in 26.2ms
395
+ NotifyMailer#test_email: processed outbound mail in 0.5ms
396
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
397
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
398
+ NotifyMailer#test_email: processed outbound mail in 0.5ms
399
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
400
+ NotifyMailer#test_email: processed outbound mail in 30.0ms
401
+ NotifyMailer#test_email: processed outbound mail in 0.6ms
402
+ NotifyMailer#test_email: processed outbound mail in 5.5ms
403
+ NotifyMailer#test_email: processed outbound mail in 0.7ms
404
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
405
+ NotifyMailer#test_email: processed outbound mail in 0.5ms
406
+ NotifyMailer#test_email: processed outbound mail in 0.8ms
407
+ NotifyMailer#test_email: processed outbound mail in 0.6ms
408
+ NotifyMailer#test_email: processed outbound mail in 28.0ms
409
+ NotifyMailer#test_email: processed outbound mail in 0.5ms
410
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
411
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
412
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
413
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
414
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
415
+ NotifyMailer#test_email: processed outbound mail in 0.5ms
416
+ NotifyMailer#test_email: processed outbound mail in 18.1ms
417
+ NotifyMailer#test_email: processed outbound mail in 0.5ms
418
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
419
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
420
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
421
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
422
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
423
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
424
+ NotifyMailer#test_email: processed outbound mail in 17.5ms
425
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
426
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
427
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
428
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
429
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
430
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
431
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
432
+ NotifyMailer#test_email: processed outbound mail in 23.8ms
433
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
434
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
435
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
436
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
437
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
438
+ NotifyMailer#test_email: processed outbound mail in 0.5ms
439
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
440
+ NotifyMailer#test_email: processed outbound mail in 26.0ms
441
+ NotifyMailer#test_email: processed outbound mail in 0.6ms
442
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
443
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
444
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
445
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
446
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
447
+ NotifyMailer#test_email: processed outbound mail in 0.3ms
448
+ NotifyMailer#test_email: processed outbound mail in 32.4ms
449
+ NotifyMailer#test_email: processed outbound mail in 0.6ms
450
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
451
+ NotifyMailer#test_email: processed outbound mail in 0.5ms
452
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
453
+ NotifyMailer#test_email: processed outbound mail in 0.5ms
454
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
455
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
456
+ NotifyMailer#test_email: processed outbound mail in 36.9ms
457
+ NotifyMailer#test_email: processed outbound mail in 1.4ms
458
+ NotifyMailer#test_email: processed outbound mail in 0.8ms
459
+ NotifyMailer#test_email: processed outbound mail in 0.6ms
460
+ NotifyMailer#test_email: processed outbound mail in 1.0ms
461
+ NotifyMailer#test_email: processed outbound mail in 0.7ms
462
+ NotifyMailer#test_email: processed outbound mail in 0.5ms
463
+ NotifyMailer#test_email: processed outbound mail in 0.6ms
464
+ NotifyMailer#test_email: processed outbound mail in 24.2ms
465
+ NotifyMailer#test_email: processed outbound mail in 0.5ms
466
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
467
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
468
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
469
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
470
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
471
+ NotifyMailer#test_email: processed outbound mail in 0.4ms
@@ -5,11 +5,13 @@ describe GovukNotifyRails::Delivery do
5
5
  describe '#deliver!' do
6
6
  let(:api_key) { 'api-key' }
7
7
  let(:notify_client) { double('NotifyClient') }
8
- let(:reply_to) { "email_reply_to_reference" }
9
-
10
8
  let(:to) { ['email@example.com'] }
11
- let(:personalisation) { { name: 'John' } }
9
+
12
10
  let(:reference) { 'my_reference' }
11
+ let(:reply_to) { 'email_reply_to_uuid' }
12
+ let(:unsubscribe_url) { 'https://example.com/unsubscribe?token=123456' }
13
+
14
+ let(:personalisation) { { name: 'John' } }
13
15
 
14
16
  let(:message) do
15
17
  instance_double(
@@ -17,8 +19,9 @@ describe GovukNotifyRails::Delivery do
17
19
  to: to,
18
20
  govuk_notify_template: 'template-123',
19
21
  govuk_notify_reference: reference,
20
- govuk_notify_personalisation: personalisation,
21
- govuk_notify_email_reply_to: reply_to
22
+ govuk_notify_email_reply_to: reply_to,
23
+ govuk_notify_one_click_unsubscribe_url: unsubscribe_url,
24
+ govuk_notify_personalisation: personalisation
22
25
  )
23
26
  end
24
27
 
@@ -37,8 +40,9 @@ describe GovukNotifyRails::Delivery do
37
40
  email_address: 'email@example.com',
38
41
  template_id: 'template-123',
39
42
  reference: reference,
40
- personalisation: personalisation,
41
- email_reply_to_id: reply_to
43
+ email_reply_to_id: reply_to,
44
+ one_click_unsubscribe_url: unsubscribe_url,
45
+ personalisation: personalisation
42
46
  }
43
47
  )
44
48
 
@@ -105,7 +109,8 @@ describe GovukNotifyRails::Delivery do
105
109
  email_address: 'email@example.com',
106
110
  template_id: 'template-123',
107
111
  reference: reference,
108
- email_reply_to_id: "email_reply_to_reference"
112
+ email_reply_to_id: reply_to,
113
+ one_click_unsubscribe_url: unsubscribe_url
109
114
  }
110
115
  )
111
116
  subject.deliver!(message)
@@ -121,7 +126,8 @@ describe GovukNotifyRails::Delivery do
121
126
  email_address: 'email@example.com',
122
127
  template_id: 'template-123',
123
128
  personalisation: personalisation,
124
- email_reply_to_id: "email_reply_to_reference"
129
+ email_reply_to_id: reply_to,
130
+ one_click_unsubscribe_url: unsubscribe_url
125
131
  }
126
132
  )
127
133
  subject.deliver!(message)
@@ -137,7 +143,25 @@ describe GovukNotifyRails::Delivery do
137
143
  email_address: 'email@example.com',
138
144
  template_id: 'template-123',
139
145
  personalisation: personalisation,
140
- reference: reference
146
+ reference: reference,
147
+ one_click_unsubscribe_url: unsubscribe_url
148
+ }
149
+ )
150
+ subject.deliver!(message)
151
+ end
152
+ end
153
+
154
+ context 'no unsubscribe url set' do
155
+ let(:unsubscribe_url) { nil }
156
+
157
+ it 'supports messages without unsubscribe url' do
158
+ expect(notify_client).to receive(:send_email).with(
159
+ {
160
+ email_address: 'email@example.com',
161
+ template_id: 'template-123',
162
+ reference: reference,
163
+ email_reply_to_id: reply_to,
164
+ personalisation: personalisation
141
165
  }
142
166
  )
143
167
  subject.deliver!(message)
@@ -5,6 +5,9 @@ RSpec.describe NotifyMailer, type: :mailer do
5
5
  describe 'new_message_test_email' do
6
6
  let(:template) { '9661d08a-486d-4c67-865e-ad976f17871d' }
7
7
  let(:reference) { 'my_reference' }
8
+ let(:reply_to) { '527c131f-ef4b-4b5b-8f9b-3202581af277' }
9
+ let(:unsubscribe_url) { 'https://example.com/unsubscribe?token=123456' }
10
+
8
11
  let(:user) { double('User', name: 'Test Name', email: 'test@example.com') }
9
12
  let(:mail) { described_class.test_email(user) }
10
13
 
@@ -28,6 +31,14 @@ RSpec.describe NotifyMailer, type: :mailer do
28
31
  expect(mail.govuk_notify_reference).to eq(reference)
29
32
  end
30
33
 
34
+ it 'sets the reply_to' do
35
+ expect(mail.govuk_notify_email_reply_to).to eq(reply_to)
36
+ end
37
+
38
+ it 'sets the unsubscribe url' do
39
+ expect(mail.govuk_notify_one_click_unsubscribe_url).to eq(unsubscribe_url)
40
+ end
41
+
31
42
  it 'sets the personalisation' do
32
43
  expect(mail.govuk_notify_personalisation.keys).to eq([:full_name])
33
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_notify_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesus Laiz
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-07 00:00:00.000000000 Z
11
+ date: 2024-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '5.1'
33
+ version: '6.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '5.1'
40
+ version: '6.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -94,7 +94,7 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 3.0.5
97
- description:
97
+ description:
98
98
  email:
99
99
  - zheileman@users.noreply.github.com
100
100
  executables: []
@@ -166,7 +166,7 @@ homepage: https://github.com/ministryofjustice/govuk_notify_rails
166
166
  licenses:
167
167
  - MIT
168
168
  metadata: {}
169
- post_install_message:
169
+ post_install_message:
170
170
  rdoc_options: []
171
171
  require_paths:
172
172
  - lib
@@ -181,64 +181,64 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
183
  requirements: []
184
- rubygems_version: 3.0.3
185
- signing_key:
184
+ rubygems_version: 3.4.10
185
+ signing_key:
186
186
  specification_version: 4
187
187
  summary: Custom ActionMailer delivery method for sending emails via GOV.UK Notify
188
188
  API
189
189
  test_files:
190
- - spec/spec_helper.rb
191
- - spec/dummy/app/mailers/notify_mailer.rb
190
+ - spec/dummy/README.md
191
+ - spec/dummy/Rakefile
192
+ - spec/dummy/app/assets/config/manifest.js
193
+ - spec/dummy/app/assets/javascripts/application.js
194
+ - spec/dummy/app/assets/javascripts/cable.js
195
+ - spec/dummy/app/assets/stylesheets/application.css
196
+ - spec/dummy/app/controllers/application_controller.rb
197
+ - spec/dummy/app/helpers/application_helper.rb
198
+ - spec/dummy/app/jobs/application_job.rb
192
199
  - spec/dummy/app/mailers/application_mailer.rb
200
+ - spec/dummy/app/mailers/notify_mailer.rb
193
201
  - spec/dummy/app/models/application_record.rb
194
- - spec/dummy/app/jobs/application_job.rb
195
- - spec/dummy/app/controllers/application_controller.rb
196
202
  - spec/dummy/app/views/layouts/application.html.erb
197
203
  - spec/dummy/app/views/layouts/mailer.html.erb
198
204
  - spec/dummy/app/views/layouts/mailer.text.erb
199
- - spec/dummy/app/assets/config/manifest.js
200
- - spec/dummy/app/assets/javascripts/cable.js
201
- - spec/dummy/app/assets/javascripts/application.js
202
- - spec/dummy/app/assets/stylesheets/application.css
203
- - spec/dummy/app/helpers/application_helper.rb
204
- - spec/dummy/bin/update
205
+ - spec/dummy/bin/bundle
206
+ - spec/dummy/bin/rails
205
207
  - spec/dummy/bin/rake
206
208
  - spec/dummy/bin/setup
207
- - spec/dummy/bin/bundle
208
209
  - spec/dummy/bin/spring
209
- - spec/dummy/bin/rails
210
- - spec/dummy/config/secrets.yml
211
- - spec/dummy/config/routes.rb
212
- - spec/dummy/config/locales/en.yml
213
- - spec/dummy/config/environments/production.rb
214
- - spec/dummy/config/environments/development.rb
215
- - spec/dummy/config/environments/test.rb
216
- - spec/dummy/config/spring.rb
217
- - spec/dummy/config/environment.rb
210
+ - spec/dummy/bin/update
218
211
  - spec/dummy/config/application.rb
219
- - spec/dummy/config/puma.rb
220
212
  - spec/dummy/config/boot.rb
213
+ - spec/dummy/config/environment.rb
214
+ - spec/dummy/config/environments/development.rb
215
+ - spec/dummy/config/environments/production.rb
216
+ - spec/dummy/config/environments/test.rb
221
217
  - spec/dummy/config/initializers/application_controller_renderer.rb
222
- - spec/dummy/config/initializers/backtrace_silencers.rb
223
- - spec/dummy/config/initializers/mime_types.rb
224
- - spec/dummy/config/initializers/filter_parameter_logging.rb
225
- - spec/dummy/config/initializers/session_store.rb
226
- - spec/dummy/config/initializers/wrap_parameters.rb
227
- - spec/dummy/config/initializers/new_framework_defaults.rb
228
218
  - spec/dummy/config/initializers/assets.rb
219
+ - spec/dummy/config/initializers/backtrace_silencers.rb
229
220
  - spec/dummy/config/initializers/cookies_serializer.rb
221
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
230
222
  - spec/dummy/config/initializers/govuk_notify_rails.rb
231
223
  - spec/dummy/config/initializers/inflections.rb
224
+ - spec/dummy/config/initializers/mime_types.rb
225
+ - spec/dummy/config/initializers/new_framework_defaults.rb
226
+ - spec/dummy/config/initializers/session_store.rb
227
+ - spec/dummy/config/initializers/wrap_parameters.rb
228
+ - spec/dummy/config/locales/en.yml
229
+ - spec/dummy/config/puma.rb
230
+ - spec/dummy/config/routes.rb
231
+ - spec/dummy/config/secrets.yml
232
+ - spec/dummy/config/spring.rb
232
233
  - spec/dummy/config.ru
233
- - spec/dummy/README.md
234
- - spec/dummy/Rakefile
235
- - spec/dummy/public/favicon.ico
234
+ - spec/dummy/log/development.log
235
+ - spec/dummy/public/404.html
236
236
  - spec/dummy/public/422.html
237
- - spec/dummy/public/apple-touch-icon.png
238
237
  - spec/dummy/public/500.html
239
- - spec/dummy/public/404.html
240
238
  - spec/dummy/public/apple-touch-icon-precomposed.png
239
+ - spec/dummy/public/apple-touch-icon.png
240
+ - spec/dummy/public/favicon.ico
241
241
  - spec/dummy/public/robots.txt
242
- - spec/dummy/log/development.log
243
242
  - spec/govuk_notify_delivery/delivery_spec.rb
244
243
  - spec/mailers/notify_mailer_spec.rb
244
+ - spec/spec_helper.rb