mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 17:43:42 -05:00
Merge pull request #1278 from sharelatex/revert-1240-as-import-status-page
Revert "Import status page" GitOrigin-RevId: aa667a7b158b38aeccc8251931cc20589dcb2bdd
This commit is contained in:
parent
56784c4089
commit
1160620afc
13 changed files with 18 additions and 228 deletions
|
@ -106,7 +106,6 @@ module.exports = AuthorizationMiddlewear =
|
||||||
return callback(null, user_id)
|
return callback(null, user_id)
|
||||||
|
|
||||||
redirectToRestricted: (req, res, next) ->
|
redirectToRestricted: (req, res, next) ->
|
||||||
# TODO: move this to throwing ForbiddenError
|
|
||||||
res.redirect "/restricted?from=#{encodeURIComponent(req.url)}"
|
res.redirect "/restricted?from=#{encodeURIComponent(req.url)}"
|
||||||
|
|
||||||
restricted : (req, res, next)->
|
restricted : (req, res, next)->
|
||||||
|
|
|
@ -8,10 +8,6 @@ module.exports = ErrorController =
|
||||||
res.render 'general/404',
|
res.render 'general/404',
|
||||||
title: "page_not_found"
|
title: "page_not_found"
|
||||||
|
|
||||||
forbidden: (req, res) ->
|
|
||||||
res.status(403)
|
|
||||||
res.render 'user/restricted'
|
|
||||||
|
|
||||||
serverError: (req, res)->
|
serverError: (req, res)->
|
||||||
res.status(500)
|
res.status(500)
|
||||||
res.render 'general/500',
|
res.render 'general/500',
|
||||||
|
@ -31,9 +27,6 @@ module.exports = ErrorController =
|
||||||
if error instanceof Errors.NotFoundError
|
if error instanceof Errors.NotFoundError
|
||||||
logger.warn {err: error, url: req.url}, "not found error"
|
logger.warn {err: error, url: req.url}, "not found error"
|
||||||
ErrorController.notFound req, res
|
ErrorController.notFound req, res
|
||||||
else if error instanceof Errors.ForbiddenError
|
|
||||||
logger.error err: error, "forbidden error"
|
|
||||||
ErrorController.forbidden req, res
|
|
||||||
else if error instanceof Errors.TooManyRequestsError
|
else if error instanceof Errors.TooManyRequestsError
|
||||||
logger.warn {err: error, url: req.url}, "too many requests error"
|
logger.warn {err: error, url: req.url}, "too many requests error"
|
||||||
res.sendStatus(429)
|
res.sendStatus(429)
|
||||||
|
|
|
@ -5,13 +5,6 @@ NotFoundError = (message) ->
|
||||||
return error
|
return error
|
||||||
NotFoundError.prototype.__proto__ = Error.prototype
|
NotFoundError.prototype.__proto__ = Error.prototype
|
||||||
|
|
||||||
ForbiddenError = (message) ->
|
|
||||||
error = new Error(message)
|
|
||||||
error.name = "ForbiddenError"
|
|
||||||
error.__proto__ = ForbiddenError.prototype
|
|
||||||
return error
|
|
||||||
ForbiddenError.prototype.__proto__ = Error.prototype
|
|
||||||
|
|
||||||
ServiceNotConfiguredError = (message) ->
|
ServiceNotConfiguredError = (message) ->
|
||||||
error = new Error(message)
|
error = new Error(message)
|
||||||
error.name = "ServiceNotConfiguredError"
|
error.name = "ServiceNotConfiguredError"
|
||||||
|
@ -112,7 +105,6 @@ SLInV2Error.prototype.__proto__ = Error.prototype
|
||||||
|
|
||||||
module.exports = Errors =
|
module.exports = Errors =
|
||||||
NotFoundError: NotFoundError
|
NotFoundError: NotFoundError
|
||||||
ForbiddenError: ForbiddenError
|
|
||||||
ServiceNotConfiguredError: ServiceNotConfiguredError
|
ServiceNotConfiguredError: ServiceNotConfiguredError
|
||||||
TooManyRequestsError: TooManyRequestsError
|
TooManyRequestsError: TooManyRequestsError
|
||||||
InvalidNameError: InvalidNameError
|
InvalidNameError: InvalidNameError
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
ProjectController = require "../Project/ProjectController"
|
ProjectController = require "../Project/ProjectController"
|
||||||
AuthenticationController = require '../Authentication/AuthenticationController'
|
AuthenticationController = require '../Authentication/AuthenticationController'
|
||||||
TokenAccessHandler = require './TokenAccessHandler'
|
TokenAccessHandler = require './TokenAccessHandler'
|
||||||
Features = require '../../infrastructure/Features'
|
|
||||||
Errors = require '../Errors/Errors'
|
Errors = require '../Errors/Errors'
|
||||||
logger = require 'logger-sharelatex'
|
logger = require 'logger-sharelatex'
|
||||||
settings = require 'settings-sharelatex'
|
settings = require 'settings-sharelatex'
|
||||||
|
@ -38,17 +37,10 @@ module.exports = TokenAccessController =
|
||||||
if !projectExists and settings.overleaf
|
if !projectExists and settings.overleaf
|
||||||
logger.log {token, userId},
|
logger.log {token, userId},
|
||||||
"[TokenAccess] no project found for this token"
|
"[TokenAccess] no project found for this token"
|
||||||
TokenAccessHandler.getV1DocInfo token, userId, (err, doc_info) ->
|
TokenAccessHandler.getV1DocInfo token, (err, doc_info) ->
|
||||||
return next err if err?
|
return next err if err?
|
||||||
return next(new Errors.NotFoundError()) if doc_info.exported
|
return next(new Errors.NotFoundError()) if doc_info.exported
|
||||||
if Features.hasFeature('force-import-to-v2')
|
return res.redirect(302, "/sign_in_to_v1?return_to=/#{token}")
|
||||||
return res.render('project/v2-import', {
|
|
||||||
projectId: token,
|
|
||||||
hasOwner: doc_info.has_owner,
|
|
||||||
name: doc_info.name
|
|
||||||
})
|
|
||||||
else
|
|
||||||
return res.redirect(302, "/sign_in_to_v1?return_to=/#{token}")
|
|
||||||
else if !project?
|
else if !project?
|
||||||
logger.log {token, userId},
|
logger.log {token, userId},
|
||||||
"[TokenAccess] no token-based project found for readAndWrite token"
|
"[TokenAccess] no token-based project found for readAndWrite token"
|
||||||
|
|
|
@ -2,7 +2,6 @@ Project = require('../../models/Project').Project
|
||||||
CollaboratorsHandler = require('../Collaborators/CollaboratorsHandler')
|
CollaboratorsHandler = require('../Collaborators/CollaboratorsHandler')
|
||||||
PublicAccessLevels = require '../Authorization/PublicAccessLevels'
|
PublicAccessLevels = require '../Authorization/PublicAccessLevels'
|
||||||
PrivilegeLevels = require '../Authorization/PrivilegeLevels'
|
PrivilegeLevels = require '../Authorization/PrivilegeLevels'
|
||||||
UserGetter = require '../User/UserGetter'
|
|
||||||
ObjectId = require("mongojs").ObjectId
|
ObjectId = require("mongojs").ObjectId
|
||||||
Settings = require('settings-sharelatex')
|
Settings = require('settings-sharelatex')
|
||||||
V1Api = require "../V1/V1Api"
|
V1Api = require "../V1/V1Api"
|
||||||
|
@ -111,7 +110,7 @@ module.exports = TokenAccessHandler =
|
||||||
if privilegeLevel != PrivilegeLevels.READ_ONLY
|
if privilegeLevel != PrivilegeLevels.READ_ONLY
|
||||||
project.tokens.readOnly = ''
|
project.tokens.readOnly = ''
|
||||||
|
|
||||||
getV1DocInfo: (token, v2UserId, callback=(err, info)->) ->
|
getV1DocInfo: (token, callback=(err, info)->) ->
|
||||||
# default to allowing access and not exported
|
# default to allowing access and not exported
|
||||||
return callback(null, {
|
return callback(null, {
|
||||||
allow: true
|
allow: true
|
||||||
|
@ -119,9 +118,6 @@ module.exports = TokenAccessHandler =
|
||||||
exported: false
|
exported: false
|
||||||
}) unless Settings.apis?.v1?
|
}) unless Settings.apis?.v1?
|
||||||
|
|
||||||
UserGetter.getUser v2UserId, { overleaf: 1 }, (err, user) ->
|
V1Api.request { url: "/api/v1/sharelatex/docs/#{token}/info" }, (err, response, body) ->
|
||||||
return callback(err) if err?
|
return callback err if err?
|
||||||
v1UserId = user.overleaf?.id
|
callback null, body
|
||||||
V1Api.request { url: "/api/v1/sharelatex/users/#{v1UserId}/docs/#{token}/info" }, (err, response, body) ->
|
|
||||||
return callback err if err?
|
|
||||||
callback null, body
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
request = require 'request'
|
request = require 'request'
|
||||||
settings = require 'settings-sharelatex'
|
settings = require 'settings-sharelatex'
|
||||||
Errors = require '../Errors/Errors'
|
|
||||||
|
|
||||||
# TODO: check what happens when these settings aren't defined
|
# TODO: check what happens when these settings aren't defined
|
||||||
DEFAULT_V1_PARAMS = {
|
DEFAULT_V1_PARAMS = {
|
||||||
|
@ -39,10 +38,6 @@ module.exports = V1Api =
|
||||||
return callback(error, response, body) if error?
|
return callback(error, response, body) if error?
|
||||||
if 200 <= response.statusCode < 300 or response.statusCode in (options.expectedStatusCodes or [])
|
if 200 <= response.statusCode < 300 or response.statusCode in (options.expectedStatusCodes or [])
|
||||||
callback null, response, body
|
callback null, response, body
|
||||||
else if response.statusCode == 403
|
|
||||||
error = new Errors.ForbiddenError("overleaf v1 returned forbidden")
|
|
||||||
error.statusCode = response.statusCode
|
|
||||||
callback error
|
|
||||||
else
|
else
|
||||||
error = new Error("overleaf v1 returned non-success code: #{response.statusCode} #{options.method} #{options.uri}")
|
error = new Error("overleaf v1 returned non-success code: #{response.statusCode} #{options.method} #{options.uri}")
|
||||||
error.statusCode = response.statusCode
|
error.statusCode = response.statusCode
|
||||||
|
|
|
@ -29,7 +29,5 @@ module.exports = Features =
|
||||||
Settings.overleaf? and isEnabled
|
Settings.overleaf? and isEnabled
|
||||||
when 'redirect-sl'
|
when 'redirect-sl'
|
||||||
return Settings.redirectToV2?
|
return Settings.redirectToV2?
|
||||||
when 'force-import-to-v2'
|
|
||||||
return Settings.forceImportToV2
|
|
||||||
else
|
else
|
||||||
throw new Error("unknown feature: #{feature}")
|
throw new Error("unknown feature: #{feature}")
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
extends ../layout
|
|
||||||
|
|
||||||
block content
|
|
||||||
main.content
|
|
||||||
.container
|
|
||||||
.row
|
|
||||||
.col-sm-8.col-sm-offset-2
|
|
||||||
h1.text-center Move project to Overleaf v2
|
|
||||||
img.v2-import__img(
|
|
||||||
src="/img/v1-import/v2-editor.png"
|
|
||||||
alt="The new V2 editor."
|
|
||||||
)
|
|
||||||
|
|
||||||
if hasOwner
|
|
||||||
p.text-center.row-spaced-small
|
|
||||||
| #[strong #{name}] has not yet been moved into the new version of
|
|
||||||
| Overleaf. You will need to move it in order to continue working
|
|
||||||
| on it. It should only take a few seconds.
|
|
||||||
|
|
||||||
form(
|
|
||||||
async-form="v2Import"
|
|
||||||
name="v2ImportForm"
|
|
||||||
action="/overleaf/project/"+ projectId + "/import"
|
|
||||||
method="POST"
|
|
||||||
ng-cloak
|
|
||||||
)
|
|
||||||
input(name='_csrf', type='hidden', value=csrfToken)
|
|
||||||
form-messages(for="v2ImportForm")
|
|
||||||
input.row-spaced.btn.btn-primary.text-center.center-block(
|
|
||||||
type="submit"
|
|
||||||
value="Move Project and Continue"
|
|
||||||
ng-disabled="v2ImportForm.inflight || v2ImportForm.response.success"
|
|
||||||
)
|
|
||||||
else
|
|
||||||
p.text-center.row-spaced.small
|
|
||||||
| #[strong #{name}] has not yet been moved into the new version of
|
|
||||||
| Overleaf. This project was created anonymously and therefore
|
|
||||||
| cannot be automatically imported. Please download a zip file of
|
|
||||||
| the project and upload that to continue editing it.
|
|
||||||
|
|
||||||
button.row-spaced.btn.btn-primary.text-center.center-block
|
|
||||||
| Download project zip file
|
|
||||||
|
|
||||||
|
|
||||||
h3 What can I do once I've moved my project?
|
|
||||||
ul
|
|
||||||
li New & Improved Editor
|
|
||||||
li Tracked Changed & Comments
|
|
||||||
li Git access (still supported)
|
|
||||||
|
|
||||||
h3 Is there anything I can't do once I've moved my project to
|
|
||||||
ul
|
|
||||||
li Assignments
|
|
||||||
li F1000 Research Workflow
|
|
||||||
li
|
|
||||||
| Files you have imported from CiteULike and Plotly will become
|
|
||||||
| ordinary files, but you can still use these services by
|
|
||||||
| downloading and uploading files
|
|
||||||
li
|
|
||||||
| Publishing to Figshare and PeerWith are not presently available,
|
|
||||||
| but improved versions will be coming back
|
|
|
@ -7,5 +7,4 @@
|
||||||
@import "app/institution-hub.less";
|
@import "app/institution-hub.less";
|
||||||
@import "app/publisher-hub.less";
|
@import "app/publisher-hub.less";
|
||||||
@import "app/admin-hub.less";
|
@import "app/admin-hub.less";
|
||||||
@import "app/import.less";
|
|
||||||
@import "components/overbox.less";
|
@import "components/overbox.less";
|
|
@ -1,5 +0,0 @@
|
||||||
.v2-import__img {
|
|
||||||
.img-responsive;
|
|
||||||
.center-block;
|
|
||||||
width: 80%;
|
|
||||||
}
|
|
|
@ -132,7 +132,7 @@ module.exports = MockV1Api =
|
||||||
console.error "error starting MockV1Api:", error.message
|
console.error "error starting MockV1Api:", error.message
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
|
||||||
app.get '/api/v1/sharelatex/users/:user_id/docs/:token/info', (req, res, next) =>
|
app.get '/api/v1/sharelatex/docs/:token/info', (req, res, next) =>
|
||||||
res.json { allow: true, exported: false }
|
res.json { allow: true, exported: false }
|
||||||
|
|
||||||
MockV1Api.run()
|
MockV1Api.run()
|
||||||
|
|
|
@ -35,9 +35,6 @@ describe "TokenAccessController", ->
|
||||||
exported: false
|
exported: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
'../../infrastructure/Features': @Features = {
|
|
||||||
hasFeature: sinon.stub().returns(false)
|
|
||||||
}
|
|
||||||
'logger-sharelatex': {log: sinon.stub(), err: sinon.stub()}
|
'logger-sharelatex': {log: sinon.stub(), err: sinon.stub()}
|
||||||
'settings-sharelatex': {
|
'settings-sharelatex': {
|
||||||
overleaf:
|
overleaf:
|
||||||
|
@ -253,7 +250,6 @@ describe "TokenAccessController", ->
|
||||||
@req.url = '/123abc'
|
@req.url = '/123abc'
|
||||||
@res = new MockResponse()
|
@res = new MockResponse()
|
||||||
@res.redirect = sinon.stub()
|
@res.redirect = sinon.stub()
|
||||||
@res.render = sinon.stub()
|
|
||||||
@next = sinon.stub()
|
@next = sinon.stub()
|
||||||
@req.params['read_and_write_token'] = '123abc'
|
@req.params['read_and_write_token'] = '123abc'
|
||||||
@TokenAccessHandler.findProjectWithReadAndWriteToken = sinon.stub()
|
@TokenAccessHandler.findProjectWithReadAndWriteToken = sinon.stub()
|
||||||
|
@ -261,11 +257,8 @@ describe "TokenAccessController", ->
|
||||||
|
|
||||||
describe 'when project was not exported from v1', ->
|
describe 'when project was not exported from v1', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@TokenAccessHandler.getV1DocInfo = sinon.stub().yields(null, {
|
@TokenAccessHandler.checkV1ProjectExported = sinon.stub()
|
||||||
allow: true
|
.callsArgWith(1, null, false)
|
||||||
exists: true
|
|
||||||
exported: false
|
|
||||||
})
|
|
||||||
@TokenAccessController.readAndWriteToken @req, @res, @next
|
@TokenAccessController.readAndWriteToken @req, @res, @next
|
||||||
|
|
||||||
it 'should redirect to v1', (done) ->
|
it 'should redirect to v1', (done) ->
|
||||||
|
@ -276,87 +269,14 @@ describe "TokenAccessController", ->
|
||||||
)).to.equal true
|
)).to.equal true
|
||||||
done()
|
done()
|
||||||
|
|
||||||
describe 'when project was not exported from v1 but forcing import to v2', ->
|
|
||||||
beforeEach ->
|
|
||||||
@Features.hasFeature.returns(true)
|
|
||||||
|
|
||||||
describe 'with project name', ->
|
|
||||||
beforeEach ->
|
|
||||||
@TokenAccessHandler.getV1DocInfo = sinon.stub().yields(null, {
|
|
||||||
allow: true
|
|
||||||
exists: true
|
|
||||||
exported: false
|
|
||||||
has_owner: true
|
|
||||||
name: 'A title'
|
|
||||||
})
|
|
||||||
@TokenAccessController.readAndWriteToken @req, @res, @next
|
|
||||||
|
|
||||||
it 'should render v2-import page with name', (done) ->
|
|
||||||
expect(@res.render.calledWith(
|
|
||||||
'project/v2-import',
|
|
||||||
{
|
|
||||||
projectId: '123abc'
|
|
||||||
name: 'A title'
|
|
||||||
hasOwner: true
|
|
||||||
}
|
|
||||||
)).to.equal true
|
|
||||||
done()
|
|
||||||
|
|
||||||
describe 'with project owner', ->
|
|
||||||
beforeEach ->
|
|
||||||
@TokenAccessHandler.getV1DocInfo = sinon.stub().yields(null, {
|
|
||||||
allow: true
|
|
||||||
exists: true
|
|
||||||
exported: false
|
|
||||||
has_owner: true
|
|
||||||
name: 'A title'
|
|
||||||
})
|
|
||||||
@TokenAccessController.readAndWriteToken @req, @res, @next
|
|
||||||
|
|
||||||
it 'should render v2-import page', (done) ->
|
|
||||||
expect(@res.render.calledWith(
|
|
||||||
'project/v2-import',
|
|
||||||
{
|
|
||||||
projectId: '123abc',
|
|
||||||
hasOwner: true
|
|
||||||
name: 'A title'
|
|
||||||
}
|
|
||||||
)).to.equal true
|
|
||||||
done()
|
|
||||||
|
|
||||||
describe 'without project owner', ->
|
|
||||||
beforeEach ->
|
|
||||||
@TokenAccessHandler.getV1DocInfo = sinon.stub().yields(null, {
|
|
||||||
allow: true
|
|
||||||
exists: true
|
|
||||||
exported: false
|
|
||||||
has_owner: false
|
|
||||||
name: 'A title'
|
|
||||||
})
|
|
||||||
@TokenAccessController.readAndWriteToken @req, @res, @next
|
|
||||||
|
|
||||||
it 'should render v2-import page', (done) ->
|
|
||||||
expect(@res.render.calledWith(
|
|
||||||
'project/v2-import',
|
|
||||||
{
|
|
||||||
projectId: '123abc',
|
|
||||||
hasOwner: false
|
|
||||||
name: 'A title'
|
|
||||||
}
|
|
||||||
)).to.equal true
|
|
||||||
done()
|
|
||||||
|
|
||||||
describe 'when project was exported from v1', ->
|
describe 'when project was exported from v1', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@TokenAccessHandler.getV1DocInfo = sinon.stub().yields(null, {
|
@TokenAccessHandler.checkV1ProjectExported = sinon.stub()
|
||||||
allow: true
|
.callsArgWith(1, null, false)
|
||||||
exists: true
|
|
||||||
exported: true
|
|
||||||
})
|
|
||||||
@TokenAccessController.readAndWriteToken @req, @res, @next
|
@TokenAccessController.readAndWriteToken @req, @res, @next
|
||||||
|
|
||||||
it 'should call next with a not-found error', (done) ->
|
it 'should call next with a not-found error', (done) ->
|
||||||
expect(@next.callCount).to.equal 1
|
expect(@next.callCount).to.equal 0
|
||||||
done()
|
done()
|
||||||
|
|
||||||
describe 'when token access is off, but user has higher access anyway', ->
|
describe 'when token access is off, but user has higher access anyway', ->
|
||||||
|
|
|
@ -21,7 +21,6 @@ describe "TokenAccessHandler", ->
|
||||||
'../../models/Project': {Project: @Project = {}}
|
'../../models/Project': {Project: @Project = {}}
|
||||||
'settings-sharelatex': @settings = {}
|
'settings-sharelatex': @settings = {}
|
||||||
'../Collaborators/CollaboratorsHandler': @CollaboratorsHandler = {}
|
'../Collaborators/CollaboratorsHandler': @CollaboratorsHandler = {}
|
||||||
'../User/UserGetter': @UserGetter = {}
|
|
||||||
'../V1/V1Api': @V1Api = {
|
'../V1/V1Api': @V1Api = {
|
||||||
request: sinon.stub()
|
request: sinon.stub()
|
||||||
}
|
}
|
||||||
|
@ -494,12 +493,11 @@ describe "TokenAccessHandler", ->
|
||||||
|
|
||||||
describe 'getV1DocInfo', ->
|
describe 'getV1DocInfo', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@v2UserId = 123
|
|
||||||
@callback = sinon.stub()
|
@callback = sinon.stub()
|
||||||
|
|
||||||
describe 'when v1 api not set', ->
|
describe 'when v1 api not set', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@TokenAccessHandler.getV1DocInfo @token, @v2UserId, @callback
|
@TokenAccessHandler.getV1DocInfo @token, @callback
|
||||||
|
|
||||||
it 'should not check access and return default info', ->
|
it 'should not check access and return default info', ->
|
||||||
expect(@V1Api.request.called).to.equal false
|
expect(@V1Api.request.called).to.equal false
|
||||||
|
@ -513,45 +511,19 @@ describe "TokenAccessHandler", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@settings.apis = { v1: 'v1' }
|
@settings.apis = { v1: 'v1' }
|
||||||
|
|
||||||
describe 'on UserGetter.getUser success', ->
|
describe 'on success', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@UserGetter.getUser = sinon.stub().yields(null, {
|
|
||||||
overleaf: { id: 1 }
|
|
||||||
})
|
|
||||||
@TokenAccessHandler.getV1DocInfo @token, @v2UserId, @callback
|
|
||||||
|
|
||||||
it 'should get user', ->
|
|
||||||
expect(@UserGetter.getUser.calledWith(@v2UserId)).to.equal true
|
|
||||||
|
|
||||||
describe 'on UserGetter.getUser error', ->
|
|
||||||
beforeEach ->
|
|
||||||
@error = new Error('failed to get user')
|
|
||||||
@UserGetter.getUser = sinon.stub().yields(@error)
|
|
||||||
@TokenAccessHandler.getV1DocInfo @token, @v2UserId, @callback
|
|
||||||
|
|
||||||
it 'should callback with error', ->
|
|
||||||
expect(@callback.calledWith @error).to.equal true
|
|
||||||
|
|
||||||
describe 'on V1Api.request success', ->
|
|
||||||
beforeEach ->
|
|
||||||
@v1UserId = 1
|
|
||||||
@UserGetter.getUser = sinon.stub().yields(null, {
|
|
||||||
overleaf: { id: @v1UserId }
|
|
||||||
})
|
|
||||||
@V1Api.request = sinon.stub().callsArgWith(1, null, null, 'mock-data')
|
@V1Api.request = sinon.stub().callsArgWith(1, null, null, 'mock-data')
|
||||||
@TokenAccessHandler.getV1DocInfo @token, @v2UserId, @callback
|
@TokenAccessHandler.getV1DocInfo @token, @callback
|
||||||
|
|
||||||
it 'should return response body', ->
|
it 'should return response body', ->
|
||||||
expect(@V1Api.request.calledWith { url: "/api/v1/sharelatex/users/#{@v1UserId}/docs/#{@token}/info" }).to.equal true
|
expect(@V1Api.request.calledWith { url: "/api/v1/sharelatex/docs/#{@token}/info" }).to.equal true
|
||||||
expect(@callback.calledWith null, 'mock-data').to.equal true
|
expect(@callback.calledWith null, 'mock-data').to.equal true
|
||||||
|
|
||||||
describe 'on V1Api.request error', ->
|
describe 'on error', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@UserGetter.getUser = sinon.stub().yields(null, {
|
|
||||||
overleaf: { id: 1 }
|
|
||||||
})
|
|
||||||
@V1Api.request = sinon.stub().callsArgWith(1, 'error')
|
@V1Api.request = sinon.stub().callsArgWith(1, 'error')
|
||||||
@TokenAccessHandler.getV1DocInfo @token, @v2UserId, @callback
|
@TokenAccessHandler.getV1DocInfo @token, @callback
|
||||||
|
|
||||||
it 'should callback with error', ->
|
it 'should callback with error', ->
|
||||||
expect(@callback.calledWith 'error').to.equal true
|
expect(@callback.calledWith 'error').to.equal true
|
||||||
|
|
Loading…
Reference in a new issue