collectiveidea/delayed_job — pull request #344 by dcuddeback (2012-01-30 19:03:21+00:00)
Title: Removes nil guard that causes silent failures

The nil guard in PerformableMethod#perform means that no error is raised when attempting to delay a method on nil:

@model = Model.some_lookup_method(params) # => nil
@model.delay.process_something

In this example, if `@model` is nil, then PerformableMethod happily ignores the error. It seems like this was by design, because you have a spec for this exact scenario:

context "with the persisted record cannot be found" do
before do
@method.object = nil
end

it "should be a no-op if object is nil" do
lambda { @method.perform }.should_not raise_error
end
end

What was the rationale for this design decision? In our particular application, we've found this to be detrimental, because we don't receive failure notices when delaying a method on `nil`.

If you'd like to change the behavior to raise an error instead, I've attached a patch that will do that. If not, it's an easy monkey patch for others to apply. Another alternative is that we can make it configurable: `Delayed::Worker.raise_error_on_nil = true`.