continue to raise on serializing an unsaved model to a delayed job
This capability got lost in the move to native YAML serialization. refs #1 Change-Id: Id7ea4d635f74732d793c53f0fd34304730ade978 Reviewed-on: https://gerrit.instructure.com/2402 Reviewed-by: Bracken Mosbacker <bracken@instructure.com> Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
parent
fd8154dc3e
commit
fc4a866af8
|
@ -18,6 +18,9 @@ class ActiveRecord::Base
|
|||
yaml_as "tag:ruby.yaml.org,2002:ActiveRecord"
|
||||
|
||||
def to_yaml(opts = {})
|
||||
if id.nil?
|
||||
raise("Can't serialize unsaved ActiveRecord object for delayed job: #{self.inspect}")
|
||||
end
|
||||
YAML.quick_emit(self.object_id, opts) do |out|
|
||||
out.scalar(taguri, id.to_s)
|
||||
end
|
||||
|
|
|
@ -36,5 +36,14 @@ describe Delayed::Job do
|
|||
Delayed::Job.db_time_now.zone.should match(/CST|CDT/)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
it "should fail on job creation if an unsaved AR object is used" do
|
||||
story = Story.new :text => "Once upon..."
|
||||
lambda { story.send_later(:text) }.should raise_error
|
||||
|
||||
reader = StoryReader.new
|
||||
lambda { reader.send_later(:read, story) }.should raise_error
|
||||
|
||||
lambda { [story, 1, story, false].send_later(:first) }.should raise_error
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,8 +38,5 @@ describe Delayed::PerformableMethod do
|
|||
p.method.should == :read
|
||||
p.args.should == [story]
|
||||
p.perform.should == 'Epilog: Once upon...'
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue