Skip to content

Commit

Permalink
raise deserialization error when active record is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Nov 12, 2010
1 parent 7b00063 commit 09bab8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/delayed/backend/shared_spec.rb
Expand Up @@ -213,6 +213,13 @@ def create_job(opts = {})
@job = Story.create(:text => "...").delay.save
@job.name.should == 'Story#save'
end

it "should parse from handler on deserialization error" do
job = Story.create(:text => "...").delay.text
job.payload_object.object.destroy
job = described_class.find(job.id)
job.name.should == 'Delayed::PerformableMethod'
end
end

context "worker prioritization" do
Expand Down Expand Up @@ -295,11 +302,11 @@ def create_job(opts = {})
YAML.load(yaml).priority.should == 99
end

it "should ignore destroyed records" do
it "should raise deserialization error for destroyed records" do
job = described_class.enqueue SimpleJob.new
yaml = job.to_yaml
job.destroy
lambda { YAML.load(yaml).should be_nil }.should_not raise_error
lambda { YAML.load(yaml) }.should raise_error(Delayed::DeserializationError)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/delayed/serialization/active_record.rb
Expand Up @@ -4,7 +4,7 @@ class ActiveRecord::Base
def self.yaml_new(klass, tag, val)
klass.find(val['attributes']['id'])
rescue ActiveRecord::RecordNotFound
nil
raise Delayed::DeserializationError
end

def to_yaml_properties
Expand Down

0 comments on commit 09bab8a

Please sign in to comment.