Comparing version 0.7.5 to 0.8.0
@@ -79,14 +79,14 @@ /** | ||
// determine if no results | ||
if (__.isObject(result)) { | ||
if (!Object.keys(result).length) { | ||
if (operation === enums.CrudOps.READ_ONE) { | ||
if (__.isPlainObject(result)) { | ||
if (!Object.keys(result).length) { | ||
httpCode = enums.HttpCode.NOT_FOUND; | ||
} | ||
} else if (!result) { | ||
httpCode = enums.HttpCode.NOT_FOUND; | ||
} | ||
} else if (__.isArray(result)) { | ||
if (!result.length) { | ||
httpCode = enums.HttpCode.NOT_FOUND; | ||
} | ||
} | ||
self.opts.onSuccess(req, res, operation, httpCode, result); | ||
}; | ||
@@ -93,0 +93,0 @@ }; |
{ | ||
"name": "crude", | ||
"description": "Creates CRUD RESTfull endpoints for a given route", | ||
"version": "0.7.5", | ||
"version": "0.8.0", | ||
"homepage": "https://github.com/thanpolas/crude", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -56,2 +56,4 @@ # Crude | ||
- **v0.8.0**, *28 Jul 2015* | ||
- Will now return an HTTP Status 200 when no results for reading multiple records (used to return 404). | ||
- **v0.7.5**, *23 Jul 2015* | ||
@@ -58,0 +60,0 @@ - Will now allow for GET queries with multiple items per attribute. |
@@ -31,4 +31,9 @@ /** | ||
this.ctrl = testerLocal.controller(); | ||
this.ctrlEmpty = testerLocal.controllerEmpty(); | ||
this.crude = crude('/mock', this.ctrl, testCase.expressApp.app); | ||
this.crudeEmpty = crude('/empty', this.ctrlEmpty, testCase.expressApp.app); | ||
this.crude.config({pagination: false}); | ||
this.crudeEmpty.config({pagination: false}); | ||
}); | ||
@@ -100,2 +105,13 @@ | ||
}); | ||
describe('Reading with no records', function () { | ||
it('ReadAll should return 200', function (done) { | ||
this.req.get('/empty') | ||
.expect(200, done); | ||
}); | ||
it('ReadOne should return 404', function (done) { | ||
this.req.get('/empty/a') | ||
.expect(404, done); | ||
}); | ||
}); | ||
}); |
@@ -37,2 +37,23 @@ /** | ||
/** | ||
* Returns A stub controller for crude with no records. | ||
* | ||
* @return {Object} A stub controller for crude. | ||
*/ | ||
tester.controllerEmpty = function() { | ||
var item = null; | ||
var ctrl = { | ||
__item: item, | ||
create: sinon.stub().returns(item), | ||
read: sinon.stub().returns([]), | ||
readLimit: sinon.stub().returns([]), | ||
readOne: sinon.stub().returns(item), | ||
update: sinon.stub().returns(item), | ||
count: sinon.stub().returns(0), | ||
delete: sinon.stub().returns(item), | ||
}; | ||
return ctrl; | ||
}; | ||
/** | ||
* Return express Request / Response objects. | ||
@@ -39,0 +60,0 @@ * |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76002
1810
100