whitelist_mail_proxy 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -22,19 +22,8 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
22
22
  rdoc.rdoc_files.include('lib/**/*.rb')
23
23
  end
24
24
 
25
- require "rubygems"
26
25
  require "rake/gempackagetask"
27
- require "rake/rdoctask"
28
26
 
29
- require "rake/testtask"
30
- Rake::TestTask.new do |t|
31
- t.libs << "test"
32
- t.test_files = FileList["test/**/*_test.rb"]
33
- t.verbose = true
34
- end
35
-
36
-
37
- task :default => ["test"]
38
27
 
39
28
  # This builds the actual gem. For details of what all these options
40
29
  # mean, and other ones you can add, check the documentation here:
@@ -45,7 +34,7 @@ spec = Gem::Specification.new do |s|
45
34
 
46
35
  # Change these as appropriate
47
36
  s.name = "whitelist_mail_proxy"
48
- s.version = "0.4.1"
37
+ s.version = "0.4.2"
49
38
  s.summary = "A thin proxy for Mail and ActionMailer to enable whitelisting"
50
39
  s.author = "Matthew Rudy Jacobs"
51
40
  s.email = "MatthewRudyJacobs@gmail.com"
@@ -56,7 +45,7 @@ spec = Gem::Specification.new do |s|
56
45
  s.rdoc_options = %w(--main README)
57
46
 
58
47
  # Add any extra files to include in the gem
59
- s.files = %w(MIT-LICENSE Rakefile README) + Dir.glob("{test,lib/**/*}")
48
+ s.files = %w(MIT-LICENSE Rakefile README) + Dir.glob("{test,lib}/**/*")
60
49
  s.require_paths = ["lib"]
61
50
 
62
51
  # If you want to depend on other gems, add them here, along with any
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'active_support'
@@ -0,0 +1,104 @@
1
+ require 'test_helper'
2
+ require File.dirname(__FILE__)+"/../lib/whitelist_mail_proxy"
3
+
4
+ class WhitelistMailProxyTest < ActiveSupport::TestCase
5
+
6
+ test "extract_email_address - just an email" do
7
+ assert_extracted "murple@murple.com", "murple@murple.com"
8
+ end
9
+
10
+ test "extract_email_address - with a trailing space" do
11
+ assert_extracted "murple@murple.com", "murple@murple.com "
12
+ end
13
+
14
+ test "extract_email_address - with some magic" do
15
+ assert_extracted "murple+somemagic@murple.com", "murple+somemagic@murple.com"
16
+ end
17
+
18
+ test "extract_email_address - with a quoted name" do
19
+ full = %("Purple Murple" <murple@murple.com>)
20
+ assert_extracted "murple@murple.com", full
21
+ end
22
+
23
+ test "extract_email_address - with a non-quoted name" do
24
+ full = %(Purple Murple <murple@murple.com>)
25
+ assert_extracted "murple@murple.com", full
26
+ end
27
+
28
+ test "extract_email_address - without a space between the name and email" do
29
+ full = %("Purple Murple"<murple@murple.com>)
30
+ assert_extracted "murple@murple.com", full
31
+ end
32
+
33
+ test "extract_email_domain" do
34
+ assert_domain "murple.com", "murple@murple.com"
35
+ end
36
+
37
+ test "extract_email_domain - with quoted name" do
38
+ full = %("Purple Murple" <murple@murple.com>)
39
+ assert_domain "murple.com", full
40
+ end
41
+
42
+ test "block_recipient - by regexp" do
43
+ @proxy = WhitelistMailProxy.new(:delivery_method => :test, :regexp => /purple/)
44
+
45
+ # matching the email address
46
+ assert !@proxy.block_recipient?("purple@murple.com")
47
+ assert @proxy.block_recipient?("murple@murple.com")
48
+
49
+ # but also the name
50
+ assert @proxy.block_recipient?(%("Purple Murple" <murple@murple.com>))
51
+ assert !@proxy.block_recipient?(%("purple Murple" <murple@murple.com>)) # case sensitive
52
+ assert @proxy.block_recipient?(%("Murple Murple" <murple@murple.com>))
53
+ end
54
+
55
+ test "block_recipient - by single domain" do
56
+ @proxy = WhitelistMailProxy.new(:delivery_method => :test, :domain => "murple.com")
57
+
58
+ # matching the domain
59
+ assert !@proxy.block_recipient?("murple@murple.com")
60
+ assert @proxy.block_recipient?("murple@murpoo.com")
61
+
62
+ # regardless of name
63
+ assert !@proxy.block_recipient?(%("Purple Murple" <murple@murple.com>))
64
+ assert @proxy.block_recipient?(%("Purple Murple" <murple@murpoo.com>))
65
+ end
66
+
67
+ test "block_recipient - multiple domains" do
68
+ @proxy = WhitelistMailProxy.new(:delivery_method => :test, :domain => ["murple.com", "murpoo.com"])
69
+
70
+ # matching the domain
71
+ assert !@proxy.block_recipient?("murple@murple.com")
72
+ assert !@proxy.block_recipient?("murple@murpoo.com")
73
+ assert @proxy.block_recipient?("murple@somethingelse.com")
74
+
75
+ # regardless of name
76
+ assert !@proxy.block_recipient?(%("Purple Murple" <murple@murple.com>))
77
+ assert !@proxy.block_recipient?(%("Purple Murple" <murple@murpoo.com>))
78
+ assert @proxy.block_recipient?(%("Purple Murple" <murple@somethingelse.com>))
79
+ end
80
+
81
+ test "raises an exception if not given a delivery method" do
82
+ assert_raise(WhitelistMailProxy::SettingsError) do
83
+ WhitelistMailProxy.new(:domain => ["murple.com", "murpoo.com"])
84
+ end
85
+ end
86
+
87
+ test "raises an exception if not given a regexp or a domain" do
88
+ assert_raise(WhitelistMailProxy::SettingsError) do
89
+ WhitelistMailProxy.new(:delivery_method => :test)
90
+ end
91
+ assert WhitelistMailProxy.new(:delivery_method => :test, :regexp => /something/)
92
+ assert WhitelistMailProxy.new(:delivery_method => :test, :domain => ["something"])
93
+ assert WhitelistMailProxy.new(:delivery_method => :test, :domain => []) # it doesnt care if its empty
94
+ end
95
+
96
+ def assert_extracted(extracted, full)
97
+ assert_equal extracted, WhitelistMailProxy.extract_email_address(full)
98
+ end
99
+
100
+ def assert_domain(domain, full)
101
+ assert_equal domain, WhitelistMailProxy.extract_email_domain(full)
102
+ end
103
+
104
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whitelist_mail_proxy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
- prerelease: false
4
+ hash: 11
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 1
10
- version: 0.4.1
9
+ - 2
10
+ version: 0.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthew Rudy Jacobs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-08 00:00:00 +08:00
18
+ date: 2011-01-09 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -31,6 +31,8 @@ files:
31
31
  - MIT-LICENSE
32
32
  - Rakefile
33
33
  - README
34
+ - test/test_helper.rb
35
+ - test/whitelist_mail_proxy_test.rb
34
36
  - lib/whitelist_mail_proxy.rb
35
37
  has_rdoc: true
36
38
  homepage: http://github.com/matthewrudy/whitelist-mail-proxy
@@ -63,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
65
  requirements: []
64
66
 
65
67
  rubyforge_project:
66
- rubygems_version: 1.3.7
68
+ rubygems_version: 1.4.1
67
69
  signing_key:
68
70
  specification_version: 3
69
71
  summary: A thin proxy for Mail and ActionMailer to enable whitelisting