sanitize_email 1.2.0 → 1.2.1
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/.ruby-version +1 -1
- data/.travis.yml +55 -14
- data/Appraisals +55 -0
- data/CHANGELOG.md +1 -1
- data/README.md +21 -2
- data/Rakefile +5 -38
- data/gemfiles/rails_3_0.gemfile +12 -0
- data/gemfiles/rails_3_1.gemfile +13 -0
- data/gemfiles/rails_3_2.gemfile +11 -0
- data/gemfiles/rails_4_0.gemfile +11 -0
- data/gemfiles/rails_4_1.gemfile +11 -0
- data/gemfiles/rails_4_2.gemfile +10 -0
- data/gemfiles/rails_5_0.gemfile +10 -0
- data/init.rb +1 -1
- data/lib/sanitize_email/config.rb +30 -13
- data/lib/sanitize_email/mail_header_tools.rb +30 -11
- data/lib/sanitize_email/overridden_addresses.rb +5 -5
- data/lib/sanitize_email/rspec_matchers.rb +48 -29
- data/lib/sanitize_email/test_helpers.rb +16 -10
- data/lib/sanitize_email/version.rb +1 -1
- data/lib/sanitize_email.rb +24 -21
- data/sanitize_email.gemspec +2 -0
- data/spec/sanitize_email_spec.rb +521 -220
- data/spec/spec_helper.rb +9 -9
- metadata +39 -9
- data/gemfiles/Gemfile.rails-3.0.x +0 -7
- data/gemfiles/Gemfile.rails-3.1.x +0 -8
- data/gemfiles/Gemfile.rails-3.2.x +0 -9
- data/gemfiles/Gemfile.rails-4.0.x +0 -9
- data/gemfiles/Gemfile.rails-4.1.x +0 -9
- data/gemfiles/Gemfile.rails-4.2.x +0 -6
data/spec/sanitize_email_spec.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
# Copyright (c) 2008-16 Peter H. Boling of RailsBling.com
|
2
2
|
# Released under the MIT license
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
#
|
6
|
-
# TODO: Letter Opener should *not* be required,
|
6
|
+
# TODO: Letter Opener should *not* be required,
|
7
|
+
# but setting the delivery method to :file
|
8
|
+
# was causing connection errors... WTF?
|
7
9
|
#
|
8
10
|
describe SanitizeEmail do
|
9
11
|
|
10
12
|
DEFAULT_TEST_CONFIG = {
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
}
|
13
|
+
sanitized_cc: "cc@sanitize_email.org",
|
14
|
+
sanitized_bcc: "bcc@sanitize_email.org",
|
15
|
+
use_actual_email_prepended_to_subject: false,
|
16
|
+
use_actual_environment_prepended_to_subject: false,
|
17
|
+
use_actual_email_as_sanitized_user_name: false
|
18
|
+
}.freeze
|
17
19
|
|
18
20
|
before(:all) do
|
19
21
|
SanitizeEmail::Deprecation.deprecate_in_silence = true
|
@@ -23,49 +25,68 @@ describe SanitizeEmail do
|
|
23
25
|
after(:each) do
|
24
26
|
SanitizeEmail::Config.config = SanitizeEmail::Config::DEFAULTS
|
25
27
|
SanitizeEmail.force_sanitize = nil
|
26
|
-
|
27
|
-
# Mail.class_variable_get(:@@delivery_interceptors).pop
|
28
|
-
Mail.send(:class_variable_get, :@@delivery_interceptors).pop
|
28
|
+
Mail.class_variable_get(:@@delivery_interceptors).pop
|
29
29
|
end
|
30
30
|
|
31
|
-
def sanitize_spec_dryer(rails_env =
|
31
|
+
def sanitize_spec_dryer(rails_env = "test")
|
32
32
|
allow(Launchy).to receive(:open)
|
33
|
-
location = File.expand_path(
|
33
|
+
location = File.expand_path("../tmp/mail_dump", __FILE__)
|
34
34
|
FileUtils.remove_file(location, true)
|
35
35
|
Mail.defaults do
|
36
|
-
delivery_method LetterOpener::DeliveryMethod, :
|
36
|
+
delivery_method LetterOpener::DeliveryMethod, location: location
|
37
37
|
end
|
38
|
+
SanitizeEmail::Config.instance_variable_set(
|
39
|
+
:@config,
|
40
|
+
SanitizeEmail::Config::DEFAULTS.dup
|
41
|
+
)
|
38
42
|
allow(Rails).to receive(:env).and_return(rails_env)
|
39
43
|
end
|
40
44
|
|
41
45
|
def configure_sanitize_email(sanitize_hash = {})
|
42
46
|
options = DEFAULT_TEST_CONFIG.merge(sanitize_hash).dup
|
43
|
-
|
47
|
+
unless sanitize_hash.key?(:sanitized_recipients)
|
48
|
+
options.reverse_merge!(sanitized_to: "to@sanitize_email.org")
|
49
|
+
end
|
44
50
|
SanitizeEmail::Config.configure do |config|
|
51
|
+
config[:engage] = options[:engage]
|
45
52
|
config[:environment] = options[:environment]
|
46
53
|
config[:activation_proc] = options[:activation_proc]
|
47
54
|
config[:sanitized_to] = options[:sanitized_to]
|
48
55
|
config[:sanitized_cc] = options[:sanitized_cc]
|
49
56
|
config[:sanitized_bcc] = options[:sanitized_bcc]
|
50
|
-
config[:use_actual_email_prepended_to_subject] =
|
51
|
-
|
52
|
-
config[:
|
57
|
+
config[:use_actual_email_prepended_to_subject] =
|
58
|
+
options[:use_actual_email_prepended_to_subject]
|
59
|
+
config[:use_actual_environment_prepended_to_subject] =
|
60
|
+
options[:use_actual_environment_prepended_to_subject]
|
61
|
+
config[:use_actual_email_as_sanitized_user_name] =
|
62
|
+
options[:use_actual_email_as_sanitized_user_name]
|
53
63
|
|
54
64
|
# For testing *deprecated* configuration options:
|
55
|
-
|
56
|
-
|
57
|
-
|
65
|
+
if options[:local_environments]
|
66
|
+
config[:local_environments] = options[:local_environments]
|
67
|
+
end
|
68
|
+
if options[:sanitized_recipients]
|
69
|
+
config[:sanitized_recipients] = options[:sanitized_recipients]
|
70
|
+
end
|
71
|
+
unless options[:force_sanitize].nil?
|
72
|
+
config[:force_sanitize] = options[:force_sanitize]
|
73
|
+
end
|
58
74
|
end
|
59
75
|
Mail.register_interceptor(SanitizeEmail::Bleach)
|
60
76
|
end
|
61
77
|
|
62
78
|
def funky_config
|
63
79
|
SanitizeEmail::Config.configure do |config|
|
64
|
-
config[:sanitized_to] =
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
80
|
+
config[:sanitized_to] =
|
81
|
+
%w(
|
82
|
+
funky@sanitize_email.org
|
83
|
+
yummy@sanitize_email.org
|
84
|
+
same@example.org
|
85
|
+
)
|
86
|
+
config[:sanitized_cc] = nil
|
87
|
+
config[:sanitized_bcc] = nil
|
88
|
+
# logic to turn sanitize_email on and off goes in this Proc:
|
89
|
+
config[:activation_proc] = proc { Rails.env != "production" }
|
69
90
|
config[:use_actual_email_prepended_to_subject] = true
|
70
91
|
config[:use_actual_environment_prepended_to_subject] = true
|
71
92
|
config[:use_actual_email_as_sanitized_user_name] = false
|
@@ -93,69 +114,79 @@ describe SanitizeEmail do
|
|
93
114
|
|
94
115
|
def mail_delivery_hot_mess
|
95
116
|
@email_message = Mail.deliver do
|
96
|
-
from
|
97
|
-
to %w(
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
117
|
+
from "same@example.org"
|
118
|
+
to %w(
|
119
|
+
same@example.org
|
120
|
+
same@example.org
|
121
|
+
same@example.org
|
122
|
+
same@example.org
|
123
|
+
same@example.org
|
124
|
+
)
|
125
|
+
cc "same@example.org"
|
126
|
+
bcc "same@example.org"
|
127
|
+
reply_to "same@example.org"
|
128
|
+
subject "original subject"
|
129
|
+
body "funky fresh"
|
103
130
|
end
|
104
131
|
end
|
105
132
|
|
106
133
|
def mail_delivery
|
107
134
|
@email_message = Mail.deliver do
|
108
|
-
from
|
109
|
-
to
|
110
|
-
cc
|
111
|
-
bcc
|
112
|
-
reply_to
|
113
|
-
subject
|
114
|
-
body
|
135
|
+
from "from@example.org"
|
136
|
+
to "to@example.org"
|
137
|
+
cc "cc@example.org"
|
138
|
+
bcc "bcc@example.org"
|
139
|
+
reply_to "reply_to@example.org"
|
140
|
+
subject "original subject"
|
141
|
+
body "funky fresh"
|
115
142
|
end
|
116
143
|
end
|
117
144
|
|
118
145
|
def mail_delivery_multiple_recipients
|
119
146
|
@email_message = Mail.deliver do
|
120
|
-
from
|
147
|
+
from "from@example.org"
|
121
148
|
to %w( to1@example.org to2@example.org to3@example.org )
|
122
149
|
cc %w( cc1@example.org cc2@example.org cc3@example.org )
|
123
150
|
bcc %w( bcc1@example.org bcc2@example.org bcc3@example.org )
|
124
|
-
reply_to
|
125
|
-
subject
|
126
|
-
body
|
151
|
+
reply_to "reply_to@example.org"
|
152
|
+
subject "original subject"
|
153
|
+
body "funky fresh"
|
127
154
|
end
|
128
155
|
end
|
129
156
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
157
|
+
before(:each) do
|
158
|
+
sanitize_spec_dryer
|
159
|
+
end
|
134
160
|
|
161
|
+
context "module methods" do
|
135
162
|
context "unsanitary" do
|
136
163
|
before(:each) do
|
137
164
|
configure_sanitize_email
|
138
165
|
unsanitary_mail_delivery
|
139
166
|
end
|
140
167
|
it "should not alter non-sanitized attributes" do
|
141
|
-
expect(@email_message).to have_from(
|
142
|
-
expect(@email_message).to have_reply_to(
|
143
|
-
expect(@email_message).to have_body_text(
|
168
|
+
expect(@email_message).to have_from("from@example.org")
|
169
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
170
|
+
expect(@email_message).to have_body_text("funky fresh")
|
144
171
|
end
|
145
172
|
it "should not prepend overrides" do
|
146
|
-
expect(@email_message).not_to have_to_username(
|
147
|
-
|
173
|
+
expect(@email_message).not_to have_to_username(
|
174
|
+
"to at sanitize_email.org"
|
175
|
+
)
|
176
|
+
expect(@email_message).not_to have_subject(
|
177
|
+
"(to at sanitize_email.org)"
|
178
|
+
)
|
148
179
|
end
|
149
180
|
it "alters nothing" do
|
150
|
-
expect(@email_message).to have_from(
|
151
|
-
expect(@email_message).to have_reply_to(
|
181
|
+
expect(@email_message).to have_from("from@example.org")
|
182
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
152
183
|
expect(@email_message).to have_from("from@example.org")
|
153
184
|
expect(@email_message).to have_to("to@example.org")
|
154
185
|
expect(@email_message).not_to have_to_username("to at")
|
155
186
|
expect(@email_message).to have_cc("cc@example.org")
|
156
187
|
expect(@email_message).to have_bcc("bcc@example.org")
|
157
188
|
expect(@email_message).to have_subject("original subject")
|
158
|
-
expect(@email_message).to have_body_text(
|
189
|
+
expect(@email_message).to have_body_text("funky fresh")
|
159
190
|
end
|
160
191
|
end
|
161
192
|
|
@@ -165,13 +196,17 @@ describe SanitizeEmail do
|
|
165
196
|
sanitary_mail_delivery
|
166
197
|
end
|
167
198
|
it "should not alter non-sanitized attributes" do
|
168
|
-
expect(@email_message).to have_from(
|
169
|
-
expect(@email_message).to have_reply_to(
|
170
|
-
expect(@email_message).to have_body_text(
|
199
|
+
expect(@email_message).to have_from("from@example.org")
|
200
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
201
|
+
expect(@email_message).to have_body_text("funky fresh")
|
171
202
|
end
|
172
203
|
it "should not prepend overrides" do
|
173
|
-
expect(@email_message).not_to have_to_username(
|
174
|
-
|
204
|
+
expect(@email_message).not_to have_to_username(
|
205
|
+
"to at sanitize_email.org"
|
206
|
+
)
|
207
|
+
expect(@email_message).not_to have_subject(
|
208
|
+
"(to at sanitize_email.org)"
|
209
|
+
)
|
175
210
|
end
|
176
211
|
it "should override" do
|
177
212
|
expect(@email_message).to have_to("to@sanitize_email.org")
|
@@ -179,13 +214,26 @@ describe SanitizeEmail do
|
|
179
214
|
expect(@email_message).to have_bcc("bcc@sanitize_email.org")
|
180
215
|
end
|
181
216
|
it "should set headers" do
|
182
|
-
expect(@email_message).to have_header(
|
183
|
-
|
184
|
-
|
217
|
+
expect(@email_message).to have_header(
|
218
|
+
"X-Sanitize-Email-To",
|
219
|
+
"to@example.org"
|
220
|
+
)
|
221
|
+
expect(@email_message).to have_header(
|
222
|
+
"X-Sanitize-Email-Cc",
|
223
|
+
"cc@example.org"
|
224
|
+
)
|
225
|
+
expect(@email_message).not_to have_header(
|
226
|
+
"X-Sanitize-Email-Bcc",
|
227
|
+
"bcc@sanitize_email.org"
|
228
|
+
)
|
185
229
|
end
|
186
230
|
it "should not prepend originals by default" do
|
187
|
-
expect(@email_message).not_to have_to_username(
|
188
|
-
|
231
|
+
expect(@email_message).not_to have_to_username(
|
232
|
+
"to at example.org <to@sanitize_email.org>"
|
233
|
+
)
|
234
|
+
expect(@email_message).not_to have_subject(
|
235
|
+
"(to at example.org) original subject"
|
236
|
+
)
|
189
237
|
end
|
190
238
|
end
|
191
239
|
|
@@ -195,12 +243,14 @@ describe SanitizeEmail do
|
|
195
243
|
sanitary_mail_delivery_multiple_recipients
|
196
244
|
end
|
197
245
|
it "should not alter non-sanitized attributes" do
|
198
|
-
expect(@email_message).to have_from(
|
199
|
-
expect(@email_message).to have_reply_to(
|
200
|
-
expect(@email_message).to have_body_text(
|
246
|
+
expect(@email_message).to have_from("from@example.org")
|
247
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
248
|
+
expect(@email_message).to have_body_text("funky fresh")
|
201
249
|
end
|
202
250
|
it "should not prepend overrides" do
|
203
|
-
expect(@email_message).not_to have_to_username(
|
251
|
+
expect(@email_message).not_to have_to_username(
|
252
|
+
"to at sanitize_email.org"
|
253
|
+
)
|
204
254
|
expect(@email_message).not_to have_subject("(to at sanitize_email.org)")
|
205
255
|
end
|
206
256
|
it "should override" do
|
@@ -209,29 +259,78 @@ describe SanitizeEmail do
|
|
209
259
|
expect(@email_message).to have_bcc("bcc@sanitize_email.org")
|
210
260
|
end
|
211
261
|
it "should set headers for sanitized :to recipients" do
|
212
|
-
expect(@email_message).to have_header(
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
expect(@email_message).
|
262
|
+
expect(@email_message).to have_header(
|
263
|
+
"X-Sanitize-Email-To",
|
264
|
+
"to1@example.org"
|
265
|
+
)
|
266
|
+
expect(@email_message).not_to have_header(
|
267
|
+
"X-Sanitize-Email-To-0",
|
268
|
+
"to1@example.org"
|
269
|
+
)
|
270
|
+
expect(@email_message).not_to have_header(
|
271
|
+
"X-Sanitize-Email-To-1",
|
272
|
+
"to1@example.org"
|
273
|
+
)
|
274
|
+
expect(@email_message).to have_header(
|
275
|
+
"X-Sanitize-Email-To-2",
|
276
|
+
"to2@example.org"
|
277
|
+
)
|
278
|
+
expect(@email_message).to have_header(
|
279
|
+
"X-Sanitize-Email-To-3",
|
280
|
+
"to3@example.org"
|
281
|
+
)
|
217
282
|
end
|
218
283
|
it "should set headers for sanitized :cc recipients" do
|
219
|
-
expect(@email_message).to have_header(
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
expect(@email_message).
|
284
|
+
expect(@email_message).to have_header(
|
285
|
+
"X-Sanitize-Email-Cc",
|
286
|
+
"cc1@example.org"
|
287
|
+
)
|
288
|
+
expect(@email_message).not_to have_header(
|
289
|
+
"X-Sanitize-Email-Cc-0",
|
290
|
+
"cc1@example.org"
|
291
|
+
)
|
292
|
+
expect(@email_message).not_to have_header(
|
293
|
+
"X-Sanitize-Email-Cc-1",
|
294
|
+
"cc1@example.org"
|
295
|
+
)
|
296
|
+
expect(@email_message).to have_header(
|
297
|
+
"X-Sanitize-Email-Cc-2",
|
298
|
+
"cc2@example.org"
|
299
|
+
)
|
300
|
+
expect(@email_message).to have_header(
|
301
|
+
"X-Sanitize-Email-Cc-3",
|
302
|
+
"cc3@example.org"
|
303
|
+
)
|
224
304
|
end
|
225
305
|
it "should not set headers for sanitized :bcc recipients" do
|
226
|
-
expect(@email_message).not_to have_header(
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
expect(@email_message).not_to have_header(
|
306
|
+
expect(@email_message).not_to have_header(
|
307
|
+
"X-Sanitize-Email-Bcc",
|
308
|
+
"bcc1@sanitize_email.org"
|
309
|
+
)
|
310
|
+
expect(@email_message).not_to have_header(
|
311
|
+
"X-Sanitize-Email-Bcc-0",
|
312
|
+
"bcc1@sanitize_email.org"
|
313
|
+
)
|
314
|
+
expect(@email_message).not_to have_header(
|
315
|
+
"X-Sanitize-Email-Bcc-1",
|
316
|
+
"bcc1@sanitize_email.org"
|
317
|
+
)
|
318
|
+
expect(@email_message).not_to have_header(
|
319
|
+
"X-Sanitize-Email-Bcc-2",
|
320
|
+
"bcc2@sanitize_email.org"
|
321
|
+
)
|
322
|
+
expect(@email_message).not_to have_header(
|
323
|
+
"X-Sanitize-Email-Bcc-3",
|
324
|
+
"bcc3@sanitize_email.org"
|
325
|
+
)
|
231
326
|
end
|
232
327
|
it "should not prepend originals by default" do
|
233
|
-
expect(@email_message).not_to have_to_username(
|
234
|
-
|
328
|
+
expect(@email_message).not_to have_to_username(
|
329
|
+
"to at example.org <to@sanitize_email.org>"
|
330
|
+
)
|
331
|
+
expect(@email_message).not_to have_subject(
|
332
|
+
"(to at example.org) original subject"
|
333
|
+
)
|
235
334
|
end
|
236
335
|
end
|
237
336
|
|
@@ -242,19 +341,24 @@ describe SanitizeEmail do
|
|
242
341
|
mail_delivery
|
243
342
|
end
|
244
343
|
it "original to is prepended to subject" do
|
245
|
-
|
344
|
+
regex = /\(to at example.org\).*original subject/
|
345
|
+
expect(@email_message).to have_subject(regex)
|
246
346
|
end
|
247
347
|
it "original to is only prepended once to subject" do
|
248
|
-
|
348
|
+
regex = /\(to at example.org\).*\(to at example.org\).*original subject/
|
349
|
+
expect(@email_message).not_to have_subject(regex)
|
249
350
|
end
|
250
351
|
it "should not alter non-sanitized attributes" do
|
251
|
-
expect(@email_message).to have_from(
|
252
|
-
expect(@email_message).to have_reply_to(
|
253
|
-
expect(@email_message).to have_body_text(
|
352
|
+
expect(@email_message).to have_from("from@example.org")
|
353
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
354
|
+
expect(@email_message).to have_body_text("funky fresh")
|
254
355
|
end
|
255
356
|
it "should not prepend overrides" do
|
256
|
-
expect(@email_message).not_to have_to_username(
|
257
|
-
|
357
|
+
expect(@email_message).not_to have_to_username(
|
358
|
+
"to at sanitize_email.org"
|
359
|
+
)
|
360
|
+
regex = /.*\(to at sanitize_email.org\).*/
|
361
|
+
expect(@email_message).not_to have_subject(regex)
|
258
362
|
end
|
259
363
|
it "should override where original recipients were not nil" do
|
260
364
|
expect(@email_message).to have_to("funky@sanitize_email.org")
|
@@ -264,21 +368,43 @@ describe SanitizeEmail do
|
|
264
368
|
expect(@email_message).not_to have_bcc("bcc@sanitize_email.org")
|
265
369
|
end
|
266
370
|
it "should set headers of originals" do
|
267
|
-
expect(@email_message).to have_header(
|
268
|
-
|
371
|
+
expect(@email_message).to have_header(
|
372
|
+
"X-Sanitize-Email-To",
|
373
|
+
"to@example.org"
|
374
|
+
)
|
375
|
+
expect(@email_message).to have_header(
|
376
|
+
"X-Sanitize-Email-Cc",
|
377
|
+
"cc@example.org"
|
378
|
+
)
|
269
379
|
end
|
270
380
|
it "should not set headers of bcc" do
|
271
|
-
expect(@email_message).not_to have_header(
|
381
|
+
expect(@email_message).not_to have_header(
|
382
|
+
"X-Sanitize-Email-Bcc",
|
383
|
+
"bcc@sanitize_email.org"
|
384
|
+
)
|
272
385
|
end
|
273
386
|
it "should not set headers of overrides" do
|
274
|
-
expect(@email_message).not_to have_header(
|
275
|
-
|
276
|
-
|
387
|
+
expect(@email_message).not_to have_header(
|
388
|
+
"X-Sanitize-Email-To",
|
389
|
+
"funky@sanitize_email.org"
|
390
|
+
)
|
391
|
+
expect(@email_message).not_to have_header(
|
392
|
+
"X-Sanitize-Email-Cc",
|
393
|
+
"cc@sanitize_email.org"
|
394
|
+
)
|
395
|
+
expect(@email_message).not_to have_header(
|
396
|
+
"X-Sanitize-Email-Bcc",
|
397
|
+
"bcc@sanitize_email.org"
|
398
|
+
)
|
277
399
|
#puts "email headers:\n#{@email_message.header}"
|
278
400
|
end
|
279
401
|
it "should not prepend originals by default" do
|
280
|
-
expect(@email_message).not_to have_to_username(
|
281
|
-
|
402
|
+
expect(@email_message).not_to have_to_username(
|
403
|
+
"to at example.org <to@sanitize_email.org>"
|
404
|
+
)
|
405
|
+
expect(@email_message).not_to have_subject(
|
406
|
+
"(to at example.org) original subject"
|
407
|
+
)
|
282
408
|
end
|
283
409
|
end
|
284
410
|
|
@@ -289,15 +415,17 @@ describe SanitizeEmail do
|
|
289
415
|
mail_delivery_hot_mess
|
290
416
|
end
|
291
417
|
it "original to is prepended to subject" do
|
292
|
-
|
418
|
+
regex = /\(same at example.org\).*original subject/
|
419
|
+
expect(@email_message).to match_subject(regex)
|
293
420
|
end
|
294
421
|
it "original to is only prepended once to subject" do
|
295
|
-
|
422
|
+
regex = /\(same at example.org\).*\(same at example.org\).*original subject/
|
423
|
+
expect(@email_message).not_to match_subject(regex)
|
296
424
|
end
|
297
425
|
it "should not alter non-sanitized attributes" do
|
298
|
-
expect(@email_message).to have_from(
|
299
|
-
expect(@email_message).to have_reply_to(
|
300
|
-
expect(@email_message).to have_body_text(
|
426
|
+
expect(@email_message).to have_from("same@example.org")
|
427
|
+
expect(@email_message).to have_reply_to("same@example.org")
|
428
|
+
expect(@email_message).to have_body_text("funky fresh")
|
301
429
|
end
|
302
430
|
it "should not prepend overrides" do
|
303
431
|
expect(@email_message).not_to have_to_username("same at example.org")
|
@@ -310,19 +438,35 @@ describe SanitizeEmail do
|
|
310
438
|
expect(@email_message).not_to have_bcc("same@example.org")
|
311
439
|
end
|
312
440
|
it "should set headers of originals" do
|
313
|
-
expect(@email_message).to have_header(
|
314
|
-
|
441
|
+
expect(@email_message).to have_header(
|
442
|
+
"X-Sanitize-Email-To",
|
443
|
+
"same@example.org"
|
444
|
+
)
|
445
|
+
expect(@email_message).to have_header(
|
446
|
+
"X-Sanitize-Email-Cc",
|
447
|
+
"same@example.org"
|
448
|
+
)
|
315
449
|
end
|
316
450
|
it "should not set headers of bcc" do
|
317
|
-
expect(@email_message).not_to have_header(
|
451
|
+
expect(@email_message).not_to have_header(
|
452
|
+
"X-Sanitize-Email-Bcc",
|
453
|
+
"same@example.org"
|
454
|
+
)
|
318
455
|
end
|
319
456
|
it "should not set headers of overrides" do
|
320
|
-
expect(@email_message).not_to have_header(
|
321
|
-
|
457
|
+
expect(@email_message).not_to have_header(
|
458
|
+
"X-Sanitize-Email-Bcc",
|
459
|
+
"same@example.org"
|
460
|
+
)
|
461
|
+
# puts "email headers:\n#{@email_message.header}"
|
322
462
|
end
|
323
463
|
it "should not prepend originals by default" do
|
324
|
-
expect(@email_message).not_to have_to_username(
|
325
|
-
|
464
|
+
expect(@email_message).not_to have_to_username(
|
465
|
+
"same at example.org <same@example.org>"
|
466
|
+
)
|
467
|
+
expect(@email_message).not_to have_subject(
|
468
|
+
"(same at example.org) original subject"
|
469
|
+
)
|
326
470
|
end
|
327
471
|
end
|
328
472
|
|
@@ -330,14 +474,14 @@ describe SanitizeEmail do
|
|
330
474
|
context "true" do
|
331
475
|
before(:each) do
|
332
476
|
# Should turn off sanitization using the force_sanitize
|
333
|
-
configure_sanitize_email(
|
477
|
+
configure_sanitize_email(activation_proc: proc { true })
|
334
478
|
SanitizeEmail.force_sanitize = true
|
335
479
|
mail_delivery
|
336
480
|
end
|
337
481
|
it "should not alter non-sanitized attributes" do
|
338
|
-
expect(@email_message).to have_from(
|
339
|
-
expect(@email_message).to have_reply_to(
|
340
|
-
expect(@email_message).to have_body_text(
|
482
|
+
expect(@email_message).to have_from("from@example.org")
|
483
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
484
|
+
expect(@email_message).to have_body_text("funky fresh")
|
341
485
|
end
|
342
486
|
it "should override" do
|
343
487
|
expect(@email_message).to have_to("to@sanitize_email.org")
|
@@ -345,75 +489,109 @@ describe SanitizeEmail do
|
|
345
489
|
expect(@email_message).to have_bcc("bcc@sanitize_email.org")
|
346
490
|
end
|
347
491
|
it "should set headers" do
|
348
|
-
expect(@email_message).to have_header(
|
349
|
-
|
350
|
-
|
492
|
+
expect(@email_message).to have_header(
|
493
|
+
"X-Sanitize-Email-To",
|
494
|
+
"to@example.org"
|
495
|
+
)
|
496
|
+
expect(@email_message).to have_header(
|
497
|
+
"X-Sanitize-Email-Cc",
|
498
|
+
"cc@example.org"
|
499
|
+
)
|
500
|
+
expect(@email_message).not_to have_header(
|
501
|
+
"X-Sanitize-Email-Bcc",
|
502
|
+
"bcc@sanitize_email.org"
|
503
|
+
)
|
351
504
|
end
|
352
505
|
end
|
353
506
|
context "false" do
|
354
507
|
before(:each) do
|
355
508
|
# Should turn off sanitization using the force_sanitize
|
356
|
-
configure_sanitize_email(
|
509
|
+
configure_sanitize_email(activation_proc: proc { true })
|
357
510
|
SanitizeEmail.force_sanitize = false
|
358
511
|
mail_delivery
|
359
512
|
end
|
360
513
|
it "should not alter non-sanitized attributes" do
|
361
|
-
expect(@email_message).to have_from(
|
362
|
-
expect(@email_message).to have_reply_to(
|
363
|
-
expect(@email_message).to have_body_text(
|
514
|
+
expect(@email_message).to have_from("from@example.org")
|
515
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
516
|
+
expect(@email_message).to have_body_text("funky fresh")
|
364
517
|
end
|
365
518
|
it "should not alter normally sanitized attributes" do
|
366
519
|
expect(@email_message).to have_to("to@example.org")
|
367
520
|
expect(@email_message).to have_cc("cc@example.org")
|
368
521
|
expect(@email_message).to have_bcc("bcc@example.org")
|
369
|
-
expect(@email_message).not_to have_header(
|
370
|
-
|
371
|
-
|
522
|
+
expect(@email_message).not_to have_header(
|
523
|
+
"X-Sanitize-Email-To",
|
524
|
+
"to@example.org"
|
525
|
+
)
|
526
|
+
expect(@email_message).not_to have_header(
|
527
|
+
"X-Sanitize-Email-Cc",
|
528
|
+
"cc@example.org"
|
529
|
+
)
|
530
|
+
expect(@email_message).not_to have_header(
|
531
|
+
"X-Sanitize-Email-Bcc",
|
532
|
+
"bcc@example.org"
|
533
|
+
)
|
372
534
|
end
|
373
535
|
end
|
374
536
|
context "nil" do
|
375
537
|
context "activation proc enables" do
|
376
538
|
before(:each) do
|
377
|
-
sanitize_spec_dryer
|
378
539
|
# Should ignore force_sanitize setting
|
379
|
-
configure_sanitize_email(
|
540
|
+
configure_sanitize_email(activation_proc: proc { true })
|
380
541
|
SanitizeEmail.force_sanitize = nil
|
381
542
|
mail_delivery
|
382
543
|
end
|
383
544
|
it "should not alter non-sanitized attributes" do
|
384
|
-
expect(@email_message).to have_from(
|
385
|
-
expect(@email_message).to have_reply_to(
|
386
|
-
expect(@email_message).to have_body_text(
|
545
|
+
expect(@email_message).to have_from("from@example.org")
|
546
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
547
|
+
expect(@email_message).to have_body_text("funky fresh")
|
387
548
|
end
|
388
549
|
it "should override" do
|
389
550
|
expect(@email_message).to have_to("to@sanitize_email.org")
|
390
551
|
expect(@email_message).to have_cc("cc@sanitize_email.org")
|
391
552
|
expect(@email_message).to have_bcc("bcc@sanitize_email.org")
|
392
|
-
expect(@email_message).to have_header(
|
393
|
-
|
394
|
-
|
553
|
+
expect(@email_message).to have_header(
|
554
|
+
"X-Sanitize-Email-To",
|
555
|
+
"to@example.org"
|
556
|
+
)
|
557
|
+
expect(@email_message).to have_header(
|
558
|
+
"X-Sanitize-Email-Cc",
|
559
|
+
"cc@example.org"
|
560
|
+
)
|
561
|
+
expect(@email_message).not_to have_header(
|
562
|
+
"X-Sanitize-Email-Bcc",
|
563
|
+
"bcc@sanitize_email.org"
|
564
|
+
)
|
395
565
|
end
|
396
566
|
end
|
397
567
|
context "activation proc disables" do
|
398
568
|
before(:each) do
|
399
|
-
sanitize_spec_dryer
|
400
569
|
# Should ignore force_sanitize setting
|
401
|
-
configure_sanitize_email(
|
570
|
+
configure_sanitize_email(activation_proc: proc { false })
|
402
571
|
SanitizeEmail.force_sanitize = nil
|
403
572
|
mail_delivery
|
404
573
|
end
|
405
574
|
it "should not alter non-sanitized attributes" do
|
406
|
-
expect(@email_message).to have_from(
|
407
|
-
expect(@email_message).to have_reply_to(
|
408
|
-
expect(@email_message).to have_body_text(
|
575
|
+
expect(@email_message).to have_from("from@example.org")
|
576
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
577
|
+
expect(@email_message).to have_body_text("funky fresh")
|
409
578
|
end
|
410
579
|
it "should not alter normally sanitized attributes" do
|
411
580
|
expect(@email_message).to have_to("to@example.org")
|
412
581
|
expect(@email_message).to have_cc("cc@example.org")
|
413
582
|
expect(@email_message).to have_bcc("bcc@example.org")
|
414
|
-
expect(@email_message).not_to have_header(
|
415
|
-
|
416
|
-
|
583
|
+
expect(@email_message).not_to have_header(
|
584
|
+
"X-Sanitize-Email-To",
|
585
|
+
"to@example.org"
|
586
|
+
)
|
587
|
+
expect(@email_message).not_to have_header(
|
588
|
+
"X-Sanitize-Email-Cc",
|
589
|
+
"cc@example.org"
|
590
|
+
)
|
591
|
+
expect(@email_message).not_to have_header(
|
592
|
+
"X-Sanitize-Email-Bcc",
|
593
|
+
"bcc@example.org"
|
594
|
+
)
|
417
595
|
end
|
418
596
|
end
|
419
597
|
end
|
@@ -424,40 +602,57 @@ describe SanitizeEmail do
|
|
424
602
|
context ":use_actual_environment_prepended_to_subject" do
|
425
603
|
context "true" do
|
426
604
|
before(:each) do
|
427
|
-
configure_sanitize_email(
|
605
|
+
configure_sanitize_email(
|
606
|
+
environment: "{{serverABC}}",
|
607
|
+
use_actual_environment_prepended_to_subject: true
|
608
|
+
)
|
428
609
|
sanitary_mail_delivery
|
429
610
|
end
|
430
611
|
it "original to is prepended" do
|
431
|
-
expect(@email_message).to have_subject(
|
612
|
+
expect(@email_message).to have_subject(
|
613
|
+
"{{serverABC}} original subject"
|
614
|
+
)
|
432
615
|
end
|
433
616
|
it "should not alter non-sanitized attributes" do
|
434
|
-
expect(@email_message).to have_from(
|
435
|
-
expect(@email_message).to have_reply_to(
|
436
|
-
expect(@email_message).to have_body_text(
|
617
|
+
expect(@email_message).to have_from("from@example.org")
|
618
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
619
|
+
expect(@email_message).to have_body_text("funky fresh")
|
437
620
|
end
|
438
621
|
it "should not prepend overrides" do
|
439
|
-
expect(@email_message).not_to have_to_username(
|
440
|
-
|
622
|
+
expect(@email_message).not_to have_to_username(
|
623
|
+
"to at sanitize_email.org"
|
624
|
+
)
|
625
|
+
expect(@email_message).not_to have_subject(
|
626
|
+
"(to at sanitize_email.org)"
|
627
|
+
)
|
441
628
|
end
|
442
629
|
end
|
443
630
|
context "false" do
|
444
631
|
before(:each) do
|
445
|
-
|
446
|
-
|
632
|
+
configure_sanitize_email(
|
633
|
+
environment: "{{serverABC}}",
|
634
|
+
use_actual_environment_prepended_to_subject: false
|
635
|
+
)
|
447
636
|
sanitary_mail_delivery
|
448
637
|
end
|
449
638
|
it "original to is not prepended" do
|
450
|
-
expect(@email_message).not_to have_subject(
|
639
|
+
expect(@email_message).not_to have_subject(
|
640
|
+
"{{serverABC}} original subject"
|
641
|
+
)
|
451
642
|
expect(@email_message.subject).to eq("original subject")
|
452
643
|
end
|
453
644
|
it "should not alter non-sanitized attributes" do
|
454
|
-
expect(@email_message).to have_from(
|
455
|
-
expect(@email_message).to have_reply_to(
|
456
|
-
expect(@email_message).to have_body_text(
|
645
|
+
expect(@email_message).to have_from("from@example.org")
|
646
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
647
|
+
expect(@email_message).to have_body_text("funky fresh")
|
457
648
|
end
|
458
649
|
it "should not prepend overrides" do
|
459
|
-
expect(@email_message).not_to have_to_username(
|
460
|
-
|
650
|
+
expect(@email_message).not_to have_to_username(
|
651
|
+
"to at sanitize_email.org"
|
652
|
+
)
|
653
|
+
expect(@email_message).not_to have_subject(
|
654
|
+
"(to at sanitize_email.org)"
|
655
|
+
)
|
461
656
|
end
|
462
657
|
end
|
463
658
|
end
|
@@ -465,40 +660,77 @@ describe SanitizeEmail do
|
|
465
660
|
context ":use_actual_email_prepended_to_subject" do
|
466
661
|
context "true" do
|
467
662
|
before(:each) do
|
468
|
-
|
469
|
-
configure_sanitize_email({:use_actual_email_prepended_to_subject => true})
|
470
|
-
sanitary_mail_delivery
|
471
|
-
end
|
472
|
-
it "original to is prepended" do
|
473
|
-
expect(@email_message).to have_subject("(to at example.org) original subject")
|
663
|
+
configure_sanitize_email(use_actual_email_prepended_to_subject: true)
|
474
664
|
end
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
665
|
+
context "to address is an array" do
|
666
|
+
before do
|
667
|
+
sanitary_mail_delivery_multiple_recipients
|
668
|
+
end
|
669
|
+
it "original to is prepended" do
|
670
|
+
expect(@email_message).to have_subject(
|
671
|
+
"(to1 at example.org,to2 at example.org,to3 at example.org) original subject"
|
672
|
+
)
|
673
|
+
end
|
674
|
+
it "should not alter non-sanitized attributes" do
|
675
|
+
expect(@email_message).to have_from("from@example.org")
|
676
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
677
|
+
expect(@email_message).to have_body_text("funky fresh")
|
678
|
+
end
|
679
|
+
it "should not prepend overrides" do
|
680
|
+
expect(@email_message).not_to have_to_username(
|
681
|
+
"to at sanitize_email.org"
|
682
|
+
)
|
683
|
+
expect(@email_message).not_to have_subject(
|
684
|
+
"(to at sanitize_email.org)"
|
685
|
+
)
|
686
|
+
end
|
479
687
|
end
|
480
|
-
|
481
|
-
|
482
|
-
|
688
|
+
context "to address is not an array" do
|
689
|
+
before do
|
690
|
+
sanitary_mail_delivery
|
691
|
+
end
|
692
|
+
it "original to is prepended" do
|
693
|
+
expect(@email_message).to have_subject(
|
694
|
+
"(to at example.org) original subject"
|
695
|
+
)
|
696
|
+
end
|
697
|
+
it "should not alter non-sanitized attributes" do
|
698
|
+
expect(@email_message).to have_from("from@example.org")
|
699
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
700
|
+
expect(@email_message).to have_body_text("funky fresh")
|
701
|
+
end
|
702
|
+
it "should not prepend overrides" do
|
703
|
+
expect(@email_message).not_to have_to_username(
|
704
|
+
"to at sanitize_email.org"
|
705
|
+
)
|
706
|
+
expect(@email_message).not_to have_subject(
|
707
|
+
"(to at sanitize_email.org)"
|
708
|
+
)
|
709
|
+
end
|
483
710
|
end
|
484
711
|
end
|
485
712
|
context "false" do
|
486
713
|
before(:each) do
|
487
|
-
|
488
|
-
configure_sanitize_email({:use_actual_email_prepended_to_subject => false})
|
714
|
+
configure_sanitize_email(use_actual_email_prepended_to_subject: false)
|
489
715
|
sanitary_mail_delivery
|
490
716
|
end
|
491
717
|
it "original to is not prepended" do
|
492
|
-
expect(@email_message).not_to have_subject(
|
718
|
+
expect(@email_message).not_to have_subject(
|
719
|
+
"(to at example.org) original subject"
|
720
|
+
)
|
493
721
|
end
|
494
722
|
it "should not alter non-sanitized attributes" do
|
495
|
-
expect(@email_message).to have_from(
|
496
|
-
expect(@email_message).to have_reply_to(
|
497
|
-
expect(@email_message).to have_body_text(
|
723
|
+
expect(@email_message).to have_from("from@example.org")
|
724
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
725
|
+
expect(@email_message).to have_body_text("funky fresh")
|
498
726
|
end
|
499
727
|
it "should not prepend overrides" do
|
500
|
-
expect(@email_message).not_to have_to_username(
|
501
|
-
|
728
|
+
expect(@email_message).not_to have_to_username(
|
729
|
+
"to at sanitize_email.org"
|
730
|
+
)
|
731
|
+
expect(@email_message).not_to have_subject(
|
732
|
+
"(to at sanitize_email.org)"
|
733
|
+
)
|
502
734
|
end
|
503
735
|
end
|
504
736
|
end
|
@@ -506,40 +738,107 @@ describe SanitizeEmail do
|
|
506
738
|
context ":use_actual_email_as_sanitized_user_name" do
|
507
739
|
context "true" do
|
508
740
|
before(:each) do
|
509
|
-
|
510
|
-
|
741
|
+
configure_sanitize_email(
|
742
|
+
use_actual_email_as_sanitized_user_name: true
|
743
|
+
)
|
511
744
|
sanitary_mail_delivery
|
512
745
|
end
|
513
746
|
it "original to is munged and prepended" do
|
514
|
-
expect(@email_message).to have_to_username(
|
747
|
+
expect(@email_message).to have_to_username(
|
748
|
+
"to at example.org <to@sanitize_email.org>"
|
749
|
+
)
|
515
750
|
end
|
516
751
|
it "should not alter non-sanitized attributes" do
|
517
|
-
expect(@email_message).to have_from(
|
518
|
-
expect(@email_message).to have_reply_to(
|
519
|
-
expect(@email_message).to have_body_text(
|
752
|
+
expect(@email_message).to have_from("from@example.org")
|
753
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
754
|
+
expect(@email_message).to have_body_text("funky fresh")
|
520
755
|
end
|
521
756
|
it "should not prepend overrides" do
|
522
|
-
expect(@email_message).not_to have_to_username(
|
523
|
-
|
757
|
+
expect(@email_message).not_to have_to_username(
|
758
|
+
"to at sanitize_email.org"
|
759
|
+
)
|
760
|
+
expect(@email_message).not_to have_subject(
|
761
|
+
"(to at sanitize_email.org)"
|
762
|
+
)
|
524
763
|
end
|
525
764
|
end
|
526
765
|
context "false" do
|
527
766
|
before(:each) do
|
528
|
-
|
529
|
-
|
767
|
+
configure_sanitize_email(
|
768
|
+
use_actual_email_as_sanitized_user_name: false
|
769
|
+
)
|
530
770
|
sanitary_mail_delivery
|
531
771
|
end
|
532
772
|
it "original to is not prepended" do
|
533
|
-
expect(@email_message).not_to have_to_username(
|
773
|
+
expect(@email_message).not_to have_to_username(
|
774
|
+
"to at example.org <to@sanitize_email.org>"
|
775
|
+
)
|
776
|
+
end
|
777
|
+
it "should not alter non-sanitized attributes" do
|
778
|
+
expect(@email_message).to have_from("from@example.org")
|
779
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
780
|
+
expect(@email_message).to have_body_text("funky fresh")
|
781
|
+
end
|
782
|
+
it "should not prepend overrides" do
|
783
|
+
expect(@email_message).not_to have_to_username(
|
784
|
+
"to at sanitize_email.org"
|
785
|
+
)
|
786
|
+
expect(@email_message).not_to have_subject(
|
787
|
+
"(to at sanitize_email.org)"
|
788
|
+
)
|
789
|
+
end
|
790
|
+
end
|
791
|
+
end
|
792
|
+
|
793
|
+
context ":engage" do
|
794
|
+
context "is true" do
|
795
|
+
before(:each) do
|
796
|
+
# Should turn off sanitization using the force_sanitize
|
797
|
+
configure_sanitize_email(
|
798
|
+
engage: true,
|
799
|
+
sanitized_recipients: "marv@example.org",
|
800
|
+
use_actual_email_prepended_to_subject: true,
|
801
|
+
use_actual_email_as_sanitized_user_name: true
|
802
|
+
)
|
803
|
+
mail_delivery
|
804
|
+
end
|
805
|
+
it "should not alter non-sanitized attributes" do
|
806
|
+
expect(@email_message).to have_from("from@example.org")
|
807
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
808
|
+
expect(@email_message).to have_body_text("funky fresh")
|
809
|
+
end
|
810
|
+
it "should prepend overrides" do
|
811
|
+
expect(@email_message).to have_to_username("to at example.org")
|
812
|
+
expect(@email_message).to have_subject("(to at example.org)")
|
813
|
+
end
|
814
|
+
it "should alter normally sanitized attributes" do
|
815
|
+
expect(@email_message).not_to have_to("to@example.org")
|
816
|
+
expect(@email_message).to have_to("marv@example.org")
|
817
|
+
end
|
818
|
+
end
|
819
|
+
context "is false" do
|
820
|
+
before(:each) do
|
821
|
+
# Should turn off sanitization using the force_sanitize
|
822
|
+
configure_sanitize_email(
|
823
|
+
engage: false,
|
824
|
+
sanitized_recipients: "marv@example.org",
|
825
|
+
use_actual_email_prepended_to_subject: true,
|
826
|
+
use_actual_email_as_sanitized_user_name: true
|
827
|
+
)
|
828
|
+
mail_delivery
|
534
829
|
end
|
535
830
|
it "should not alter non-sanitized attributes" do
|
536
|
-
expect(@email_message).to have_from(
|
537
|
-
expect(@email_message).to have_reply_to(
|
538
|
-
expect(@email_message).to have_body_text(
|
831
|
+
expect(@email_message).to have_from("from@example.org")
|
832
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
833
|
+
expect(@email_message).to have_body_text("funky fresh")
|
539
834
|
end
|
540
835
|
it "should not prepend overrides" do
|
541
|
-
expect(@email_message).not_to have_to_username("to at
|
542
|
-
expect(@email_message).not_to have_subject("(to at
|
836
|
+
expect(@email_message).not_to have_to_username("to at example.org")
|
837
|
+
expect(@email_message).not_to have_subject("(to at example.org)")
|
838
|
+
end
|
839
|
+
it "should not alter normally sanitized attributes" do
|
840
|
+
expect(@email_message).to have_to("to@example.org")
|
841
|
+
expect(@email_message).not_to have_to("marv@example.org")
|
543
842
|
end
|
544
843
|
end
|
545
844
|
end
|
@@ -551,33 +850,33 @@ describe SanitizeEmail do
|
|
551
850
|
context ":local_environments" do
|
552
851
|
context "matching" do
|
553
852
|
before(:each) do
|
554
|
-
|
555
|
-
configure_sanitize_email({:local_environments => ['test']})
|
853
|
+
configure_sanitize_email(local_environments: ["test"])
|
556
854
|
expect(SanitizeEmail[:activation_proc].call).to eq(true)
|
557
855
|
mail_delivery
|
558
856
|
end
|
559
857
|
it "should not alter non-sanitized attributes" do
|
560
|
-
expect(@email_message).to have_from(
|
561
|
-
expect(@email_message).to have_reply_to(
|
562
|
-
expect(@email_message).to have_body_text(
|
858
|
+
expect(@email_message).to have_from("from@example.org")
|
859
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
860
|
+
expect(@email_message).to have_body_text("funky fresh")
|
563
861
|
end
|
564
862
|
it "should use activation_proc for matching environment" do
|
565
|
-
expect(@email_message).to
|
566
|
-
expect(@email_message).to
|
567
|
-
expect(@email_message).to
|
863
|
+
expect(@email_message).to match_to("to@sanitize_email.org")
|
864
|
+
expect(@email_message).to match_cc("cc@sanitize_email.org")
|
865
|
+
expect(@email_message).to match_bcc("bcc@sanitize_email.org")
|
568
866
|
end
|
569
867
|
end
|
570
868
|
context "non-matching" do
|
571
869
|
before(:each) do
|
572
|
-
sanitize_spec_dryer(
|
573
|
-
|
870
|
+
sanitize_spec_dryer("production")
|
871
|
+
# Won't match!
|
872
|
+
configure_sanitize_email(local_environments: ["development"])
|
574
873
|
expect(SanitizeEmail[:activation_proc].call).to eq(false)
|
575
874
|
mail_delivery
|
576
875
|
end
|
577
876
|
it "should not alter non-sanitized attributes" do
|
578
|
-
expect(@email_message).to have_from(
|
579
|
-
expect(@email_message).to have_reply_to(
|
580
|
-
expect(@email_message).to have_body_text(
|
877
|
+
expect(@email_message).to have_from("from@example.org")
|
878
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
879
|
+
expect(@email_message).to have_body_text("funky fresh")
|
581
880
|
end
|
582
881
|
it "should use activation_proc for non-matching environment" do
|
583
882
|
expect(@email_message).to have_to("to@example.org")
|
@@ -589,14 +888,15 @@ describe SanitizeEmail do
|
|
589
888
|
|
590
889
|
context ":sanitized_recipients" do
|
591
890
|
before(:each) do
|
592
|
-
|
593
|
-
|
891
|
+
configure_sanitize_email(
|
892
|
+
sanitized_recipients: "barney@sanitize_email.org"
|
893
|
+
)
|
594
894
|
sanitary_mail_delivery
|
595
895
|
end
|
596
896
|
it "should not alter non-sanitized attributes" do
|
597
|
-
expect(@email_message).to have_from(
|
598
|
-
expect(@email_message).to have_reply_to(
|
599
|
-
expect(@email_message).to have_body_text(
|
897
|
+
expect(@email_message).to have_from("from@example.org")
|
898
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
899
|
+
expect(@email_message).to have_body_text("funky fresh")
|
600
900
|
end
|
601
901
|
it "used as sanitized_to" do
|
602
902
|
expect(@email_message).to have_to("barney@sanitize_email.org")
|
@@ -605,21 +905,22 @@ describe SanitizeEmail do
|
|
605
905
|
|
606
906
|
context ":force_sanitize" do
|
607
907
|
before(:each) do
|
608
|
-
sanitize_spec_dryer
|
609
908
|
# Should turn off sanitization using the force_sanitize
|
610
|
-
configure_sanitize_email(
|
909
|
+
configure_sanitize_email(
|
910
|
+
activation_proc: proc { true },
|
911
|
+
force_sanitize: false
|
912
|
+
)
|
611
913
|
mail_delivery
|
612
914
|
end
|
613
915
|
it "should not alter non-sanitized attributes" do
|
614
|
-
expect(@email_message).to have_from(
|
615
|
-
expect(@email_message).to have_reply_to(
|
616
|
-
expect(@email_message).to have_body_text(
|
916
|
+
expect(@email_message).to have_from("from@example.org")
|
917
|
+
expect(@email_message).to have_reply_to("reply_to@example.org")
|
918
|
+
expect(@email_message).to have_body_text("funky fresh")
|
617
919
|
end
|
618
920
|
it "should not alter normally sanitized attributes" do
|
619
921
|
expect(@email_message).to have_to("to@example.org")
|
620
922
|
end
|
621
923
|
end
|
622
|
-
|
623
924
|
end
|
624
925
|
end
|
625
926
|
end
|