defra_ruby_email 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/defra_ruby_email/version.rb +1 -1
  3. metadata +14 -177
  4. data/spec/defra_ruby_email_spec.rb +0 -39
  5. data/spec/dummy/README.rdoc +0 -28
  6. data/spec/dummy/Rakefile +0 -6
  7. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  8. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  9. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  10. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  11. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  12. data/spec/dummy/bin/bundle +0 -3
  13. data/spec/dummy/bin/rails +0 -4
  14. data/spec/dummy/bin/rake +0 -4
  15. data/spec/dummy/bin/setup +0 -29
  16. data/spec/dummy/config/application.rb +0 -29
  17. data/spec/dummy/config/boot.rb +0 -5
  18. data/spec/dummy/config/environment.rb +0 -5
  19. data/spec/dummy/config/environments/development.rb +0 -38
  20. data/spec/dummy/config/environments/production.rb +0 -76
  21. data/spec/dummy/config/environments/test.rb +0 -42
  22. data/spec/dummy/config/initializers/assets.rb +0 -11
  23. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  24. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  25. data/spec/dummy/config/initializers/defra_ruby_email.rb +0 -5
  26. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  27. data/spec/dummy/config/initializers/inflections.rb +0 -16
  28. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  29. data/spec/dummy/config/initializers/session_store.rb +0 -3
  30. data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +0 -10
  31. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -9
  32. data/spec/dummy/config/locales/en.yml +0 -23
  33. data/spec/dummy/config/routes.rb +0 -4
  34. data/spec/dummy/config/secrets.yml +0 -22
  35. data/spec/dummy/config.ru +0 -4
  36. data/spec/dummy/log/test.log +0 -13969
  37. data/spec/dummy/public/404.html +0 -67
  38. data/spec/dummy/public/422.html +0 -67
  39. data/spec/dummy/public/500.html +0 -66
  40. data/spec/dummy/public/favicon.ico +0 -0
  41. data/spec/examples.txt +0 -38
  42. data/spec/lib/last_email_cache_spec.rb +0 -221
  43. data/spec/lib/last_notify_message_spec.rb +0 -85
  44. data/spec/rails_helper.rb +0 -46
  45. data/spec/requests/last_email_spec.rb +0 -34
  46. data/spec/requests/last_notify_message_spec.rb +0 -82
  47. data/spec/spec_helper.rb +0 -83
  48. data/spec/support/helpers/configuration.rb +0 -16
  49. data/spec/support/pry.rb +0 -7
  50. data/spec/support/simplecov.rb +0 -17
@@ -1,67 +0,0 @@
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>
@@ -1,67 +0,0 @@
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>
@@ -1,66 +0,0 @@
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/examples.txt DELETED
@@ -1,38 +0,0 @@
1
- example_id | status | run_time |
2
- -------------------------------------------------- | ------ | --------------- |
3
- ./spec/defra_ruby_email_spec.rb[1:1:1] | passed | 0.00141 seconds |
4
- ./spec/defra_ruby_email_spec.rb[1:2:1:1] | passed | 0.00065 seconds |
5
- ./spec/defra_ruby_email_spec.rb[1:2:2:1] | passed | 0.00012 seconds |
6
- ./spec/lib/last_email_cache_spec.rb[1:1:1:1] | passed | 0.0002 seconds |
7
- ./spec/lib/last_email_cache_spec.rb[1:1:1:2] | passed | 0.0002 seconds |
8
- ./spec/lib/last_email_cache_spec.rb[1:1:2:1:1] | passed | 0.00348 seconds |
9
- ./spec/lib/last_email_cache_spec.rb[1:1:2:1:2] | passed | 0.00401 seconds |
10
- ./spec/lib/last_email_cache_spec.rb[1:1:2:1:3] | passed | 0.00321 seconds |
11
- ./spec/lib/last_email_cache_spec.rb[1:1:2:2:1] | passed | 0.00316 seconds |
12
- ./spec/lib/last_email_cache_spec.rb[1:1:2:2:2] | passed | 0.00406 seconds |
13
- ./spec/lib/last_email_cache_spec.rb[1:1:2:2:3] | passed | 0.00322 seconds |
14
- ./spec/lib/last_email_cache_spec.rb[1:1:3:1:1] | passed | 0.00744 seconds |
15
- ./spec/lib/last_email_cache_spec.rb[1:1:3:1:2] | passed | 0.00738 seconds |
16
- ./spec/lib/last_email_cache_spec.rb[1:1:3:1:3] | passed | 0.00725 seconds |
17
- ./spec/lib/last_email_cache_spec.rb[1:1:3:2:1] | passed | 0.01275 seconds |
18
- ./spec/lib/last_email_cache_spec.rb[1:1:3:2:2] | passed | 0.01283 seconds |
19
- ./spec/lib/last_email_cache_spec.rb[1:1:3:2:3] | passed | 0.01324 seconds |
20
- ./spec/lib/last_email_cache_spec.rb[1:1:3:3:1] | passed | 0.01334 seconds |
21
- ./spec/lib/last_email_cache_spec.rb[1:1:3:3:2] | passed | 0.01667 seconds |
22
- ./spec/lib/last_email_cache_spec.rb[1:1:3:3:3] | passed | 0.01566 seconds |
23
- ./spec/lib/last_email_cache_spec.rb[1:1:3:4:1] | passed | 0.0092 seconds |
24
- ./spec/lib/last_email_cache_spec.rb[1:1:3:4:2] | passed | 0.02459 seconds |
25
- ./spec/lib/last_email_cache_spec.rb[1:1:3:4:3] | passed | 0.00897 seconds |
26
- ./spec/lib/last_email_cache_spec.rb[1:1:4:1] | passed | 0.00686 seconds |
27
- ./spec/lib/last_email_cache_spec.rb[1:1:4:2] | passed | 0.00606 seconds |
28
- ./spec/lib/last_email_cache_spec.rb[1:1:4:3] | passed | 0.00752 seconds |
29
- ./spec/lib/last_email_cache_spec.rb[1:1:4:4] | passed | 0.00553 seconds |
30
- ./spec/lib/last_notify_message_spec.rb[1:1:1] | passed | 0.00917 seconds |
31
- ./spec/lib/last_notify_message_spec.rb[1:2:1:1] | passed | 0.00014 seconds |
32
- ./spec/lib/last_notify_message_spec.rb[1:2:1:2] | passed | 0.00014 seconds |
33
- ./spec/lib/last_notify_message_spec.rb[1:2:2:1] | passed | 0.0005 seconds |
34
- ./spec/lib/last_notify_message_spec.rb[1:2:2:2] | passed | 0.00064 seconds |
35
- ./spec/requests/last_email_spec.rb[1:1:1] | passed | 0.2142 seconds |
36
- ./spec/requests/last_email_spec.rb[1:2:1] | passed | 0.00534 seconds |
37
- ./spec/requests/last_notify_message_spec.rb[1:1:1] | passed | 0.007 seconds |
38
- ./spec/requests/last_notify_message_spec.rb[1:2:1] | passed | 0.00562 seconds |
@@ -1,221 +0,0 @@
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
@@ -1,85 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails_helper"
4
-
5
- module DefraRubyEmail
6
- RSpec.describe LastNotifyMessage do
7
- subject(:instance) { described_class.instance }
8
-
9
- before(:each) { instance.reset }
10
-
11
- let(:client) { double(:client, get_notifications: notifications) }
12
- let(:notifications) { double(:notifications, collection: collection) }
13
- let(:collection) { double(:collection, first: notification) }
14
- let(:notification) do
15
- double(:notification,
16
- type: "email",
17
- template: "template",
18
- subject: "Subject",
19
- body: "Body",
20
- sent_at: "datetime",
21
- email_address: "test@example.com",
22
- phone_number: nil,
23
- line_1: nil,
24
- line_2: nil,
25
- line_3: nil,
26
- line_4: nil,
27
- line_5: nil,
28
- line_6: nil,
29
- postcode: nil)
30
- end
31
-
32
- let(:expected_keys) { %w[type template subject body date to line_1 line_2 line_3 line_4 line_5 line_6 postcode] }
33
-
34
- describe "#retrieve_last_notify_message" do
35
- it "makes a call to the Notify client" do
36
- expect(Notifications::Client).to receive(:new).with(DefraRubyEmail.configuration.notify_api_key).and_return(client)
37
- expect(client).to receive(:get_notifications).and_return(notifications)
38
-
39
- expect(instance.last_notify_message).to eq(nil)
40
-
41
- instance.retrieve_last_notify_message
42
-
43
- expect(instance.last_notify_message).to eq(notification)
44
- end
45
- end
46
-
47
- describe "#last_notify_message_json" do
48
- context "when no messages have been sent" do
49
- let(:expected_keys) { %w[error] }
50
-
51
- it "returns a JSON string" do
52
- result = instance.last_notify_message_json
53
-
54
- expect(result).to be_a(String)
55
- expect { JSON.parse(result) }.to_not raise_error
56
- end
57
-
58
- it "responds with an error message" do
59
- result = JSON.parse(instance.last_notify_message_json)
60
-
61
- expect(result.keys).to match_array(expected_keys)
62
- end
63
- end
64
-
65
- context "when a message has been sent" do
66
- before(:each) do
67
- instance.last_notify_message = notification
68
- end
69
-
70
- it "returns a JSON string" do
71
- result = instance.last_notify_message_json
72
-
73
- expect(result).to be_a(String)
74
- expect { JSON.parse(result) }.to_not raise_error
75
- end
76
-
77
- it "contains the attributes of the message" do
78
- result = JSON.parse(instance.last_notify_message_json)
79
-
80
- expect(result["last_notify_message"].keys).to match_array(expected_keys)
81
- end
82
- end
83
- end
84
- end
85
- end
data/spec/rails_helper.rb DELETED
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file is copied to spec/ when you run 'rails generate rspec:install'
4
- require "spec_helper"
5
- ENV["RAILS_ENV"] ||= "test"
6
- require File.expand_path("dummy/config/environment", __dir__)
7
-
8
- # Prevent database truncation if the environment is production
9
- abort("The Rails environment is running in production mode!") if Rails.env.production?
10
- require "rspec/rails"
11
- # Add additional requires below this line. Rails is not loaded until this point!
12
-
13
- # Requires supporting ruby files with custom matchers and macros, etc, in
14
- # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
15
- # run as spec files by default. This means that files in spec/support that end
16
- # in _spec.rb will both be required and run as specs, causing the specs to be
17
- # run twice. It is recommended that you do not name files matching this glob to
18
- # end with _spec.rb. You can configure this pattern with the --pattern
19
- # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
20
- #
21
- # We make an exception for simplecov because that will already have been
22
- # required and run at the very top of spec_helper.rb
23
- support_files = Dir["./spec/support/**/*.rb"].reject { |file| file == "./spec/support/simplecov.rb" }
24
- support_files.each { |f| require f }
25
-
26
- RSpec.configure do |config|
27
- # RSpec Rails can automatically mix in different behaviours to your tests
28
- # based on their file location, for example enabling you to call `get` and
29
- # `post` in specs under `spec/controllers`.
30
- #
31
- # You can disable this behaviour by removing the line below, and instead
32
- # explicitly tag your specs with their type, e.g.:
33
- #
34
- # RSpec.describe UsersController, :type => :controller do
35
- # # ...
36
- # end
37
- #
38
- # The different available types are documented in the features, such as in
39
- # https://relishapp.com/rspec/rspec-rails/docs
40
- config.infer_spec_type_from_file_location!
41
-
42
- # Filter lines from Rails gems in backtraces.
43
- config.filter_rails_from_backtrace!
44
- # arbitrary gems may also be filtered via:
45
- # config.filter_gems_from_backtrace("gem name")
46
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails_helper"
4
-
5
- module DefraRubyEmail
6
- RSpec.describe "LastEmail", type: :request do
7
- after(:all) { Helpers::Configuration.reset_for_tests }
8
-
9
- let(:path) { "/defra_ruby_email/last-email" }
10
-
11
- context "when mocks are enabled" do
12
- before(:each) do
13
- Helpers::Configuration.prep_for_tests
14
- TestMailer.text_email("test@example.com").deliver_now
15
- end
16
-
17
- it "returns a JSON response with a 200 code containing details of the last email sent" do
18
- get path
19
-
20
- expect(response.media_type).to eq("application/json")
21
- expect(response.code).to eq("200")
22
- expect(response.body).to eq(LastEmailCache.instance.last_email_json)
23
- end
24
- end
25
-
26
- context "when mocks are disabled" do
27
- before(:all) { DefraRubyEmail.configuration.enable = false }
28
-
29
- it "cannot load the page" do
30
- expect { get path }.to raise_error(ActionController::RoutingError)
31
- end
32
- end
33
- end
34
- end