email_blacklist 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.rdoc +5 -0
- data/VERSION +1 -1
- data/lib/email_blacklist.rb +3 -1
- data/spec/email_blacklist_spec.rb +5 -1
- metadata +1 -1
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -7,6 +7,11 @@ This is useful in a variety of situations:
|
|
7
7
|
* You can stop emails from being sent to users who have deactivated their accounts with your app.
|
8
8
|
* Any other reason you might want to stop emails from being sent...
|
9
9
|
|
10
|
+
When an email address is blacklisted, no ActionMailer emails will be sent to it, regardless of
|
11
|
+
if the email addresses is used for the to, cc or bcc fields. However, if there are additional
|
12
|
+
email addresses on the same email that are not blacklisted, the email will still be sent to them.
|
13
|
+
If all email addresses for a particular email are blacklisted, the email will not be sent at all.
|
14
|
+
|
10
15
|
== Installation
|
11
16
|
gem install email_blacklist
|
12
17
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/email_blacklist.rb
CHANGED
@@ -5,6 +5,8 @@ module EmailBlacklist
|
|
5
5
|
ADDRESS_TYPES = [:to, :cc, :bcc].freeze
|
6
6
|
|
7
7
|
class Config
|
8
|
+
@@blacklist_block = nil
|
9
|
+
|
8
10
|
class << self
|
9
11
|
def blacklist(&blk)
|
10
12
|
@@blacklist_block = blk
|
@@ -31,7 +33,7 @@ ActionMailer::Base.class_eval do
|
|
31
33
|
mail.send("#{address_type}=", addresses)
|
32
34
|
end
|
33
35
|
|
34
|
-
return if all_addresses.flatten.compact.empty?
|
36
|
+
return mail if all_addresses.flatten.compact.empty?
|
35
37
|
end
|
36
38
|
|
37
39
|
super(mail)
|
@@ -65,12 +65,16 @@ describe ActionMailer do
|
|
65
65
|
context "sending an email to just 'bob@blacklisted.org'" do
|
66
66
|
before(:each) do
|
67
67
|
ActionMailer::Base.deliveries.clear
|
68
|
-
TestMailer.deliver_email({:to => 'bob@blacklisted.org'})
|
68
|
+
@email = TestMailer.deliver_email({:to => 'bob@blacklisted.org'})
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should not send the email at all" do
|
72
72
|
ActionMailer::Base.deliveries.should == []
|
73
73
|
end
|
74
|
+
|
75
|
+
it "should still return the email" do
|
76
|
+
@email.should_not be_nil
|
77
|
+
end
|
74
78
|
end
|
75
79
|
end
|
76
80
|
|