defra_ruby_email 0.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 +7 -0
- data/LICENSE +8 -0
- data/README.md +66 -0
- data/Rakefile +38 -0
- data/app/assets/images/defra_ruby_email/govuk_logotype_email.png +0 -0
- data/app/controllers/defra_ruby_email/application_controller.rb +7 -0
- data/app/controllers/defra_ruby_email/last_email_controller.rb +9 -0
- data/app/mailers/defra_ruby_email/test_mailer.rb +60 -0
- data/config/routes.rb +8 -0
- data/lib/defra_ruby_email.rb +26 -0
- data/lib/defra_ruby_email/configuration.rb +24 -0
- data/lib/defra_ruby_email/engine.rb +15 -0
- data/lib/defra_ruby_email/last_email_cache.rb +48 -0
- data/lib/defra_ruby_email/last_email_observer.rb +13 -0
- data/lib/defra_ruby_email/version.rb +5 -0
- data/lib/tasks/changelog.rake +8 -0
- data/lib/tasks/defra_ruby_email_tasks.rake +8 -0
- data/spec/defra_ruby_email_spec.rb +39 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +29 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +38 -0
- data/spec/dummy/config/environments/production.rb +76 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +10 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/log/test.log +53 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/1W/1WwQOSlYPtmYMlk5m-3Qq4NzEWNH7tYCQhfoslnaLHk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2-/2-japRDu0GHGko1cjVWjELVh5v9nz6Q45a2beIwLUrI.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4G/4Gbu6LmPYLfAZQgL2uv1eZwq7EYA0POiSWs6C_vXckg.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/AU/AUfMxF1097iBMMdRbzJKjyzoRLp1W-b_VuQ4p0OxWfw.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/B5/B5OLh2y7CLTgfdROC0dphxzI0KC-NWuzUoZ5fHcA6Bg.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/L4/L46n6ueXJJsYfqBb0tgyq4pu-Pmwghcq4wxrrvue0iI.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/MG/MGzsWSZq4b8vtnPxO8zkfdIwLVmVdcXFO1l9ao9g8D8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ps/PsDzIFzt3gBnxeXvfMfYXZ2E6DyEFleyRRfR01u34_8.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/SN/SN9Q1o1Je1stqGQtozCzZyPlhu1QW0gOSDpTQHrdE40.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/SW/SW2WGzrHD6rQ7Iifad3AJjwO-H5MMdk-KgDcDAo2L3w.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Tz/TzV-x09rf8_JdpcH7oq7Tx0hTs-7K6EpBgN2cGzTBCw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Uz/Uzp0b_uvqxkh0hY1pfL1MUpkNlf4zy_eYSBnRQQFiC0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_D/_DYI9CGjZuQS99rHeuP1Zczax1DlXobV7fQAOlFZbW0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_M/_MsZgIvurUGOXpB0mEZtVC6mrSMcnyTk7p_1psw3G-g.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aj/ajHL7E3SCz-eQbwNQMePJRLVz6OQHk7Xtuvu4SWLiYY.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/dC/dCKQMRMWehNHUz2uovXPnFyx0OyNUCVPhPvG9tPe0TM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ex/exO17VY09nxxoT76j7M9SboKOezGF_Wx0vTvGHl-vuU.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fN/fNIVnfQsXHwqWvodZxIU869b9k7z9k8O8Z5I7waSgbo.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gF/gFPphmPziPhcj5awJ-qSf7kvvYQE-mR6fJoj5Plw17I.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gm/gm8TWq2tpBcsn1xscp-vNMVweRDHm10LXftKrZ3WL3E.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/iG/iGr34Svi4uZyFOneReXcDJZvZTJyBzaiZFOm5EcSefM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pP/pPe-s4lIFwyYOpBJcOCFWCqVHJzKmr-bXTMajg0vA0U.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/q3/q3Z4d58Hu6dSbyJh-BeC0P0-vMjbI8cfMsHN73-B3gs.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/qo/qoLNp_jcpq5z2b5ijaCSHBZO7m6FKQHFrXVGHZ9ZoZ8.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/s4/s4_2m7OtzbFTNr3n5Zn_xY2uGLRIzpG24UgWUwG3yKA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sQ/sQNMSYgTkDcfTlnbqMpLd6Erufaoxo61qkVPy4YgY3A.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/y9/y9pXiDOCIiEqKn-ES0eCNUjJ7cSQFn31eombd1vJzj4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/z9/z9x_Zb62GyFCL1ZoYErl-HHrPL6AqOOgaLaDlJ9KaEo.cache +0 -0
- data/spec/examples.txt +8 -0
- data/spec/lib/last_email_cache_spec.rb +221 -0
- data/spec/rails_helper.rb +46 -0
- data/spec/requests/last_email_spec.rb +34 -0
- data/spec/spec_helper.rb +83 -0
- data/spec/support/helpers/configuration.rb +16 -0
- data/spec/support/pry.rb +7 -0
- data/spec/support/simplecov.rb +17 -0
- metadata +297 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
|
5
|
+
|
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
|
9
|
+
|
|
10
|
+
# Make sure the secrets in this file are kept private
|
|
11
|
+
# if you're sharing your code publicly.
|
|
12
|
+
|
|
13
|
+
development:
|
|
14
|
+
secret_key_base: e8b6d07aeb45634b7e803ea08c579dde1f535778d3d480ba063c0ae5e6c3cf0bdf3c9db470bfba16fea45b1434bd14de709cd0f11283bedb292d6a66c0eea0b6
|
|
15
|
+
|
|
16
|
+
test:
|
|
17
|
+
secret_key_base: f8f7ac9a4a93992c1e06278b8e4d251852b0d9b8cfbebfa22fadcadf27d406be95b3d3cdae252690343e31f9dd4126fc8e67e035d8387dfc34c69c6cddc0b96a
|
|
18
|
+
|
|
19
|
+
# Do not keep production secrets in the repository,
|
|
20
|
+
# instead read values from the environment.
|
|
21
|
+
production:
|
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
Started GET "/defra_ruby_email/test" for 127.0.0.1 at 2020-02-07 17:32:46 +0000
|
|
2
|
+
Processing by DefraRubyEmail::TestController#show as HTML
|
|
3
|
+
Rendered /Users/acruikshanks/projects/defra/defra-ruby-email/app/views/defra_ruby_email/test/show.html.erb within layouts/defra_ruby_email/application (4.3ms)
|
|
4
|
+
Completed 200 OK in 214ms (Views: 213.6ms)
|
|
5
|
+
Started GET "/defra_ruby_email/test" for 127.0.0.1 at 2020-02-07 17:32:46 +0000
|
|
6
|
+
Processing by DefraRubyEmail::TestController#show as HTML
|
|
7
|
+
Rendered /Users/acruikshanks/projects/defra/defra-ruby-email/app/views/defra_ruby_email/test/show.html.erb within layouts/defra_ruby_email/application (0.1ms)
|
|
8
|
+
Completed 200 OK in 2ms (Views: 2.1ms)
|
|
9
|
+
Started GET "/defra_ruby_email/test" for 127.0.0.1 at 2020-02-07 17:33:13 +0000
|
|
10
|
+
Processing by DefraRubyEmail::TestController#show as HTML
|
|
11
|
+
Rendered /Users/acruikshanks/projects/defra/defra-ruby-email/app/views/defra_ruby_email/test/show.html.erb within layouts/defra_ruby_email/application (4.2ms)
|
|
12
|
+
Completed 200 OK in 288ms (Views: 287.9ms)
|
|
13
|
+
Started GET "/defra_ruby_email/test" for 127.0.0.1 at 2020-02-07 17:33:13 +0000
|
|
14
|
+
Processing by DefraRubyEmail::TestController#show as HTML
|
|
15
|
+
Rendered /Users/acruikshanks/projects/defra/defra-ruby-email/app/views/defra_ruby_email/test/show.html.erb within layouts/defra_ruby_email/application (0.1ms)
|
|
16
|
+
Completed 200 OK in 2ms (Views: 1.8ms)
|
|
17
|
+
Started GET "/defra_ruby_email/test" for 127.0.0.1 at 2020-02-07 17:35:25 +0000
|
|
18
|
+
Processing by DefraRubyEmail::TestController#show as HTML
|
|
19
|
+
Rendered /Users/acruikshanks/projects/defra/defra-ruby-email/app/views/defra_ruby_email/test/show.html.erb within layouts/defra_ruby_email/application (4.3ms)
|
|
20
|
+
Completed 200 OK in 250ms (Views: 249.3ms)
|
|
21
|
+
Started GET "/defra_ruby_email/test" for 127.0.0.1 at 2020-02-07 17:35:25 +0000
|
|
22
|
+
Processing by DefraRubyEmail::TestController#show as HTML
|
|
23
|
+
Rendered /Users/acruikshanks/projects/defra/defra-ruby-email/app/views/defra_ruby_email/test/show.html.erb within layouts/defra_ruby_email/application (0.1ms)
|
|
24
|
+
Completed 200 OK in 2ms (Views: 1.9ms)
|
|
25
|
+
Started GET "/defra_ruby_email/test" for 127.0.0.1 at 2020-02-07 17:38:23 +0000
|
|
26
|
+
Processing by DefraRubyEmail::TestController#show as HTML
|
|
27
|
+
Rendered /Users/acruikshanks/projects/defra/defra-ruby-email/app/views/defra_ruby_email/test/show.html.erb within layouts/defra_ruby_email/application (7.2ms)
|
|
28
|
+
Completed 200 OK in 252ms (Views: 251.7ms)
|
|
29
|
+
Started GET "/defra_ruby_email/test" for 127.0.0.1 at 2020-02-07 17:38:23 +0000
|
|
30
|
+
Processing by DefraRubyEmail::TestController#show as HTML
|
|
31
|
+
Rendered /Users/acruikshanks/projects/defra/defra-ruby-email/app/views/defra_ruby_email/test/show.html.erb within layouts/defra_ruby_email/application (0.1ms)
|
|
32
|
+
Completed 200 OK in 2ms (Views: 1.9ms)
|
|
33
|
+
Started GET "/defra_ruby_email/test" for 127.0.0.1 at 2020-02-07 17:38:55 +0000
|
|
34
|
+
Processing by DefraRubyEmail::TestController#show as HTML
|
|
35
|
+
Rendered /Users/acruikshanks/projects/defra/defra-ruby-email/app/views/defra_ruby_email/test/show.html.erb within layouts/defra_ruby_email/application (5.1ms)
|
|
36
|
+
Completed 200 OK in 287ms (Views: 286.5ms)
|
|
37
|
+
Started GET "/defra_ruby_email/test" for 127.0.0.1 at 2020-02-07 17:38:55 +0000
|
|
38
|
+
Processing by DefraRubyEmail::TestController#show as HTML
|
|
39
|
+
Rendered /Users/acruikshanks/projects/defra/defra-ruby-email/app/views/defra_ruby_email/test/show.html.erb within layouts/defra_ruby_email/application (0.1ms)
|
|
40
|
+
Completed 200 OK in 2ms (Views: 1.5ms)
|
|
41
|
+
Started GET "/defra_ruby_mocks/company" for 127.0.0.1 at 2020-02-07 17:43:35 +0000
|
|
42
|
+
Started GET "/defra_ruby_mocks/company" for 127.0.0.1 at 2020-02-07 17:44:16 +0000
|
|
43
|
+
Started GET "/defra_ruby_mocks/company" for 127.0.0.1 at 2020-02-07 17:44:16 +0000
|
|
44
|
+
Started GET "/defra_ruby_mocks/company" for 127.0.0.1 at 2020-02-07 17:44:16 +0000
|
|
45
|
+
Started GET "/defra_ruby_email/test" for 127.0.0.1 at 2020-02-07 17:45:07 +0000
|
|
46
|
+
Processing by DefraRubyEmail::TestController#show as HTML
|
|
47
|
+
Rendered /Users/acruikshanks/projects/defra/defra-ruby-email/app/views/defra_ruby_email/test/show.html.erb within layouts/defra_ruby_email/application (4.6ms)
|
|
48
|
+
Completed 200 OK in 277ms (Views: 277.1ms)
|
|
49
|
+
Started GET "/defra_ruby_email/test" for 127.0.0.1 at 2020-02-07 17:45:07 +0000
|
|
50
|
+
Processing by DefraRubyEmail::TestController#show as HTML
|
|
51
|
+
Rendered /Users/acruikshanks/projects/defra/defra-ruby-email/app/views/defra_ruby_email/test/show.html.erb within layouts/defra_ruby_email/application (0.1ms)
|
|
52
|
+
Completed 200 OK in 2ms (Views: 1.8ms)
|
|
53
|
+
Started GET "/defra_ruby_email/test" for 127.0.0.1 at 2020-02-07 17:45:07 +0000
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body>
|
|
58
|
+
<!-- This file lives in public/404.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
|
63
|
+
</div>
|
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
65
|
+
</div>
|
|
66
|
+
</body>
|
|
67
|
+
</html>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body>
|
|
58
|
+
<!-- This file lives in public/422.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
|
63
|
+
</div>
|
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
65
|
+
</div>
|
|
66
|
+
</body>
|
|
67
|
+
</html>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body>
|
|
58
|
+
<!-- This file lives in public/500.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
|
62
|
+
</div>
|
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
64
|
+
</div>
|
|
65
|
+
</body>
|
|
66
|
+
</html>
|
|
File without changes
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/1W/1WwQOSlYPtmYMlk5m-3Qq4NzEWNH7tYCQhfoslnaLHk.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
I"�/Users/acruikshanks/projects/defra/defra-ruby-email/app/assets/stylesheets/defra_ruby_email/application.css?type=text/css&pipeline=self&id=95128a7258fb2b1cc10b87f5e7163c13480cf0b6013423b8b889c6080f7f6f23:ET
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2-/2-japRDu0GHGko1cjVWjELVh5v9nz6Q45a2beIwLUrI.cache
ADDED
|
Binary file
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4G/4Gbu6LmPYLfAZQgL2uv1eZwq7EYA0POiSWs6C_vXckg.cache
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
[o:Set:
|
|
2
|
+
@hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"0processors:type=text/css&file_type=text/css;TTI"~file-digest:///Users/acruikshanks/projects/defra/defra-ruby-email/app/assets/stylesheets/defra_ruby_email/application.css;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI"nfile-digest:///Users/acruikshanks/projects/defra/defra-ruby-email/app/assets/stylesheets/defra_ruby_email;TTF
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
[o:Set:
|
|
2
|
+
@hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"0processors:type=text/css&file_type=text/css;TTI"9file-digest://app/assets/stylesheets/application.css;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI")file-digest://app/assets/stylesheets;TTF
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/AU/AUfMxF1097iBMMdRbzJKjyzoRLp1W-b_VuQ4p0OxWfw.cache
ADDED
|
Binary file
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/B5/B5OLh2y7CLTgfdROC0dphxzI0KC-NWuzUoZ5fHcA6Bg.cache
ADDED
|
Binary file
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/L4/L46n6ueXJJsYfqBb0tgyq4pu-Pmwghcq4wxrrvue0iI.cache
ADDED
|
Binary file
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/MG/MGzsWSZq4b8vtnPxO8zkfdIwLVmVdcXFO1l9ao9g8D8.cache
ADDED
|
Binary file
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ps/PsDzIFzt3gBnxeXvfMfYXZ2E6DyEFleyRRfR01u34_8.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"%�W\�yho9S���ƫ˥��)|�~���(���
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/SN/SN9Q1o1Je1stqGQtozCzZyPlhu1QW0gOSDpTQHrdE40.cache
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
[o:Set:
|
|
2
|
+
@hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI"~file-digest:///Users/acruikshanks/projects/defra/defra-ruby-email/app/assets/stylesheets/defra_ruby_email/application.css;TTI"nfile-digest:///Users/acruikshanks/projects/defra/defra-ruby-email/app/assets/stylesheets/defra_ruby_email;TTF
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/SW/SW2WGzrHD6rQ7Iifad3AJjwO-H5MMdk-KgDcDAo2L3w.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=fad3563cb7794399020ed270ad1a5351d9445eac0a53023cebacc5aac6bc41d1:ET
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Tz/TzV-x09rf8_JdpcH7oq7Tx0hTs-7K6EpBgN2cGzTBCw.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
I"}app/assets/stylesheets/application.css?type=text/css&id=5dc29380884dce19f5842d9b98e593023501072edf0a683e4968357fe8e8bff5:ET
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Uz/Uzp0b_uvqxkh0hY1pfL1MUpkNlf4zy_eYSBnRQQFiC0.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"%�W\�yho9S���ƫ˥��)|�~���(���
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_D/_DYI9CGjZuQS99rHeuP1Zczax1DlXobV7fQAOlFZbW0.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"%Ѱč@�����6H�uZoX�Z�gbh0W��V
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_M/_MsZgIvurUGOXpB0mEZtVC6mrSMcnyTk7p_1psw3G-g.cache
ADDED
|
Binary file
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aj/ajHL7E3SCz-eQbwNQMePJRLVz6OQHk7Xtuvu4SWLiYY.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
I"�/Users/acruikshanks/projects/defra/defra-ruby-email/app/assets/javascripts/defra_ruby_email/application.js?type=application/javascript&id=f3d9ad429050fa27b5ed82613b4e3873ebbf433875e30b8f862a237136e7425b:ET
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/dC/dCKQMRMWehNHUz2uovXPnFyx0OyNUCVPhPvG9tPe0TM.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=0981d070b48bf256ca407442cca380224822dbdc0dc126995e25f99a1d142282:ET
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ex/exO17VY09nxxoT76j7M9SboKOezGF_Wx0vTvGHl-vuU.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
I"�/Users/acruikshanks/projects/defra/defra-ruby-email/app/assets/javascripts/defra_ruby_email/application.js?type=application/javascript&pipeline=self&id=9c853fb9e01341bd711e16d407101a3fe2fa08bc4500db07929e3b4fe9628813:ET
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fN/fNIVnfQsXHwqWvodZxIU869b9k7z9k8O8Z5I7waSgbo.cache
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
[o:Set:
|
|
2
|
+
@hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"}file-digest:///Users/acruikshanks/projects/defra/defra-ruby-email/app/assets/javascripts/defra_ruby_email/application.js;TTI"nfile-digest:///Users/acruikshanks/projects/defra/defra-ruby-email/app/assets/javascripts/defra_ruby_email;TTF
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gF/gFPphmPziPhcj5awJ-qSf7kvvYQE-mR6fJoj5Plw17I.cache
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
[o:Set:
|
|
2
|
+
@hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Lprocessors:type=application/javascript&file_type=application/javascript;TTI"}file-digest:///Users/acruikshanks/projects/defra/defra-ruby-email/app/assets/javascripts/defra_ruby_email/application.js;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"nfile-digest:///Users/acruikshanks/projects/defra/defra-ruby-email/app/assets/javascripts/defra_ruby_email;TTF
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gm/gm8TWq2tpBcsn1xscp-vNMVweRDHm10LXftKrZ3WL3E.cache
ADDED
|
Binary file
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/iG/iGr34Svi4uZyFOneReXcDJZvZTJyBzaiZFOm5EcSefM.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
I"�/Users/acruikshanks/projects/defra/defra-ruby-email/app/assets/stylesheets/defra_ruby_email/application.css?type=text/css&id=6f9ea299ba94033b5b252b97f1dccd370deb9bd91658ac6dc7210ec4c1406e7b:ET
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
[o:Set:
|
|
2
|
+
@hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Lprocessors:type=application/javascript&file_type=application/javascript;TTI"8file-digest://app/assets/javascripts/application.js;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI")file-digest://app/assets/javascripts;TTF
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pP/pPe-s4lIFwyYOpBJcOCFWCqVHJzKmr-bXTMajg0vA0U.cache
ADDED
|
Binary file
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/q3/q3Z4d58Hu6dSbyJh-BeC0P0-vMjbI8cfMsHN73-B3gs.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"%��Rm�v�S3.��O�L���ڹc�ƕq�=_j�
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/qo/qoLNp_jcpq5z2b5ijaCSHBZO7m6FKQHFrXVGHZ9ZoZ8.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
I"�app/assets/javascripts/application.js?type=application/javascript&id=7e42ac83f6955f877ca368796d07aed1fbdc34db7fb8df79c12aa9e24eb43917:ET
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/s4/s4_2m7OtzbFTNr3n5Zn_xY2uGLRIzpG24UgWUwG3yKA.cache
ADDED
|
Binary file
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sQ/sQNMSYgTkDcfTlnbqMpLd6Erufaoxo61qkVPy4YgY3A.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"%��Rm�v�S3.��O�L���ڹc�ƕq�=_j�
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/y9/y9pXiDOCIiEqKn-ES0eCNUjJ7cSQFn31eombd1vJzj4.cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"%Ѱč@�����6H�uZoX�Z�gbh0W��V
|
data/spec/dummy/tmp/cache/assets/sprockets/v3.0/z9/z9x_Zb62GyFCL1ZoYErl-HHrPL6AqOOgaLaDlJ9KaEo.cache
ADDED
|
Binary file
|
data/spec/examples.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
example_id | status | run_time |
|
|
2
|
+
---------------------------------------- | ------ | --------------- |
|
|
3
|
+
./spec/defra_ruby_email_spec.rb[1:1:1] | passed | 0.00747 seconds |
|
|
4
|
+
./spec/defra_ruby_email_spec.rb[1:2:1:1] | passed | 0.00016 seconds |
|
|
5
|
+
./spec/defra_ruby_email_spec.rb[1:2:2:1] | passed | 0.00737 seconds |
|
|
6
|
+
./spec/requests/test_spec.rb[1:1:1] | passed | 0.32532 seconds |
|
|
7
|
+
./spec/requests/test_spec.rb[1:1:2] | passed | 0.00952 seconds |
|
|
8
|
+
./spec/requests/test_spec.rb[1:2:1] | passed | 0.00874 seconds |
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails_helper"
|
|
4
|
+
|
|
5
|
+
module DefraRubyEmail
|
|
6
|
+
RSpec.describe LastEmailCache do
|
|
7
|
+
subject(:instance) { described_class.instance }
|
|
8
|
+
|
|
9
|
+
before(:each) { instance.reset }
|
|
10
|
+
|
|
11
|
+
let(:recipient) { "test@example.com" }
|
|
12
|
+
let(:add_attachment) { false }
|
|
13
|
+
let(:expected_keys) { %w[date from to bcc cc reply_to subject body attachments] }
|
|
14
|
+
|
|
15
|
+
describe "#last_email_json" do
|
|
16
|
+
|
|
17
|
+
context "when the no emails have been sent" do
|
|
18
|
+
let(:expected_keys) { %w[error] }
|
|
19
|
+
|
|
20
|
+
it "returns a JSON string" do
|
|
21
|
+
result = instance.last_email_json
|
|
22
|
+
|
|
23
|
+
expect(result).to be_a(String)
|
|
24
|
+
expect { JSON.parse(result) }.to_not raise_error
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "responds with an error message" do
|
|
28
|
+
result = JSON.parse(instance.last_email_json)
|
|
29
|
+
|
|
30
|
+
expect(result.keys).to match_array(expected_keys)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context "when a basic email is sent" do
|
|
35
|
+
context "and it is formatted as plain text" do
|
|
36
|
+
before(:each) { TestMailer.text_email(recipient, add_attachment).deliver_now }
|
|
37
|
+
|
|
38
|
+
it "returns a JSON string" do
|
|
39
|
+
result = instance.last_email_json
|
|
40
|
+
|
|
41
|
+
expect(result).to be_a(String)
|
|
42
|
+
expect { JSON.parse(result) }.to_not raise_error
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "contains the attributes of the email" do
|
|
46
|
+
result = JSON.parse(instance.last_email_json)
|
|
47
|
+
|
|
48
|
+
expect(result["last_email"].keys).to match_array(expected_keys)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "extracts the plain text body content" do
|
|
52
|
+
result = JSON.parse(instance.last_email_json)
|
|
53
|
+
|
|
54
|
+
expect(result["last_email"]["body"]).to start_with("This is the text version of an email")
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context "and it is formatted as html" do
|
|
59
|
+
before(:each) { TestMailer.html_email(recipient, add_attachment).deliver_now }
|
|
60
|
+
|
|
61
|
+
it "returns a JSON string" do
|
|
62
|
+
result = instance.last_email_json
|
|
63
|
+
|
|
64
|
+
expect(result).to be_a(String)
|
|
65
|
+
expect { JSON.parse(result) }.to_not raise_error
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "contains the attributes of the email" do
|
|
69
|
+
result = JSON.parse(instance.last_email_json)
|
|
70
|
+
|
|
71
|
+
expect(result["last_email"].keys).to match_array(expected_keys)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "extracts the html body content" do
|
|
75
|
+
result = JSON.parse(instance.last_email_json)
|
|
76
|
+
|
|
77
|
+
expect(result["last_email"]["body"]).to start_with("<h1>This is the html version of an email</h1>")
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Multi-part essentially means the email contains more than 2 elements. An
|
|
83
|
+
# element can be a HTML version, and plain text version, and an
|
|
84
|
+
# attachment. If it contains at least 2 of these it will be sent as a
|
|
85
|
+
# multipart email
|
|
86
|
+
context "when a multi-part email is sent" do
|
|
87
|
+
context "and it contains both a html and text version" do
|
|
88
|
+
before(:each) { TestMailer.multipart_email(recipient, add_attachment).deliver_now }
|
|
89
|
+
|
|
90
|
+
it "returns a JSON string" do
|
|
91
|
+
result = instance.last_email_json
|
|
92
|
+
|
|
93
|
+
expect(result).to be_a(String)
|
|
94
|
+
expect { JSON.parse(result) }.to_not raise_error
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "contains the attributes of the email" do
|
|
98
|
+
result = JSON.parse(instance.last_email_json)
|
|
99
|
+
|
|
100
|
+
expect(result["last_email"].keys).to match_array(expected_keys)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "extracts the plain text body content" do
|
|
104
|
+
result = JSON.parse(instance.last_email_json)
|
|
105
|
+
|
|
106
|
+
expect(result["last_email"]["body"]).to start_with("This is the text version of an email")
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
context "and contains both a html and text version plus an attachment" do
|
|
111
|
+
before(:each) { TestMailer.multipart_email(recipient, add_attachment).deliver_now }
|
|
112
|
+
|
|
113
|
+
let(:add_attachment) { true }
|
|
114
|
+
|
|
115
|
+
it "returns a JSON string" do
|
|
116
|
+
result = instance.last_email_json
|
|
117
|
+
|
|
118
|
+
expect(result).to be_a(String)
|
|
119
|
+
expect { JSON.parse(result) }.to_not raise_error
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "contains the attributes of the email" do
|
|
123
|
+
result = JSON.parse(instance.last_email_json)
|
|
124
|
+
|
|
125
|
+
expect(result["last_email"].keys).to match_array(expected_keys)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "extracts the plain text body content" do
|
|
129
|
+
result = JSON.parse(instance.last_email_json)
|
|
130
|
+
|
|
131
|
+
expect(result["last_email"]["body"]).to start_with("This is the text version of an email")
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
context "but it just contains a plain text part and an attachment" do
|
|
136
|
+
before(:each) { TestMailer.text_email(recipient, add_attachment).deliver_now }
|
|
137
|
+
|
|
138
|
+
let(:add_attachment) { true }
|
|
139
|
+
|
|
140
|
+
it "returns a JSON string" do
|
|
141
|
+
result = instance.last_email_json
|
|
142
|
+
|
|
143
|
+
expect(result).to be_a(String)
|
|
144
|
+
expect { JSON.parse(result) }.to_not raise_error
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it "contains the attributes of the email" do
|
|
148
|
+
result = JSON.parse(instance.last_email_json)
|
|
149
|
+
|
|
150
|
+
expect(result["last_email"].keys).to match_array(expected_keys)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it "extracts the plain text body content" do
|
|
154
|
+
result = JSON.parse(instance.last_email_json)
|
|
155
|
+
|
|
156
|
+
expect(result["last_email"]["body"]).to start_with("This is the text version of an email")
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
context "but it just contains a html part and an attachment" do
|
|
161
|
+
before(:each) { TestMailer.html_email(recipient, add_attachment).deliver_now }
|
|
162
|
+
|
|
163
|
+
let(:add_attachment) { true }
|
|
164
|
+
|
|
165
|
+
it "returns a JSON string" do
|
|
166
|
+
result = instance.last_email_json
|
|
167
|
+
|
|
168
|
+
expect(result).to be_a(String)
|
|
169
|
+
expect { JSON.parse(result) }.to_not raise_error
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
it "contains the attributes of the email" do
|
|
173
|
+
result = JSON.parse(instance.last_email_json)
|
|
174
|
+
|
|
175
|
+
expect(result["last_email"].keys).to match_array(expected_keys)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it "extracts the html body content" do
|
|
179
|
+
result = JSON.parse(instance.last_email_json)
|
|
180
|
+
|
|
181
|
+
expect(result["last_email"]["body"]).to start_with("<h1>This is the html version of an email</h1>")
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
context "when multiple emails have been sent" do
|
|
187
|
+
before(:each) do
|
|
188
|
+
TestMailer.text_email(recipient, add_attachment).deliver_now
|
|
189
|
+
TestMailer.text_email(last_recipient, add_attachment).deliver_now
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
let(:last_recipient) { "joe.bloggs@example.com" }
|
|
193
|
+
|
|
194
|
+
it "returns a JSON string" do
|
|
195
|
+
result = instance.last_email_json
|
|
196
|
+
|
|
197
|
+
expect(result).to be_a(String)
|
|
198
|
+
expect { JSON.parse(result) }.to_not raise_error
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
it "contains the attributes of the email" do
|
|
202
|
+
result = JSON.parse(instance.last_email_json)
|
|
203
|
+
|
|
204
|
+
expect(result["last_email"].keys).to match_array(expected_keys)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it "extracts the plain text body content" do
|
|
208
|
+
result = JSON.parse(instance.last_email_json)
|
|
209
|
+
|
|
210
|
+
expect(result["last_email"]["body"]).to start_with("This is the text version of an email")
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
it "contains the details of the last email sent" do
|
|
214
|
+
result = JSON.parse(instance.last_email_json)
|
|
215
|
+
|
|
216
|
+
expect(result["last_email"]["to"]).to eq([last_recipient])
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end
|