sanitize_email 0.3.9 → 1.0.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/CHANGELOG +23 -0
- data/Gemfile +11 -11
- data/Gemfile.lock +129 -0
- data/{LICENSE.txt → MIT-LICENSE} +1 -3
- data/README.rdoc +28 -71
- data/Rakefile +54 -9
- data/VERSION.yml +4 -4
- data/lib/sanitize_email.rb +28 -9
- data/lib/sanitize_email/config.rb +34 -0
- data/lib/sanitize_email/engine.rb +12 -0
- data/lib/sanitize_email/hook.rb +30 -0
- data/lib/sanitize_email/railtie.rb +12 -0
- data/lib/sanitize_email/sanitizer.rb +73 -0
- data/lib/sanitize_email/version.rb +3 -1
- data/sanitize_email.gemspec +80 -21
- data/spec/sanitize_email_spec.rb +68 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/tmp/mail_dump/1343461037_3f3edd7/plain.html +76 -0
- metadata +201 -68
- checksums.yaml +0 -7
- data/.gitignore +0 -20
- data/CHANGELOG.md +0 -27
- data/lib/sanitize_email/custom_environments.rb +0 -21
- data/lib/sanitize_email/sanitize_email.rb +0 -114
- data/test/sample_mailer.rb +0 -24
- data/test/sanitize_email_test.rb +0 -76
- data/test/test_helper.rb +0 -25
data/test/sample_mailer.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
class SampleMailer < ActionMailer::Base
|
2
|
-
|
3
|
-
def gmail_override
|
4
|
-
@recipients = "to_real@email.com"
|
5
|
-
@cc = "cc_real@email.com"
|
6
|
-
@bcc = "bcc_real@email.com"
|
7
|
-
|
8
|
-
@subject = "Hello there"
|
9
|
-
|
10
|
-
part :content_type => "text/html", :body => "Hello there"
|
11
|
-
end
|
12
|
-
|
13
|
-
def gmail_override_multiple_recipient
|
14
|
-
@recipients = ["to_0_real@email.com", "to_1_real@email.com"]
|
15
|
-
@cc = "cc_real@email.com"
|
16
|
-
@bcc = "bcc_real@email.com"
|
17
|
-
|
18
|
-
@subject = "Hello there, multiple"
|
19
|
-
|
20
|
-
part :content_type => "text/html", :body => "Hello there, multiple."
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
data/test/sanitize_email_test.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/test_helper')
|
2
|
-
|
3
|
-
class SanitizeEmailTest < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
ENV['RAILS_ENV'] = 'test'
|
6
|
-
end
|
7
|
-
|
8
|
-
def prepare_sanitizations(to = nil, cc = nil, bcc = nil, use_actual_email_as_sanitized_user_name = false)
|
9
|
-
ActionMailer::Base.sanitized_recipients = to
|
10
|
-
ActionMailer::Base.sanitized_cc = cc
|
11
|
-
ActionMailer::Base.sanitized_bcc = bcc
|
12
|
-
ActionMailer::Base.local_environments = %w( test )
|
13
|
-
ActionMailer::Base.use_actual_email_as_sanitized_user_name = use_actual_email_as_sanitized_user_name
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_send_can_override_recips_cc_bcc_all_independently
|
17
|
-
prepare_sanitizations("to_sanitized@email.com", "cc_sanitized@email.com")
|
18
|
-
|
19
|
-
tmail = SampleMailer.create_gmail_override
|
20
|
-
assert_equal ["to_sanitized@email.com"], tmail.to
|
21
|
-
assert_equal ["cc_sanitized@email.com"], tmail.cc
|
22
|
-
assert_equal nil, tmail.bcc
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_to_with_override
|
26
|
-
prepare_sanitizations("to_sanitized@email.com", nil, nil, :override_username)
|
27
|
-
tmail = SampleMailer.create_gmail_override
|
28
|
-
assert_equal "to_real@email.com", tmail.to_addrs[0].name
|
29
|
-
assert_equal "to_sanitized@email.com", tmail.to_addrs[0].address
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_tcc_with_override
|
33
|
-
prepare_sanitizations("to_sanitized@email.com", "cc_sanitized@email.com", nil, :override_username)
|
34
|
-
tmail = SampleMailer.create_gmail_override
|
35
|
-
assert_equal "cc_real@email.com", tmail.cc_addrs[0].name
|
36
|
-
assert_equal "cc_sanitized@email.com", tmail.cc_addrs[0].address
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_bcc_with_override
|
40
|
-
prepare_sanitizations("to_sanitized@email.com", nil, "bcc_sanitized@email.com", :override_username)
|
41
|
-
tmail = SampleMailer.create_gmail_override
|
42
|
-
assert_equal "bcc_real@email.com", tmail.bcc_addrs[0].name
|
43
|
-
assert_equal "bcc_sanitized@email.com", tmail.bcc_addrs[0].address
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_override_with_multiple_santiized_emails
|
47
|
-
prepare_sanitizations(["to_0_sanitized@email.com", "to_1_sanitized@email.com"], nil, nil, :override_username)
|
48
|
-
tmail = SampleMailer.create_gmail_override
|
49
|
-
tmail.to_addrs.each_with_index do |mail, idx|
|
50
|
-
assert_equal "to_real@email.com", mail.name
|
51
|
-
assert_equal "to_#{idx}_sanitized@email.com", mail.address
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_overriding_multiple_real_addresses
|
56
|
-
prepare_sanitizations("to_sanitized@email.com", nil, nil, :override_username)
|
57
|
-
tmail = SampleMailer.create_gmail_override_multiple_recipient
|
58
|
-
tmail.to_addrs.each_with_index do |mail, idx|
|
59
|
-
assert_equal "to_#{idx}_real@email.com", mail.name
|
60
|
-
assert_equal "to_sanitized@email.com", mail.address
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_overriding_multiple_real_addresses_with_multiple_sanitized_emails
|
65
|
-
prepare_sanitizations(["to_0_sanitized@email.com", "to_1_sanitized@email.com"], nil, nil, :override_username)
|
66
|
-
tmail = SampleMailer.create_gmail_override_multiple_recipient
|
67
|
-
|
68
|
-
assert tmail.to_addrs.map(&:name).include?("to_0_real@email.com")
|
69
|
-
assert tmail.to_addrs.map(&:name).include?("to_1_real@email.com")
|
70
|
-
|
71
|
-
assert tmail.to_addrs.map(&:address).include?("to_0_sanitized@email.com")
|
72
|
-
assert tmail.to_addrs.map(&:address).include?("to_1_sanitized@email.com")
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# Note tests require tmail to be the underlying message handler, so need to be run with Rails 2.3 or below
|
2
|
-
require 'rubygems'
|
3
|
-
|
4
|
-
vendored_rails = File.dirname(__FILE__) + '/../../../../vendor/rails'
|
5
|
-
if File.exists?(vendored_rails)
|
6
|
-
Dir.glob(vendored_rails + "/**/lib").each { |dir| $:.unshift dir }
|
7
|
-
RAILS_ROOT = File.dirname(__FILE__) + '/../../../../' unless defined?(RAILS_ROOT)
|
8
|
-
else
|
9
|
-
gem 'rails', "=#{ENV['VERSION']}" if ENV['VERSION']
|
10
|
-
RAILS_ROOT = '.' unless defined?(RAILS_ROOT)
|
11
|
-
end
|
12
|
-
|
13
|
-
require 'test/unit'
|
14
|
-
|
15
|
-
RAILS_ENV = 'test'
|
16
|
-
|
17
|
-
require File.join(File.dirname(__FILE__), "..", "init")
|
18
|
-
|
19
|
-
# configure ActionMailer
|
20
|
-
ActionMailer::Base.template_root = File.join(File.dirname(__FILE__), "test")
|
21
|
-
ActionMailer::Base.sanitized_recipients = "test@example.com"
|
22
|
-
ActionMailer::Base.sanitized_bcc = nil
|
23
|
-
ActionMailer::Base.sanitized_cc = nil
|
24
|
-
|
25
|
-
require File.expand_path(File.dirname(__FILE__) + '/sample_mailer')
|