mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-24 03:23:10 +00:00
preserve existing history when user upgrades
This commit is contained in:
parent
e292de5eb0
commit
fd49601716
3 changed files with 27 additions and 1 deletions
|
@ -64,6 +64,19 @@ module.exports = MongoManager =
|
|||
upsert: true
|
||||
}, callback
|
||||
|
||||
upgradeHistory: (project_id, callback = (error) ->) ->
|
||||
# preserve the project's existing history
|
||||
db.docHistory.update {
|
||||
project_id: ObjectId(project_id)
|
||||
temporary: true
|
||||
expiresAt: {$exists: true}
|
||||
}, {
|
||||
$set: {temporary: false}
|
||||
$unset: {expiresAt: ""}
|
||||
}, {
|
||||
multi: true
|
||||
}, callback
|
||||
|
||||
ensureIndices: () ->
|
||||
# For finding all updates that go into a diff for a doc
|
||||
db.docHistory.ensureIndex { doc_id: 1, v: 1 }, { background: true }
|
||||
|
|
|
@ -15,7 +15,9 @@ module.exports = UpdateTrimmer =
|
|||
if details?.features?.versioning
|
||||
MongoManager.setProjectMetaData project_id, preserveHistory: true, (error) ->
|
||||
return callback(error) if error?
|
||||
callback null, false
|
||||
MongoManager.upgradeHistory project_id, (error) ->
|
||||
return callback(error) if error?
|
||||
callback null, false
|
||||
else
|
||||
callback null, true
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ describe "UpdateTrimmer", ->
|
|||
features: {}
|
||||
@MongoManager.getProjectMetaData = sinon.stub().callsArgWith(1, null, @metadata)
|
||||
@MongoManager.setProjectMetaData = sinon.stub().callsArgWith(2)
|
||||
@MongoManager.upgradeHistory = sinon.stub().callsArgWith(1)
|
||||
@WebApiManager.getProjectDetails = sinon.stub().callsArgWith(1, null, @details)
|
||||
|
||||
describe "with preserveHistory set in the project meta data", ->
|
||||
|
@ -73,6 +74,11 @@ describe "UpdateTrimmer", ->
|
|||
.calledWith(@project_id, {preserveHistory: true})
|
||||
.should.equal true
|
||||
|
||||
it "should upgrade any existing history", ->
|
||||
@MongoManager.upgradeHistory
|
||||
.calledWith(@project_id)
|
||||
.should.equal true
|
||||
|
||||
it "should return false", ->
|
||||
@callback.calledWith(null, false).should.equal true
|
||||
|
||||
|
@ -98,6 +104,11 @@ describe "UpdateTrimmer", ->
|
|||
.calledWith(@project_id, {preserveHistory: true})
|
||||
.should.equal true
|
||||
|
||||
it "should upgrade any existing history", ->
|
||||
@MongoManager.upgradeHistory
|
||||
.calledWith(@project_id)
|
||||
.should.equal true
|
||||
|
||||
it "should return false", ->
|
||||
@callback.calledWith(null, false).should.equal true
|
||||
|
||||
|
|
Loading…
Reference in a new issue