Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 31 additions and 2 deletions.
  1. +5 −1 lib/catch_all.rb
  2. +1 −1 lib/catch_all/version.rb
  3. +25 −0 spec/catch_all_spec.rb
View
6 lib/catch_all.rb
@@ -9,7 +9,11 @@ def enabled?
end
def enable(*to_addresses)
- to_addresses = to_addresses.flatten
+ to_addresses = to_addresses.flatten.compact
+
+ if to_addresses.length == 0
+ Kernel.warn("No email addresses passed to ActionMailer::CatchAll!")
+ end
if enabled?
disable
View
2 lib/catch_all/version.rb
@@ -1,5 +1,5 @@
module ActionMailer
module CatchAll
- VERSION = '0.0.1'
+ VERSION = '0.0.2'
end
end
View
25 spec/catch_all_spec.rb
@@ -16,6 +16,10 @@ def notify_with_name
def notify_no_address
mail()
end
+
+ def notify_with_empty_to
+ mail(:to => [])
+ end
end
describe ActionMailer::CatchAll do
@@ -93,4 +97,25 @@ def notify_no_address
ActionMailer::CatchAll.disable
ActionMailer::CatchAll.should_not be_enabled
end
+
+ it "should warn and use [] if passed an empty list" do
+ Kernel.should_receive(:warn).with("No email addresses passed to ActionMailer::CatchAll!")
+ ActionMailer::CatchAll.enable([])
+ mailer = Notifier.notify
+ mailer.to.should == []
+ end
+
+ it "should warn and use [] if passed a nil" do
+ Kernel.should_receive(:warn).with("No email addresses passed to ActionMailer::CatchAll!")
+ ActionMailer::CatchAll.enable(nil)
+ mailer = Notifier.notify
+ mailer.to.should == []
+ end
+
+ it "should warn and use [] if passed nothing" do
+ Kernel.should_receive(:warn).with("No email addresses passed to ActionMailer::CatchAll!")
+ ActionMailer::CatchAll.enable()
+ mailer = Notifier.notify
+ mailer.to.should == []
+ end
end

No commit comments for this range

Something went wrong with that request. Please try again.