diff --git a/lib/delayed/performable_method.rb b/lib/delayed/performable_method.rb index 5182e7603..10f16256f 100644 --- a/lib/delayed/performable_method.rb +++ b/lib/delayed/performable_method.rb @@ -33,7 +33,7 @@ def load(arg) case arg when CLASS_STRING_FORMAT then $1.constantize when AR_STRING_FORMAT then $1.constantize.find($2) - when DM_STRING_FORMAT then $1.constantize.get($2) + when DM_STRING_FORMAT then $1.constantize.get!($2) else arg end end @@ -59,4 +59,4 @@ def class_to_string(obj) "CLASS:#{obj.name}" end end -end \ No newline at end of file +end diff --git a/spec/delayed_method_spec.rb b/spec/delayed_method_spec.rb index 970228645..10c2cb2be 100644 --- a/spec/delayed_method_spec.rb +++ b/spec/delayed_method_spec.rb @@ -90,6 +90,23 @@ def read(story) end + it "should ignore delayed method calls on objects that have been deleted." do + story = Story.create :text => 'Once upon...' + story.send_later(:tell) + + story.destroy + Story.count.should == 0 + + output = nil + + Delayed::Job.reserve do |e| + puts e.inspect + output = e.perform + end + + output.should == true + end + it "should store the object as string if its an active record" do story = Story.create :text => 'Once upon...' story.send_later(:tell) @@ -116,4 +133,4 @@ def read(story) job.payload_object.perform.should == 'Epilog: Once upon...' end -end \ No newline at end of file +end