-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from holidayextras/disable-unwanted-actions
Prevent crash when requesting unavailable functionality
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
var jsonApi = require("../.."); | ||
|
||
module.exports = new jsonApi.MemoryHandler(); | ||
module.exports.delete = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"use strict"; | ||
var request = require("request"); | ||
var assert = require("assert"); | ||
var helpers = require("./helpers.js"); | ||
var jsonApiTestServer = require("../example/server.js"); | ||
|
||
|
||
describe("Testing jsonapi-server", function() { | ||
describe("unavailable functions", function() { | ||
it("responds with a clear error", function(done) { | ||
var data = { | ||
method: "delete", | ||
url: "http://localhost:16006/rest/photos/14" | ||
}; | ||
request(data, function(err, res, json) { | ||
assert.equal(err, null); | ||
json = helpers.validateError(json); | ||
assert.equal(res.statusCode, "403", "Expecting 403"); | ||
assert.equal(json.errors[0].detail, "The requested resource 'photos' does not support 'delete'"); | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
before(function() { | ||
jsonApiTestServer.start(); | ||
}); | ||
after(function() { | ||
jsonApiTestServer.close(); | ||
}); | ||
}); |