mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
more refactoring
This commit is contained in:
parent
ddd26798f1
commit
5c31e80062
5 changed files with 40 additions and 37 deletions
|
@ -21,7 +21,7 @@ app.get '/project/:project_id/doc/:doc_id/raw', HttpController.getRawDoc
|
|||
app.post '/project/:project_id/doc/:doc_id', bodyParser.json(limit: "2mb"), HttpController.updateDoc
|
||||
app.del '/project/:project_id/doc/:doc_id', HttpController.deleteDoc
|
||||
|
||||
if Settings.filestore.backend == "s3"
|
||||
if Settings.filestore?.backend == "s3"
|
||||
app.get '/project/:project_id/archive', HttpController.archiveAllDocs
|
||||
|
||||
app.get '/status', (req, res)->
|
||||
|
|
|
@ -7,7 +7,7 @@ settings = require("settings-sharelatex")
|
|||
request = require("request")
|
||||
crypto = require("crypto")
|
||||
thirtySeconds = 30 * 1000
|
||||
DocArchive = require "./DocArchive"
|
||||
DocArchive = require "./DocArchiveManager"
|
||||
|
||||
module.exports = DocManager =
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
DocManager = require "./DocManager"
|
||||
logger = require "logger-sharelatex"
|
||||
DocArchive = require "./DocArchive"
|
||||
DocArchive = require "./DocArchiveManager"
|
||||
|
||||
module.exports = HttpController =
|
||||
getDoc: (req, res, next = (error) ->) ->
|
||||
|
|
|
@ -3,44 +3,47 @@ chai = require("chai")
|
|||
chai.should()
|
||||
{ObjectId} = require "mongojs"
|
||||
async = require "async"
|
||||
Settings = require("settings-sharelatex")
|
||||
|
||||
DocstoreClient = require "./helpers/DocstoreClient"
|
||||
|
||||
describe "Archiving all docs", ->
|
||||
beforeEach (done) ->
|
||||
@project_id = ObjectId()
|
||||
@docs = [{
|
||||
_id: ObjectId()
|
||||
lines: ["one", "two", "three"]
|
||||
rev: 2
|
||||
}, {
|
||||
_id: ObjectId()
|
||||
lines: ["aaa", "bbb", "ccc"]
|
||||
rev: 4
|
||||
}, {
|
||||
_id: ObjectId()
|
||||
lines: ["111", "222", "333"]
|
||||
rev: 6
|
||||
}]
|
||||
jobs = for doc in @docs
|
||||
do (doc) =>
|
||||
(callback) =>
|
||||
DocstoreClient.createDoc @project_id, doc._id, doc.lines, (err)=>
|
||||
doc.lines[0] = doc.lines[0]+" added"
|
||||
DocstoreClient.updateDoc @project_id, doc._id, doc.lines, callback
|
||||
async.series jobs, done
|
||||
if Settings.filestore?.backend == "s3"
|
||||
|
||||
it "should archive all the docs", (done) ->
|
||||
DocstoreClient.archiveAllDoc @project_id, (error, res) =>
|
||||
res.statusCode.should.equal 204
|
||||
done()
|
||||
describe "Archiving all docs", ->
|
||||
beforeEach (done) ->
|
||||
@project_id = ObjectId()
|
||||
@docs = [{
|
||||
_id: ObjectId()
|
||||
lines: ["one", "two", "three"]
|
||||
rev: 2
|
||||
}, {
|
||||
_id: ObjectId()
|
||||
lines: ["aaa", "bbb", "ccc"]
|
||||
rev: 4
|
||||
}, {
|
||||
_id: ObjectId()
|
||||
lines: ["111", "222", "333"]
|
||||
rev: 6
|
||||
}]
|
||||
jobs = for doc in @docs
|
||||
do (doc) =>
|
||||
(callback) =>
|
||||
DocstoreClient.createDoc @project_id, doc._id, doc.lines, (err)=>
|
||||
doc.lines[0] = doc.lines[0]+" added"
|
||||
DocstoreClient.updateDoc @project_id, doc._id, doc.lines, callback
|
||||
async.series jobs, done
|
||||
|
||||
it "should unarchive all the docs", (done) ->
|
||||
DocstoreClient.archiveAllDoc @project_id, (error, res) =>
|
||||
DocstoreClient.getAllDocs @project_id, (error, res, docs) =>
|
||||
throw error if error?
|
||||
docs.length.should.equal @docs.length
|
||||
for doc, i in docs
|
||||
doc.lines.should.deep.equal @docs[i].lines
|
||||
it "should archive all the docs", (done) ->
|
||||
DocstoreClient.archiveAllDoc @project_id, (error, res) =>
|
||||
res.statusCode.should.equal 204
|
||||
done()
|
||||
|
||||
it "should unarchive all the docs", (done) ->
|
||||
DocstoreClient.archiveAllDoc @project_id, (error, res) =>
|
||||
DocstoreClient.getAllDocs @project_id, (error, res, docs) =>
|
||||
throw error if error?
|
||||
docs.length.should.equal @docs.length
|
||||
for doc, i in docs
|
||||
doc.lines.should.deep.equal @docs[i].lines
|
||||
done()
|
||||
|
||||
|
|
Loading…
Reference in a new issue