mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 07:25:10 -05:00
Fix error-handling in setPublicAccessLevel
This commit is contained in:
parent
18443b55cb
commit
ec94e59388
2 changed files with 16 additions and 1 deletions
|
@ -74,7 +74,7 @@ module.exports = ProjectDetailsHandler =
|
||||||
PublicAccessLevels.TOKEN_BASED
|
PublicAccessLevels.TOKEN_BASED
|
||||||
], newAccessLevel
|
], newAccessLevel
|
||||||
Project.update {_id:project_id},{publicAccesLevel:newAccessLevel}, (err)->
|
Project.update {_id:project_id},{publicAccesLevel:newAccessLevel}, (err)->
|
||||||
callback()
|
callback(err)
|
||||||
|
|
||||||
ensureTokensArePresent: (project_id, callback=(err, tokens)->) ->
|
ensureTokensArePresent: (project_id, callback=(err, tokens)->) ->
|
||||||
ProjectGetter.getProject project_id, {tokens: 1}, (err, project) ->
|
ProjectGetter.getProject project_id, {tokens: 1}, (err, project) ->
|
||||||
|
|
|
@ -150,6 +150,21 @@ describe 'ProjectDetailsHandler', ->
|
||||||
@ProjectModel.update.calledWith({_id: @project_id}, {publicAccesLevel: @accessLevel}).should.equal true
|
@ProjectModel.update.calledWith({_id: @project_id}, {publicAccesLevel: @accessLevel}).should.equal true
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
it 'should not produce an error', (done) ->
|
||||||
|
@handler.setPublicAccessLevel @project_id, @accessLevel, (err) =>
|
||||||
|
expect(err).to.not.exist
|
||||||
|
done()
|
||||||
|
|
||||||
|
describe 'when update produces an error', ->
|
||||||
|
beforeEach ->
|
||||||
|
@ProjectModel.update.callsArgWith(2, new Error('woops'))
|
||||||
|
|
||||||
|
it 'should produce an error', (done) ->
|
||||||
|
@handler.setPublicAccessLevel @project_id, @accessLevel, (err) =>
|
||||||
|
expect(err).to.exist
|
||||||
|
expect(err).to.be.instanceof Error
|
||||||
|
done()
|
||||||
|
|
||||||
describe "ensureTokensArePresent", ->
|
describe "ensureTokensArePresent", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue