Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send correct method not supported error and status #156

Merged
merged 1 commit into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class BaseController {
methodNotSupported(req, res, next) {
debug('%s #methodNotSupported', req.originalUrl);
let err = new Error('Method not supported');
err.statusCode = 405;
err.code = 'METHOD_NOT_SUPPORTED';
err.status = 405;
next(err);
}

Expand Down
3 changes: 2 additions & 1 deletion test/controller/spec.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ describe('Form Controller', () => {
controller.methodNotSupported(req, res, next);
next.should.have.been.called.and.calledWithExactly(sinon.match.instanceOf(Error));
let err = next.args[0][0];
err.statusCode.should.equal(405);
err.status.should.equal(405);
err.code.should.equal('METHOD_NOT_SUPPORTED');
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/controller/spec.lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe('Controller Lifecycle', () => {
next.should.have.been.called;
let err = next.args[0][0];
err.should.be.instanceOf(Error);
err.statusCode.should.equal(405);
err.status.should.equal(405);
done();
};

Expand Down