Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed 2 bugs:

- ensure blacklist_block class variable is always defined.
- make sure #deliver! returns the email object, even when it early exits.
  • Loading branch information...
commit 4e9538caa8a69d907a04bd6505ec28552d6892cd 1 parent 6253709
@myronmarston authored
Showing with 8 additions and 2 deletions.
  1. +3 −1 lib/email_blacklist.rb
  2. +5 −1 spec/email_blacklist_spec.rb
View
4 lib/email_blacklist.rb
@@ -5,6 +5,8 @@ module EmailBlacklist
ADDRESS_TYPES = [:to, :cc, :bcc].freeze
class Config
+ @@blacklist_block = nil
+
class << self
def blacklist(&blk)
@@blacklist_block = blk
@@ -31,7 +33,7 @@ def deliver!(mail = @mail)
mail.send("#{address_type}=", addresses)
end
- return if all_addresses.flatten.compact.empty?
+ return mail if all_addresses.flatten.compact.empty?
end
super(mail)
View
6 spec/email_blacklist_spec.rb
@@ -65,12 +65,16 @@
context "sending an email to just 'bob@blacklisted.org'" do
before(:each) do
ActionMailer::Base.deliveries.clear
- TestMailer.deliver_email({:to => 'bob@blacklisted.org'})
+ @email = TestMailer.deliver_email({:to => 'bob@blacklisted.org'})
end
it "should not send the email at all" do
ActionMailer::Base.deliveries.should == []
end
+
+ it "should still return the email" do
+ @email.should_not be_nil
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.