mail-notify 1.2.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/linting.yml +24 -0
- data/.github/workflows/publish.yml +5 -1
- data/.github/workflows/rails-integration-tests.yml +169 -0
- data/.github/workflows/unit-tests.yml +43 -0
- data/.gitignore +5 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +23 -1
- data/Dockerfile +61 -0
- data/README.md +181 -76
- data/Rakefile +1 -6
- data/{lib/mail/notify → app/views}/layouts/govuk_notify_layout.html.erb +23 -25
- data/bin/console +4 -9
- data/bin/rspec +27 -0
- data/bin/standardrb +27 -0
- data/docs/assets/images/view_template_in_notify.png +0 -0
- data/lib/mail/notify/delivery_method.rb +17 -26
- data/lib/mail/notify/engine.rb +13 -0
- data/lib/mail/notify/mail_notify_preview_interceptor.rb +51 -0
- data/lib/mail/notify/mail_notify_previews_controller.rb +6 -0
- data/lib/mail/notify/mailer.rb +89 -7
- data/lib/mail/notify/message.rb +1 -3
- data/lib/mail/notify/version.rb +1 -1
- data/lib/mail/notify.rb +3 -3
- data/mail-notify.gemspec +16 -15
- data/renovate.json +3 -1
- metadata +74 -61
- data/.coveralls.yml +0 -0
- data/.github/dependabot.yml +0 -10
- data/.github/workflows/build.yml +0 -27
- data/.rubocop.yml +0 -14
- data/docs/screenshot.png +0 -0
- data/lib/mail/notify/mailers_controller.rb +0 -40
- data/lib/mail/notify/personalisation.rb +0 -30
- data/lib/mail/notify/railtie.rb +0 -19
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mail
|
4
|
-
module Notify
|
5
|
-
module MailersController
|
6
|
-
def preview
|
7
|
-
@email_action = File.basename(params[:path])
|
8
|
-
return super unless @preview.email_exists?(@email_action)
|
9
|
-
|
10
|
-
@email = @preview.call(@email_action, params)
|
11
|
-
|
12
|
-
return super unless notify?
|
13
|
-
|
14
|
-
return render_part if params[:part]
|
15
|
-
|
16
|
-
render_preview_wrapper
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def render_part
|
22
|
-
# Add the current directory to the view path so that Rails can find
|
23
|
-
# the `govuk_notify_layout` layout
|
24
|
-
append_view_path(__dir__)
|
25
|
-
|
26
|
-
response.content_type = "text/html"
|
27
|
-
render html: @email.preview.html.html_safe, layout: "govuk_notify_layout"
|
28
|
-
end
|
29
|
-
|
30
|
-
def render_preview_wrapper
|
31
|
-
@part = @email
|
32
|
-
render action: "email", layout: false, formats: %i[html]
|
33
|
-
end
|
34
|
-
|
35
|
-
def notify?
|
36
|
-
@email.delivery_method.instance_of?(Mail::Notify::DeliveryMethod)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mail
|
4
|
-
module Notify
|
5
|
-
class Personalisation
|
6
|
-
BLANK = Object.new
|
7
|
-
|
8
|
-
def initialize(mail)
|
9
|
-
@body = mail.body.raw_source
|
10
|
-
@subject = mail.subject
|
11
|
-
@personalisation = mail[:personalisation]&.unparsed_value || {}
|
12
|
-
end
|
13
|
-
|
14
|
-
def to_h
|
15
|
-
merged_options
|
16
|
-
.reject { |_k, v| v.blank? }
|
17
|
-
.transform_values { |value| (value == BLANK) ? "" : value }
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def merged_options
|
23
|
-
{
|
24
|
-
body: @body,
|
25
|
-
subject: @subject
|
26
|
-
}.merge(@personalisation)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/lib/mail/notify/railtie.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails/mailers_controller"
|
4
|
-
|
5
|
-
module Mail
|
6
|
-
module Notify
|
7
|
-
class Railtie < Rails::Railtie
|
8
|
-
initializer "mail-notify.add_delivery_method", before: "action_mailer.set_configs" do
|
9
|
-
ActionMailer::Base.add_delivery_method(:notify, Mail::Notify::DeliveryMethod)
|
10
|
-
end
|
11
|
-
|
12
|
-
initializer "mail-notify.action_controller" do
|
13
|
-
ActiveSupport.on_load(:action_controller, run_once: true) do
|
14
|
-
Rails::MailersController.prepend(Mail::Notify::MailersController)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|