sanitize_email 1.0.5 → 1.0.6
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.
- data/.gitignore +1 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +53 -52
- data/README.md +48 -19
- data/lib/sanitize_email/bleach.rb +10 -2
- data/lib/sanitize_email/config.rb +4 -0
- data/lib/sanitize_email/version.rb +1 -1
- data/spec/sanitize_email_spec.rb +50 -9
- data/spec/spec_helper.rb +3 -0
- metadata +2 -2
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,119 +1,120 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
sanitize_email (1.0.
|
|
4
|
+
sanitize_email (1.0.5)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: http://rubygems.org/
|
|
8
8
|
specs:
|
|
9
|
-
actionmailer (3.2.
|
|
10
|
-
actionpack (= 3.2.
|
|
9
|
+
actionmailer (3.2.9)
|
|
10
|
+
actionpack (= 3.2.9)
|
|
11
11
|
mail (~> 2.4.4)
|
|
12
|
-
actionpack (3.2.
|
|
13
|
-
activemodel (= 3.2.
|
|
14
|
-
activesupport (= 3.2.
|
|
12
|
+
actionpack (3.2.9)
|
|
13
|
+
activemodel (= 3.2.9)
|
|
14
|
+
activesupport (= 3.2.9)
|
|
15
15
|
builder (~> 3.0.0)
|
|
16
16
|
erubis (~> 2.7.0)
|
|
17
17
|
journey (~> 1.0.4)
|
|
18
18
|
rack (~> 1.4.0)
|
|
19
19
|
rack-cache (~> 1.2)
|
|
20
20
|
rack-test (~> 0.6.1)
|
|
21
|
-
sprockets (~> 2.1
|
|
22
|
-
activemodel (3.2.
|
|
23
|
-
activesupport (= 3.2.
|
|
21
|
+
sprockets (~> 2.2.1)
|
|
22
|
+
activemodel (3.2.9)
|
|
23
|
+
activesupport (= 3.2.9)
|
|
24
24
|
builder (~> 3.0.0)
|
|
25
|
-
activerecord (3.2.
|
|
26
|
-
activemodel (= 3.2.
|
|
27
|
-
activesupport (= 3.2.
|
|
25
|
+
activerecord (3.2.9)
|
|
26
|
+
activemodel (= 3.2.9)
|
|
27
|
+
activesupport (= 3.2.9)
|
|
28
28
|
arel (~> 3.0.2)
|
|
29
29
|
tzinfo (~> 0.3.29)
|
|
30
|
-
activeresource (3.2.
|
|
31
|
-
activemodel (= 3.2.
|
|
32
|
-
activesupport (= 3.2.
|
|
33
|
-
activesupport (3.2.
|
|
30
|
+
activeresource (3.2.9)
|
|
31
|
+
activemodel (= 3.2.9)
|
|
32
|
+
activesupport (= 3.2.9)
|
|
33
|
+
activesupport (3.2.9)
|
|
34
34
|
i18n (~> 0.6)
|
|
35
35
|
multi_json (~> 1.0)
|
|
36
|
-
addressable (2.2
|
|
36
|
+
addressable (2.3.2)
|
|
37
37
|
arel (3.0.2)
|
|
38
|
-
builder (3.0.
|
|
38
|
+
builder (3.0.4)
|
|
39
39
|
diff-lcs (1.1.3)
|
|
40
|
-
email_spec (1.
|
|
40
|
+
email_spec (1.4.0)
|
|
41
|
+
launchy (~> 2.1)
|
|
41
42
|
mail (~> 2.2)
|
|
42
|
-
rspec (~> 2.0)
|
|
43
43
|
erubis (2.7.0)
|
|
44
44
|
hike (1.2.1)
|
|
45
|
-
i18n (0.6.
|
|
45
|
+
i18n (0.6.1)
|
|
46
46
|
journey (1.0.4)
|
|
47
|
-
json (1.7.
|
|
48
|
-
launchy (2.1.
|
|
49
|
-
addressable (~> 2.
|
|
50
|
-
letter_opener (0.0
|
|
51
|
-
launchy
|
|
47
|
+
json (1.7.5)
|
|
48
|
+
launchy (2.1.2)
|
|
49
|
+
addressable (~> 2.3)
|
|
50
|
+
letter_opener (1.0.0)
|
|
51
|
+
launchy (>= 2.0.4)
|
|
52
52
|
mail (2.4.4)
|
|
53
53
|
i18n (>= 0.4.0)
|
|
54
54
|
mime-types (~> 1.16)
|
|
55
55
|
treetop (~> 1.4.8)
|
|
56
56
|
mime-types (1.19)
|
|
57
|
-
multi_json (1.
|
|
57
|
+
multi_json (1.5.0)
|
|
58
58
|
polyglot (0.3.3)
|
|
59
59
|
rack (1.4.1)
|
|
60
60
|
rack-cache (1.2)
|
|
61
61
|
rack (>= 0.4)
|
|
62
62
|
rack-ssl (1.3.2)
|
|
63
63
|
rack
|
|
64
|
-
rack-test (0.6.
|
|
64
|
+
rack-test (0.6.2)
|
|
65
65
|
rack (>= 1.0)
|
|
66
|
-
rails (3.2.
|
|
67
|
-
actionmailer (= 3.2.
|
|
68
|
-
actionpack (= 3.2.
|
|
69
|
-
activerecord (= 3.2.
|
|
70
|
-
activeresource (= 3.2.
|
|
71
|
-
activesupport (= 3.2.
|
|
66
|
+
rails (3.2.9)
|
|
67
|
+
actionmailer (= 3.2.9)
|
|
68
|
+
actionpack (= 3.2.9)
|
|
69
|
+
activerecord (= 3.2.9)
|
|
70
|
+
activeresource (= 3.2.9)
|
|
71
|
+
activesupport (= 3.2.9)
|
|
72
72
|
bundler (~> 1.0)
|
|
73
|
-
railties (= 3.2.
|
|
74
|
-
railties (3.2.
|
|
75
|
-
actionpack (= 3.2.
|
|
76
|
-
activesupport (= 3.2.
|
|
73
|
+
railties (= 3.2.9)
|
|
74
|
+
railties (3.2.9)
|
|
75
|
+
actionpack (= 3.2.9)
|
|
76
|
+
activesupport (= 3.2.9)
|
|
77
77
|
rack-ssl (~> 1.3.2)
|
|
78
78
|
rake (>= 0.8.7)
|
|
79
79
|
rdoc (~> 3.4)
|
|
80
80
|
thor (>= 0.14.6, < 2.0)
|
|
81
|
-
rake (0.
|
|
81
|
+
rake (10.0.3)
|
|
82
82
|
rdoc (3.12)
|
|
83
83
|
json (~> 1.4)
|
|
84
|
-
reek (1.2.
|
|
84
|
+
reek (1.2.13)
|
|
85
85
|
ripper_ruby_parser (~> 0.0.7)
|
|
86
86
|
ruby2ruby (~> 1.2.5)
|
|
87
87
|
ruby_parser (~> 2.0)
|
|
88
88
|
sexp_processor (~> 3.0)
|
|
89
|
-
ripper_ruby_parser (0.0.
|
|
89
|
+
ripper_ruby_parser (0.0.8)
|
|
90
90
|
sexp_processor (~> 3.0)
|
|
91
91
|
roodi (2.1.0)
|
|
92
92
|
ruby_parser
|
|
93
|
-
rspec (2.
|
|
94
|
-
rspec-core (~> 2.
|
|
95
|
-
rspec-expectations (~> 2.
|
|
96
|
-
rspec-mocks (~> 2.
|
|
97
|
-
rspec-core (2.
|
|
98
|
-
rspec-expectations (2.
|
|
93
|
+
rspec (2.12.0)
|
|
94
|
+
rspec-core (~> 2.12.0)
|
|
95
|
+
rspec-expectations (~> 2.12.0)
|
|
96
|
+
rspec-mocks (~> 2.12.0)
|
|
97
|
+
rspec-core (2.12.2)
|
|
98
|
+
rspec-expectations (2.12.1)
|
|
99
99
|
diff-lcs (~> 1.1.3)
|
|
100
|
-
rspec-mocks (2.
|
|
100
|
+
rspec-mocks (2.12.0)
|
|
101
101
|
ruby2ruby (1.2.5)
|
|
102
102
|
ruby_parser (~> 2.0)
|
|
103
103
|
sexp_processor (~> 3.0)
|
|
104
104
|
ruby_parser (2.3.1)
|
|
105
105
|
sexp_processor (~> 3.0)
|
|
106
106
|
sexp_processor (3.2.0)
|
|
107
|
-
sprockets (2.
|
|
107
|
+
sprockets (2.2.2)
|
|
108
108
|
hike (~> 1.2)
|
|
109
|
+
multi_json (~> 1.0)
|
|
109
110
|
rack (~> 1.0)
|
|
110
111
|
tilt (~> 1.1, != 1.3.0)
|
|
111
|
-
thor (0.
|
|
112
|
+
thor (0.16.0)
|
|
112
113
|
tilt (1.3.3)
|
|
113
|
-
treetop (1.4.
|
|
114
|
+
treetop (1.4.12)
|
|
114
115
|
polyglot
|
|
115
116
|
polyglot (>= 0.3.1)
|
|
116
|
-
tzinfo (0.3.
|
|
117
|
+
tzinfo (0.3.35)
|
|
117
118
|
|
|
118
119
|
PLATFORMS
|
|
119
120
|
ruby
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
This gem allows you to override your mail delivery settings, globally or in a local context. It's particularly helpful when you want to omit the delivery of email (e.g. in development/test environments) or alter the to/cc/bcc (e.g. in staging or demo environments) of all email generated from your application.
|
|
4
4
|
|
|
5
|
-
* compatible with Rails >= 3.X (
|
|
5
|
+
* compatible with Rails >= 3.X (since v1.0.5)
|
|
6
6
|
* compatible with any Ruby app with a Mail handler that uses the `register_interceptor` API (a la ActionMailer and Mail gems)
|
|
7
7
|
* configure it and forget it
|
|
8
8
|
* little configuration required
|
|
@@ -17,7 +17,7 @@ This gem allows you to override your mail delivery settings, globally or in a lo
|
|
|
17
17
|
| license | MIT |
|
|
18
18
|
| homepage | https://github.com/pboling/sanitize_email |
|
|
19
19
|
| documentation | http://rdoc.info/github/pboling/sanitize_email/frames |
|
|
20
|
-
| author | [Peter Boling](railsbling.com) [](http://api.coderwall.com/pboling/endorsecount.png) |
|
|
20
|
+
| author | [Peter Boling](http://railsbling.com) [](http://api.coderwall.com/pboling/endorsecount.png) |
|
|
21
21
|
| CI | https://travis-ci.org/pboling/sanitize_email [](https://travis-ci.org/pboling/sanitize_email) |
|
|
22
22
|
| QA | https://codeclimate.com/github/pboling/sanitize_email [](https://codeclimate.com/github/pboling/sanitize_email) |
|
|
23
23
|
|
|
@@ -50,13 +50,14 @@ If you install this gem on a production server (which I don't always do), you ca
|
|
|
50
50
|
Customize and add to an initializer:
|
|
51
51
|
|
|
52
52
|
SanitizeEmail::Config.configure do |config|
|
|
53
|
-
config[:sanitized_to] =
|
|
53
|
+
config[:sanitized_to] = 'to@sanitize_email.org'
|
|
54
54
|
config[:sanitized_cc] = 'cc@sanitize_email.org'
|
|
55
55
|
config[:sanitized_bcc] = 'bcc@sanitize_email.org'
|
|
56
|
-
#
|
|
57
|
-
config[:activation_proc] =
|
|
58
|
-
config[:use_actual_email_prepended_to_subject] = true
|
|
59
|
-
config[:
|
|
56
|
+
# run/call whatever logic should turn sanitize_email on and off in this Proc:
|
|
57
|
+
config[:activation_proc] = Proc.new { %w(development test).include?(Rails.env) }
|
|
58
|
+
config[:use_actual_email_prepended_to_subject] = true # or false
|
|
59
|
+
config[:use_actual_environment_prepended_to_subject] = true # or false
|
|
60
|
+
config[:use_actual_email_as_sanitized_user_name] = true # or false
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
Keep in mind, this is ruby (and possibly rails), so you can add conditionals or utilize different environment.rb files to customize these settings on a per-environment basis.
|
|
@@ -95,30 +96,58 @@ SanitizeEmail.configure block.
|
|
|
95
96
|
end
|
|
96
97
|
end
|
|
97
98
|
|
|
98
|
-
|
|
99
|
+
## Deprecations
|
|
99
100
|
|
|
100
101
|
Sometimes things get deprecated (meaning they still work, but are noisy about it). If this happens to you, and you like your head in the sand, call this number:
|
|
101
102
|
|
|
102
103
|
SanitizeEmail::Deprecation.deprecate_in_silence = true
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
## Authors
|
|
105
106
|
|
|
106
107
|
Peter Boling is the original author of the code, and current maintainer of both the rails 2 and rails 3 development tracks.
|
|
107
108
|
John Trupiano did the initial gemification and some refactoring.
|
|
108
109
|
|
|
109
|
-
|
|
110
|
+
## Contributors
|
|
110
111
|
|
|
111
112
|
See the [Network View](https://github.com/pboling/sanitize_email/network) and the [CHANGELOG](https://github.com/pboling/sanitize_email/blob/master/CHANGELOG.md)
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
## Contributing
|
|
114
115
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
1. Fork it
|
|
117
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
118
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
|
119
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
120
|
+
5. Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
|
121
|
+
6. Create new Pull Request
|
|
119
122
|
|
|
120
|
-
|
|
123
|
+
## Versioning
|
|
121
124
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
This library aims to adhere to [Semantic Versioning 2.0.0][semver].
|
|
126
|
+
Violations of this scheme should be reported as bugs. Specifically,
|
|
127
|
+
if a minor or patch version is released that breaks backward
|
|
128
|
+
compatibility, a new version should be immediately released that
|
|
129
|
+
restores compatibility. Breaking changes to the public API will
|
|
130
|
+
only be introduced with new major versions.
|
|
131
|
+
|
|
132
|
+
As a result of this policy, you can (and should) specify a
|
|
133
|
+
dependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision.
|
|
134
|
+
|
|
135
|
+
For example:
|
|
136
|
+
|
|
137
|
+
spec.add_dependency 'sanitize_email', '~> 4.0'
|
|
138
|
+
|
|
139
|
+
[semver]: http://semver.org/
|
|
140
|
+
[pvc]: http://docs.rubygems.org/read/chapter/16#page74
|
|
141
|
+
|
|
142
|
+
## References
|
|
143
|
+
|
|
144
|
+
* [Source Code](http://github.com/pboling/sanitize_email)
|
|
145
|
+
* [Gem Release Announcement](http://blog.smartlogicsolutions.com/2009/04/25/reintroducing-sanitize_email-work-with-production-email-without-fear/)
|
|
146
|
+
* [Peter's Original Writeup](http://galtzo.blogspot.com/2008/11/sanitize-email-never-worry-about.html)
|
|
147
|
+
* [Using sanitize_email to Preview HTML Emails Locally](http://blog.smartlogicsolutions.com/2009/04/30/using-sanitize-email-to-preview-html-emails-locally/)
|
|
148
|
+
|
|
149
|
+
## Legal
|
|
150
|
+
|
|
151
|
+
* MIT License
|
|
152
|
+
* Copyright (c) 2008-2013 [Peter H. Boling](http://www.railsbling.com) of Acquaintable [http://acquaintable.com/]
|
|
153
|
+
* Copyright (c) 2009 [John Trupiano](http://smartlogicsolutions.com/wiki/John_Trupiano) of [SmartLogic Solutions, LLC](http://www.smartlogicsolutions.com)
|
|
@@ -37,7 +37,9 @@ module SanitizeEmail
|
|
|
37
37
|
|
|
38
38
|
add_original_addresses_as_headers(message)
|
|
39
39
|
|
|
40
|
-
message.subject = self.
|
|
40
|
+
message.subject = self.prepend_email_to_subject(message.subject, message.to) if SanitizeEmail.use_actual_email_prepended_to_subject
|
|
41
|
+
message.subject = self.prepend_environment_to_subject(message.subject) if SanitizeEmail.use_actual_environment_prepended_to_subject
|
|
42
|
+
|
|
41
43
|
message.to = cache_to
|
|
42
44
|
message.cc = cache_cc
|
|
43
45
|
message.bcc = cache_bcc
|
|
@@ -88,7 +90,7 @@ module SanitizeEmail
|
|
|
88
90
|
|
|
89
91
|
end
|
|
90
92
|
|
|
91
|
-
def
|
|
93
|
+
def prepend_email_to_subject(real_subject, actual_addresses)
|
|
92
94
|
if !actual_addresses.respond_to?(:join)
|
|
93
95
|
real_subject
|
|
94
96
|
else
|
|
@@ -96,6 +98,12 @@ module SanitizeEmail
|
|
|
96
98
|
end
|
|
97
99
|
end
|
|
98
100
|
|
|
101
|
+
def prepend_environment_to_subject(real_subject)
|
|
102
|
+
if defined?(Rails) && Rails.env.present?
|
|
103
|
+
"[#{Rails.env}] #{real_subject}"
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
99
107
|
def to_override(actual_addresses)
|
|
100
108
|
to = override_email(:to, actual_addresses)
|
|
101
109
|
raise MissingTo, 'after overriding :to there are no addresses to send in To: header.' if to.empty?
|
|
@@ -32,6 +32,10 @@ module SanitizeEmail
|
|
|
32
32
|
# e.g. "real@example.com rest of subject"
|
|
33
33
|
:use_actual_email_prepended_to_subject => false,
|
|
34
34
|
|
|
35
|
+
# Prepend the Rails environment onto the Subject line of the message
|
|
36
|
+
# e.g. "[development] rest of subject"
|
|
37
|
+
:use_actual_environment_prepended_to_subject => false,
|
|
38
|
+
|
|
35
39
|
:activation_proc => Proc.new { false }
|
|
36
40
|
}
|
|
37
41
|
|
data/spec/sanitize_email_spec.rb
CHANGED
|
@@ -9,6 +9,7 @@ describe SanitizeEmail do
|
|
|
9
9
|
:sanitized_cc => 'cc@sanitize_email.org',
|
|
10
10
|
:sanitized_bcc => 'bcc@sanitize_email.org',
|
|
11
11
|
:use_actual_email_prepended_to_subject => false,
|
|
12
|
+
:use_actual_environment_prepended_to_subject => false,
|
|
12
13
|
:use_actual_email_as_sanitized_user_name => false
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -42,6 +43,7 @@ describe SanitizeEmail do
|
|
|
42
43
|
config[:sanitized_cc] = options[:sanitized_cc]
|
|
43
44
|
config[:sanitized_bcc] = options[:sanitized_bcc]
|
|
44
45
|
config[:use_actual_email_prepended_to_subject] = options[:use_actual_email_prepended_to_subject]
|
|
46
|
+
config[:use_actual_environment_prepended_to_subject] = options[:use_actual_environment_prepended_to_subject]
|
|
45
47
|
config[:use_actual_email_as_sanitized_user_name] = options[:use_actual_email_as_sanitized_user_name]
|
|
46
48
|
|
|
47
49
|
# For testing *deprecated* configuration options:
|
|
@@ -124,7 +126,7 @@ describe SanitizeEmail do
|
|
|
124
126
|
@email_message.should have_bcc("bcc@sanitize_email.org")
|
|
125
127
|
@email_message.should have_header("X-Sanitize-Email-To", "to@example.org")
|
|
126
128
|
@email_message.should have_header("X-Sanitize-Email-Cc", "cc@example.org")
|
|
127
|
-
@email_message.should_not have_header("X-Sanitize-Email-Bcc")
|
|
129
|
+
@email_message.should_not have_header("X-Sanitize-Email-Bcc", "bcc@sanitize_email.org")
|
|
128
130
|
end
|
|
129
131
|
it "should not prepend originals by default" do
|
|
130
132
|
@email_message.should_not have_to_username("to at example.org <to@sanitize_email.org>")
|
|
@@ -150,7 +152,7 @@ describe SanitizeEmail do
|
|
|
150
152
|
@email_message.should have_bcc("bcc@sanitize_email.org")
|
|
151
153
|
@email_message.should have_header("X-Sanitize-Email-To", "to@example.org")
|
|
152
154
|
@email_message.should have_header("X-Sanitize-Email-Cc", "cc@example.org")
|
|
153
|
-
@email_message.should_not have_header("X-Sanitize-Email-Bcc")
|
|
155
|
+
@email_message.should_not have_header("X-Sanitize-Email-Bcc", "bcc@sanitize_email.org")
|
|
154
156
|
end
|
|
155
157
|
end
|
|
156
158
|
context "false" do
|
|
@@ -168,9 +170,9 @@ describe SanitizeEmail do
|
|
|
168
170
|
@email_message.should have_to("to@example.org")
|
|
169
171
|
@email_message.should have_cc("cc@example.org")
|
|
170
172
|
@email_message.should have_bcc("bcc@example.org")
|
|
171
|
-
@email_message.should_not have_header("X-Sanitize-Email-To")
|
|
172
|
-
@email_message.should_not have_header("X-Sanitize-Email-Cc")
|
|
173
|
-
@email_message.should_not have_header("X-Sanitize-Email-Bcc")
|
|
173
|
+
@email_message.should_not have_header("X-Sanitize-Email-To", "to@example.org")
|
|
174
|
+
@email_message.should_not have_header("X-Sanitize-Email-Cc", "cc@example.org")
|
|
175
|
+
@email_message.should_not have_header("X-Sanitize-Email-Bcc", "bcc@example.org")
|
|
174
176
|
end
|
|
175
177
|
end
|
|
176
178
|
context "nil" do
|
|
@@ -192,7 +194,7 @@ describe SanitizeEmail do
|
|
|
192
194
|
@email_message.should have_bcc("bcc@sanitize_email.org")
|
|
193
195
|
@email_message.should have_header("X-Sanitize-Email-To", "to@example.org")
|
|
194
196
|
@email_message.should have_header("X-Sanitize-Email-Cc", "cc@example.org")
|
|
195
|
-
@email_message.should_not have_header("X-Sanitize-Email-Bcc")
|
|
197
|
+
@email_message.should_not have_header("X-Sanitize-Email-Bcc", "bcc@sanitize_email.org")
|
|
196
198
|
end
|
|
197
199
|
end
|
|
198
200
|
context "activation proc disables" do
|
|
@@ -211,9 +213,9 @@ describe SanitizeEmail do
|
|
|
211
213
|
@email_message.should have_to("to@example.org")
|
|
212
214
|
@email_message.should have_cc("cc@example.org")
|
|
213
215
|
@email_message.should have_bcc("bcc@example.org")
|
|
214
|
-
@email_message.should_not have_header("X-Sanitize-Email-To")
|
|
215
|
-
@email_message.should_not have_header("X-Sanitize-Email-Cc")
|
|
216
|
-
@email_message.should_not have_header("X-Sanitize-Email-Bcc")
|
|
216
|
+
@email_message.should_not have_header("X-Sanitize-Email-To", "to@example.org")
|
|
217
|
+
@email_message.should_not have_header("X-Sanitize-Email-Cc", "cc@example.org")
|
|
218
|
+
@email_message.should_not have_header("X-Sanitize-Email-Bcc", "bcc@example.org")
|
|
217
219
|
end
|
|
218
220
|
end
|
|
219
221
|
end
|
|
@@ -221,6 +223,45 @@ describe SanitizeEmail do
|
|
|
221
223
|
end
|
|
222
224
|
|
|
223
225
|
context "config options" do
|
|
226
|
+
context ":use_actual_environment_prepended_to_subject" do
|
|
227
|
+
context "true" do
|
|
228
|
+
before(:each) do
|
|
229
|
+
sanitize_spec_dryer('test')
|
|
230
|
+
configure_sanitize_email({:use_actual_environment_prepended_to_subject => true})
|
|
231
|
+
sanitary_mail_delivery
|
|
232
|
+
end
|
|
233
|
+
it "original to is prepended" do
|
|
234
|
+
@email_message.should have_subject("[test] original subject")
|
|
235
|
+
end
|
|
236
|
+
it "should not alter non-sanitized attributes" do
|
|
237
|
+
@email_message.should have_from('from@example.org')
|
|
238
|
+
@email_message.should have_reply_to('reply_to@example.org')
|
|
239
|
+
end
|
|
240
|
+
it "should not prepend overrides" do
|
|
241
|
+
@email_message.should_not have_to_username("to at sanitize_email.org")
|
|
242
|
+
@email_message.should_not have_subject("(to at sanitize_email.org)")
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
context "false" do
|
|
246
|
+
before(:each) do
|
|
247
|
+
sanitize_spec_dryer('test')
|
|
248
|
+
configure_sanitize_email({:use_actual_environment_prepended_to_subject => false})
|
|
249
|
+
sanitary_mail_delivery
|
|
250
|
+
end
|
|
251
|
+
it "original to is not prepended" do
|
|
252
|
+
@email_message.should_not have_subject("[test] original subject")
|
|
253
|
+
end
|
|
254
|
+
it "should not alter non-sanitized attributes" do
|
|
255
|
+
@email_message.should have_from('from@example.org')
|
|
256
|
+
@email_message.should have_reply_to('reply_to@example.org')
|
|
257
|
+
end
|
|
258
|
+
it "should not prepend overrides" do
|
|
259
|
+
@email_message.should_not have_to_username("to at sanitize_email.org")
|
|
260
|
+
@email_message.should_not have_subject("(to at sanitize_email.org)")
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
|
|
224
265
|
context ":use_actual_email_prepended_to_subject" do
|
|
225
266
|
context "true" do
|
|
226
267
|
before(:each) do
|
data/spec/spec_helper.rb
CHANGED
|
@@ -13,6 +13,9 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
|
|
13
13
|
|
|
14
14
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
15
15
|
RSpec.configure do |config|
|
|
16
|
+
config.include(EmailSpec::Helpers)
|
|
17
|
+
config.include(EmailSpec::Matchers)
|
|
18
|
+
|
|
16
19
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
|
17
20
|
config.run_all_when_everything_filtered = true
|
|
18
21
|
config.filter_run :focus
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sanitize_email
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.6
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date:
|
|
14
|
+
date: 2013-01-25 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: rails
|