Merge pull request #3021 from overleaf/msm-oerror-remove-conflict-error
Replace ConflictError thrown with calls to HttpErrorHandler.conflict() GitOrigin-RevId: 3b4d98af1b31e49ceab4b1b55b94b8f0323c8a9b
This commit is contained in:
@@ -63,6 +63,44 @@ describe('HttpErrorHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('conflict', function() {
|
||||
it('returns 409', function() {
|
||||
this.HttpErrorHandler.conflict(this.req, this.res)
|
||||
expect(this.res.statusCode).to.equal(409)
|
||||
})
|
||||
|
||||
it('should print a message when no content-type is included', function() {
|
||||
this.HttpErrorHandler.conflict(this.req, this.res)
|
||||
expect(this.res.body).to.equal('conflict')
|
||||
})
|
||||
|
||||
it("should render a template including the error message when content-type is 'html'", function() {
|
||||
this.req.accepts = () => 'html'
|
||||
this.HttpErrorHandler.unprocessableEntity(this.req, this.res, 'an error')
|
||||
expect(this.res.renderedTemplate).to.equal('general/400')
|
||||
expect(this.res.renderedVariables).to.deep.equal({
|
||||
title: 'Client Error',
|
||||
message: 'an error'
|
||||
})
|
||||
})
|
||||
|
||||
it("should return a json object when content-type is 'json'", function() {
|
||||
this.req.accepts = () => 'json'
|
||||
this.HttpErrorHandler.unprocessableEntity(
|
||||
this.req,
|
||||
this.res,
|
||||
'an error',
|
||||
{
|
||||
foo: 'bar'
|
||||
}
|
||||
)
|
||||
expect(JSON.parse(this.res.body)).to.deep.equal({
|
||||
message: 'an error',
|
||||
foo: 'bar'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('forbidden', function() {
|
||||
it('returns 403', function() {
|
||||
this.HttpErrorHandler.forbidden(this.req, this.res)
|
||||
|
||||
Reference in New Issue
Block a user