Permalink
Browse files

Added guard clause when creating a new CallbackRunner for nil Callbac…

…k objects. We don't want to get into a situation where we enqueue with a nill callback.
  • Loading branch information...
1 parent eab4d4e commit 217279b61675fc9c4b760bb51eef9e2b57da8969 Justin Knowlden committed Dec 16, 2008
Showing with 4 additions and 1 deletion.
  1. +1 −0 models/callback_runner.rb
  2. +3 −1 test/callback_runner_test.rb
View
1 models/callback_runner.rb
@@ -12,6 +12,7 @@ def self.replace_job_for_callback!(callback)
end
def initialize(callback)
+ raise(ArgumentError, "Callback cannot be nil") unless callback
@callback = callback
end
View
4 test/callback_runner_test.rb
@@ -7,7 +7,9 @@ def callback_with_runner(attributes={})
[callback, runner]
end
- should "barf if no callback given to initializer"
+ should "barf if nil callback given to initializer" do
+ assert_raise(ArgumentError) { CallbackRunner.new(nil) }
+ end
context "making job from callback" do
setup do

0 comments on commit 217279b

Please sign in to comment.