Skip to content

Commit

Permalink
Gracefully deprecate old nested meta
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Evans committed Apr 15, 2011
1 parent 8240f65 commit c198e0d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/dragonfly/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,10 @@ def attributes_for_url
end

def update(content, meta)
self.meta.merge!(meta) if meta
if meta
meta.merge!(meta.delete(:meta)) if meta[:meta] # legacy data etc. may have nested meta hash - deprecate gracefully here
self.meta.merge!(meta)
end
if content
self.temp_object = TempObject.new(content)
self.name = temp_object.original_filename if name.nil? && temp_object.original_filename
Expand Down
11 changes: 11 additions & 0 deletions spec/dragonfly/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1032,4 +1032,15 @@
end
end

describe "deprecated meta format" do
before(:each) do
@app = test_app
end
it "should still work if the datastore/whatever returns meta nested in :meta key" do
@app.datastore.should_receive(:retrieve).with('some_uid').and_return(['HELLO', {:name => 'test.txt', :meta => {:some => 'meta'}}])
job = @app.fetch('some_uid').apply
job.meta.should == {:name => 'test.txt', :some => 'meta'}
end
end

end

0 comments on commit c198e0d

Please sign in to comment.