govuk_notify_rails 1.0.0 → 2.0.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/lib/govuk_notify_rails/delivery.rb +6 -9
- data/lib/govuk_notify_rails/mail_ext.rb +1 -0
- data/lib/govuk_notify_rails/mailer.rb +6 -0
- data/lib/govuk_notify_rails/version.rb +1 -1
- data/spec/dummy/{README.rdoc → README.md} +1 -5
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/javascripts/application.js +4 -1
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +3 -3
- data/spec/dummy/app/controllers/application_controller.rb +0 -2
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/mailers/notify_mailer.rb +1 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +9 -8
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/rails +6 -1
- data/spec/dummy/bin/rake +5 -0
- data/spec/dummy/bin/setup +15 -10
- data/spec/dummy/bin/spring +17 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/config.ru +2 -1
- data/spec/dummy/config/application.rb +5 -15
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/development.rb +27 -11
- data/spec/dummy/config/environments/production.rb +27 -17
- data/spec/dummy/config/environments/test.rb +7 -7
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +2 -0
- data/spec/dummy/config/initializers/govuk_notify_rails.rb +1 -2
- data/spec/dummy/config/initializers/new_framework_defaults.rb +24 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +6 -1
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +1 -54
- data/spec/dummy/config/secrets.yml +3 -3
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/log/development.log +7 -428
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/govuk_notify_delivery/delivery_spec.rb +29 -11
- data/spec/mailers/notify_mailer_spec.rb +5 -0
- metadata +54 -16
- data/spec/dummy/log/test.log +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f18695b6e10853e1315086f370905884654a58a1
|
4
|
+
data.tar.gz: 7b966ffaec4bb686445c5e4a04805ab56a42baea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdf44697db9f0e8d68a27829fe9f049b9f0a6b6d286fd73382945677a03355c6bfcb036d8d91ecbfc98d586847706c49c289a39019f9c2596e6c887dcee9db51
|
7
|
+
data.tar.gz: 354f76b28d13dc315f7a6c50c82805fa314779e9b42b5586ec9c885991e2289e48e26899fd1754147c7e748fcce90ca2ef666d964bb1b53b6ea3934f5bb7c182
|
@@ -12,24 +12,21 @@ module GovukNotifyRails
|
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
-
def
|
16
|
-
settings[:
|
17
|
-
end
|
18
|
-
|
19
|
-
def secret_key
|
20
|
-
settings[:secret_key]
|
15
|
+
def api_key
|
16
|
+
settings[:api_key]
|
21
17
|
end
|
22
18
|
|
23
19
|
def payload_for(message)
|
24
20
|
{
|
25
|
-
|
26
|
-
|
21
|
+
email_address: message.to.first,
|
22
|
+
template_id: message.govuk_notify_template,
|
23
|
+
reference: message.govuk_notify_reference,
|
27
24
|
personalisation: message.govuk_notify_personalisation
|
28
25
|
}.compact
|
29
26
|
end
|
30
27
|
|
31
28
|
def notify_client
|
32
|
-
@notify_client ||= Notifications::Client.new(
|
29
|
+
@notify_client ||= Notifications::Client.new(api_key)
|
33
30
|
end
|
34
31
|
end
|
35
32
|
end
|
@@ -3,6 +3,7 @@ module GovukNotifyRails
|
|
3
3
|
default delivery_method: :govuk_notify
|
4
4
|
|
5
5
|
attr_accessor :govuk_notify_template
|
6
|
+
attr_accessor :govuk_notify_reference
|
6
7
|
attr_accessor :govuk_notify_personalisation
|
7
8
|
|
8
9
|
protected
|
@@ -14,6 +15,7 @@ module GovukNotifyRails
|
|
14
15
|
|
15
16
|
message = super(headers)
|
16
17
|
message.govuk_notify_template = govuk_notify_template
|
18
|
+
message.govuk_notify_reference = govuk_notify_reference
|
17
19
|
message.govuk_notify_personalisation = govuk_notify_personalisation
|
18
20
|
end
|
19
21
|
|
@@ -21,6 +23,10 @@ module GovukNotifyRails
|
|
21
23
|
self.govuk_notify_template = template
|
22
24
|
end
|
23
25
|
|
26
|
+
def set_reference(reference)
|
27
|
+
self.govuk_notify_reference = reference
|
28
|
+
end
|
29
|
+
|
24
30
|
def set_personalisation(personalisation)
|
25
31
|
self.govuk_notify_personalisation = personalisation
|
26
32
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# README
|
2
2
|
|
3
3
|
This README would normally document whatever steps are necessary to get the
|
4
4
|
application up and running.
|
@@ -22,7 +22,3 @@ Things you may want to cover:
|
|
22
22
|
* Deployment instructions
|
23
23
|
|
24
24
|
* ...
|
25
|
-
|
26
|
-
|
27
|
-
Please feel free to use a different markup language if you do not plan to run
|
28
|
-
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
2
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
3
|
|
4
|
-
|
4
|
+
require_relative 'config/application'
|
5
5
|
|
6
6
|
Rails.application.load_tasks
|
@@ -5,9 +5,12 @@
|
|
5
5
|
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
6
|
//
|
7
7
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
9
|
//
|
10
10
|
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
11
|
// about supported directives.
|
12
12
|
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require turbolinks
|
13
16
|
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the rails generate channel command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
@@ -6,9 +6,9 @@
|
|
6
6
|
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
7
|
*
|
8
8
|
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any
|
10
|
-
*
|
11
|
-
* file per style scope.
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
12
|
*
|
13
13
|
*= require_tree .
|
14
14
|
*= require_self
|
@@ -1,13 +1,14 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
<head>
|
4
|
-
|
5
|
-
|
6
|
-
<%= csrf_meta_tags %>
|
7
|
-
</head>
|
8
|
-
<body>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= csrf_meta_tags %>
|
9
6
|
|
10
|
-
<%=
|
7
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
8
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
9
|
+
</head>
|
11
10
|
|
12
|
-
|
11
|
+
<body>
|
12
|
+
<%= yield %>
|
13
|
+
</body>
|
13
14
|
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
data/spec/dummy/bin/rails
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
begin
|
3
|
+
load File.expand_path('../spring', __FILE__)
|
4
|
+
rescue LoadError => e
|
5
|
+
raise unless e.message.include?('spring')
|
6
|
+
end
|
7
|
+
APP_PATH = File.expand_path('../config/application', __dir__)
|
3
8
|
require_relative '../config/boot'
|
4
9
|
require 'rails/commands'
|
data/spec/dummy/bin/rake
CHANGED
data/spec/dummy/bin/setup
CHANGED
@@ -1,29 +1,34 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
3
5
|
|
4
6
|
# path to your application root.
|
5
7
|
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
8
|
|
7
|
-
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
8
14
|
# This script is a starting point to setup your application.
|
9
|
-
# Add necessary setup steps to this file
|
15
|
+
# Add necessary setup steps to this file.
|
10
16
|
|
11
17
|
puts '== Installing dependencies =='
|
12
|
-
system 'gem install bundler --conservative'
|
13
|
-
system
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
14
20
|
|
15
21
|
# puts "\n== Copying sample files =="
|
16
|
-
# unless File.exist?(
|
17
|
-
#
|
22
|
+
# unless File.exist?('config/database.yml')
|
23
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
18
24
|
# end
|
19
25
|
|
20
26
|
puts "\n== Preparing database =="
|
21
|
-
system 'bin/
|
27
|
+
system! 'bin/rails db:setup'
|
22
28
|
|
23
29
|
puts "\n== Removing old logs and tempfiles =="
|
24
|
-
system '
|
25
|
-
system 'rm -rf tmp/cache'
|
30
|
+
system! 'bin/rails log:clear tmp:clear'
|
26
31
|
|
27
32
|
puts "\n== Restarting application server =="
|
28
|
-
system '
|
33
|
+
system! 'bin/rails restart'
|
29
34
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This file loads spring without using Bundler, in order to be fast.
|
4
|
+
# It gets overwritten when you run the `spring binstub` command.
|
5
|
+
|
6
|
+
unless defined?(Spring)
|
7
|
+
require 'rubygems'
|
8
|
+
require 'bundler'
|
9
|
+
|
10
|
+
lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
|
11
|
+
spring = lockfile.specs.detect { |spec| spec.name == "spring" }
|
12
|
+
if spring
|
13
|
+
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
|
14
|
+
gem 'spring', spring.version
|
15
|
+
require 'spring/binstub'
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a way to update your development environment automatically.
|
15
|
+
# Add necessary update steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
20
|
+
|
21
|
+
puts "\n== Updating database =="
|
22
|
+
system! 'bin/rails db:migrate'
|
23
|
+
|
24
|
+
puts "\n== Removing old logs and tempfiles =="
|
25
|
+
system! 'bin/rails log:clear tmp:clear'
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system! 'bin/rails restart'
|
29
|
+
end
|
data/spec/dummy/config.ru
CHANGED
@@ -1,13 +1,11 @@
|
|
1
|
-
|
1
|
+
require_relative 'boot'
|
2
2
|
|
3
|
-
|
4
|
-
# require "active_record/railtie"
|
5
|
-
require 'action_controller/railtie'
|
6
|
-
require 'action_mailer/railtie'
|
7
|
-
require 'action_view/railtie'
|
8
|
-
require 'rails/test_unit/railtie'
|
3
|
+
require 'rails/all'
|
9
4
|
|
5
|
+
# Require the gems listed in Gemfile, including any gems
|
6
|
+
# you've limited to :test, :development, or :production.
|
10
7
|
Bundler.require(*Rails.groups)
|
8
|
+
|
11
9
|
require 'govuk_notify_rails'
|
12
10
|
|
13
11
|
module Dummy
|
@@ -15,13 +13,5 @@ module Dummy
|
|
15
13
|
# Settings in config/environments/* take precedence over those specified here.
|
16
14
|
# Application configuration should go into files in config/initializers
|
17
15
|
# -- all .rb files in that directory are automatically loaded.
|
18
|
-
|
19
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
20
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
21
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
22
|
-
|
23
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
24
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
25
|
-
# config.i18n.default_locale = :de
|
26
16
|
end
|
27
17
|
end
|
@@ -9,30 +9,46 @@ Rails.application.configure do
|
|
9
9
|
# Do not eager load code on boot.
|
10
10
|
config.eager_load = false
|
11
11
|
|
12
|
-
# Show full error reports
|
13
|
-
config.consider_all_requests_local
|
14
|
-
|
12
|
+
# Show full error reports.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
|
15
|
+
# Enable/disable caching. By default caching is disabled.
|
16
|
+
if Rails.root.join('tmp/caching-dev.txt').exist?
|
17
|
+
config.action_controller.perform_caching = true
|
18
|
+
|
19
|
+
config.cache_store = :memory_store
|
20
|
+
config.public_file_server.headers = {
|
21
|
+
'Cache-Control' => 'public, max-age=172800'
|
22
|
+
}
|
23
|
+
else
|
24
|
+
config.action_controller.perform_caching = false
|
25
|
+
|
26
|
+
config.cache_store = :null_store
|
27
|
+
end
|
15
28
|
|
16
29
|
# Don't care if the mailer can't send.
|
17
30
|
config.action_mailer.raise_delivery_errors = false
|
18
31
|
|
32
|
+
config.action_mailer.perform_caching = false
|
33
|
+
|
19
34
|
# Print deprecation notices to the Rails logger.
|
20
35
|
config.active_support.deprecation = :log
|
21
36
|
|
37
|
+
# Raise an error on page load if there are pending migrations.
|
38
|
+
config.active_record.migration_error = :page_load
|
39
|
+
|
22
40
|
# Debug mode disables concatenation and preprocessing of assets.
|
23
41
|
# This option may cause significant delays in view rendering with a large
|
24
42
|
# number of complex assets.
|
25
43
|
config.assets.debug = true
|
26
44
|
|
27
|
-
#
|
28
|
-
|
29
|
-
config.assets.digest = true
|
30
|
-
|
31
|
-
# Adds additional error checking when serving assets at runtime.
|
32
|
-
# Checks for improperly declared sprockets dependencies.
|
33
|
-
# Raises helpful error messages.
|
34
|
-
config.assets.raise_runtime_errors = true
|
45
|
+
# Suppress logger output for asset requests.
|
46
|
+
config.assets.quiet = true
|
35
47
|
|
36
48
|
# Raises error for missing translations
|
37
49
|
# config.action_view.raise_on_missing_translations = true
|
50
|
+
|
51
|
+
# Use an evented file watcher to asynchronously detect changes in source code,
|
52
|
+
# routes, locales, etc. This feature depends on the listen gem.
|
53
|
+
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
38
54
|
end
|