Skip to content

Commit

Permalink
Make sure the migrator sets the checksum when creating new design docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ellneal committed Oct 6, 2016
1 parent 7d79c40 commit 056a8a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/couchrest/model/designs/migrations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def migrate(db = nil, &block)
id = self['_id']

if !doc
# make sure the checksum has been calculated
checksum! if !self['couchrest-hash']

# no need to migrate, just save it
new_doc = to_hash.dup
db.save_doc(new_doc)
Expand Down
1 change: 1 addition & 0 deletions spec/unit/designs/migrations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class DesignSampleModelMigrate < MigrationModelBase
end
doc = @db.get(@doc['_id'])
expect(doc['views']['all']).to eql(@doc['views']['all'])
expect(doc['couchrest-hash']).not_to be_nil
expect(callback).to be_nil
end

Expand Down

0 comments on commit 056a8a8

Please sign in to comment.