mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 21:33:24 +03:00
commit
b6528c0494
@ -43,7 +43,7 @@ db = {
|
||||
* - If there is no path
|
||||
* - If the name doesn't have json in it
|
||||
*/
|
||||
return when.reject(new errors.InternalServerError('Please select a .json file to import.'));
|
||||
return when.reject(new errors.UnsupportedMediaTypeError('Please select a .json file to import.'));
|
||||
}
|
||||
|
||||
return api.settings.read({key: 'databaseVersion', context: { internal: true }}).then(function (response) {
|
||||
|
@ -208,6 +208,9 @@ http = function (apiMethod) {
|
||||
}).then(function addLocationHeader(header) {
|
||||
if (header) {
|
||||
res.set({'Location': header});
|
||||
// The location header indicates that a new object was created.
|
||||
// In this case the status code should be 201 Created
|
||||
res.status(201);
|
||||
}
|
||||
|
||||
// Add Content-Disposition Header
|
||||
|
@ -12,6 +12,7 @@ var _ = require('lodash'),
|
||||
RequestEntityTooLargeError = require('./requesttoolargeerror'),
|
||||
UnauthorizedError = require('./unauthorizederror'),
|
||||
ValidationError = require('./validationerror'),
|
||||
UnsupportedMediaTypeError = require('./unsupportedmediaerror'),
|
||||
EmailError = require('./emailerror'),
|
||||
errors,
|
||||
|
||||
@ -258,4 +259,5 @@ module.exports.NoPermissionError = NoPermissionError;
|
||||
module.exports.UnauthorizedError = UnauthorizedError;
|
||||
module.exports.ValidationError = ValidationError;
|
||||
module.exports.RequestEntityTooLargeError = RequestEntityTooLargeError;
|
||||
module.exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
|
||||
module.exports.EmailError = EmailError;
|
||||
|
15
core/server/errors/unsupportedmediaerror.js
Normal file
15
core/server/errors/unsupportedmediaerror.js
Normal file
@ -0,0 +1,15 @@
|
||||
// # Unsupported Media Type
|
||||
// Custom error class with status code and type prefilled.
|
||||
|
||||
function UnsupportedMediaTypeError(message) {
|
||||
this.message = message;
|
||||
this.stack = new Error().stack;
|
||||
this.code = 415;
|
||||
this.type = this.name;
|
||||
}
|
||||
|
||||
UnsupportedMediaTypeError.prototype = Object.create(Error.prototype);
|
||||
UnsupportedMediaTypeError.prototype.name = "UnsupportedMediaTypeError";
|
||||
|
||||
|
||||
module.exports = UnsupportedMediaTypeError;
|
@ -86,7 +86,7 @@ describe('Notifications API', function () {
|
||||
request.post(testUtils.API.getApiQuery('notifications/'))
|
||||
.set('X-CSRF-Token', csrfToken)
|
||||
.send(newNotification)
|
||||
.expect(200)
|
||||
.expect(201)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
@ -119,7 +119,7 @@ describe('Notifications API', function () {
|
||||
request.post(testUtils.API.getApiQuery('notifications/'))
|
||||
.set('X-CSRF-Token', csrfToken)
|
||||
.send(newNotification)
|
||||
.expect(200)
|
||||
.expect(201)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
|
@ -355,7 +355,7 @@ describe('Post API', function () {
|
||||
request.post(testUtils.API.getApiQuery('posts/?include=tags'))
|
||||
.set('X-CSRF-Token', csrfToken)
|
||||
.send(newPost)
|
||||
.expect(200)
|
||||
.expect(201)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
@ -713,7 +713,7 @@ describe('Post API', function () {
|
||||
request.post(testUtils.API.getApiQuery('posts/'))
|
||||
.set('X-CSRF-Token', csrfToken)
|
||||
.send(newPost)
|
||||
.expect(200)
|
||||
.expect(201)
|
||||
.end(function (err ,res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
|
Loading…
Reference in New Issue
Block a user