Skip to content

Commit

Permalink
Ensure that destroyed DataMapper objects with a send_later call are
Browse files Browse the repository at this point in the history
properly ignored.

Signed-off-by: Chris Van Pelt <[email protected]>
  • Loading branch information
bpo authored and vanpelt committed Jun 16, 2009
1 parent b5943fb commit f487438
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/delayed/performable_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -59,4 +59,4 @@ def class_to_string(obj)
"CLASS:#{obj.name}"
end
end
end
end
19 changes: 18 additions & 1 deletion spec/delayed_method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -116,4 +133,4 @@ def read(story)
job.payload_object.perform.should == 'Epilog: Once upon...'
end

end
end

0 comments on commit f487438

Please sign in to comment.