From 716ed4569fe79b4b153a46ce8243785a00735705 Mon Sep 17 00:00:00 2001 From: Simon Ho Date: Fri, 18 Sep 2015 19:13:08 -0700 Subject: [PATCH 1/2] Add test fixtures for shared methods --- .../both-configs-set/common/models/todo.js | 3 ++ .../both-configs-set/common/models/todo.json | 18 ++++++++ .../both-configs-set/server/config.json | 32 +++++++++++++ .../both-configs-set/server/datasources.json | 6 +++ .../both-configs-set/server/model-config.json | 46 +++++++++++++++++++ .../both-configs-set/server/server.js | 6 +++ .../common/models/todo.js | 3 ++ .../common/models/todo.json | 18 ++++++++ .../config-default-false/server/config.json | 31 +++++++++++++ .../server/datasources.json | 6 +++ .../server/model-config.json | 39 ++++++++++++++++ .../config-default-false/server/server.js | 6 +++ .../config-default-true/common/models/todo.js | 3 ++ .../common/models/todo.json | 18 ++++++++ .../config-default-true/server/config.json | 31 +++++++++++++ .../server/datasources.json | 6 +++ .../server/model-config.json | 39 ++++++++++++++++ .../config-default-true/server/server.js | 6 +++ .../common/models/todo.js | 3 ++ .../common/models/todo.json | 18 ++++++++ .../config-defined-false/server/config.json | 31 +++++++++++++ .../server/datasources.json | 6 +++ .../server/model-config.json | 39 ++++++++++++++++ .../config-defined-false/server/server.js | 6 +++ .../config-defined-true/common/models/todo.js | 3 ++ .../common/models/todo.json | 18 ++++++++ .../config-defined-true/server/config.json | 31 +++++++++++++ .../server/datasources.json | 6 +++ .../server/model-config.json | 39 ++++++++++++++++ .../config-defined-true/server/server.js | 6 +++ .../common/models/todo.js | 3 ++ .../common/models/todo.json | 18 ++++++++ .../server/config.json | 28 +++++++++++ .../server/datasources.json | 6 +++ .../server/model-config.json | 46 +++++++++++++++++++ .../server/server.js | 6 +++ .../common/models/todo.js | 3 ++ .../common/models/todo.json | 18 ++++++++ .../server/config.json | 28 +++++++++++ .../server/datasources.json | 6 +++ .../server/model-config.json | 46 +++++++++++++++++++ .../server/server.js | 6 +++ .../common/models/todo.js | 3 ++ .../common/models/todo.json | 18 ++++++++ .../server/config.json | 28 +++++++++++ .../server/datasources.json | 6 +++ .../server/model-config.json | 46 +++++++++++++++++++ .../server/server.js | 6 +++ .../common/models/todo.js | 3 ++ .../common/models/todo.json | 18 ++++++++ .../server/config.json | 28 +++++++++++ .../server/datasources.json | 6 +++ .../server/model-config.json | 46 +++++++++++++++++++ .../server/server.js | 6 +++ 54 files changed, 951 insertions(+) create mode 100644 test/fixtures/shared-methods/both-configs-set/common/models/todo.js create mode 100644 test/fixtures/shared-methods/both-configs-set/common/models/todo.json create mode 100644 test/fixtures/shared-methods/both-configs-set/server/config.json create mode 100644 test/fixtures/shared-methods/both-configs-set/server/datasources.json create mode 100644 test/fixtures/shared-methods/both-configs-set/server/model-config.json create mode 100644 test/fixtures/shared-methods/both-configs-set/server/server.js create mode 100644 test/fixtures/shared-methods/config-default-false/common/models/todo.js create mode 100644 test/fixtures/shared-methods/config-default-false/common/models/todo.json create mode 100644 test/fixtures/shared-methods/config-default-false/server/config.json create mode 100644 test/fixtures/shared-methods/config-default-false/server/datasources.json create mode 100644 test/fixtures/shared-methods/config-default-false/server/model-config.json create mode 100644 test/fixtures/shared-methods/config-default-false/server/server.js create mode 100644 test/fixtures/shared-methods/config-default-true/common/models/todo.js create mode 100644 test/fixtures/shared-methods/config-default-true/common/models/todo.json create mode 100644 test/fixtures/shared-methods/config-default-true/server/config.json create mode 100644 test/fixtures/shared-methods/config-default-true/server/datasources.json create mode 100644 test/fixtures/shared-methods/config-default-true/server/model-config.json create mode 100644 test/fixtures/shared-methods/config-default-true/server/server.js create mode 100644 test/fixtures/shared-methods/config-defined-false/common/models/todo.js create mode 100644 test/fixtures/shared-methods/config-defined-false/common/models/todo.json create mode 100644 test/fixtures/shared-methods/config-defined-false/server/config.json create mode 100644 test/fixtures/shared-methods/config-defined-false/server/datasources.json create mode 100644 test/fixtures/shared-methods/config-defined-false/server/model-config.json create mode 100644 test/fixtures/shared-methods/config-defined-false/server/server.js create mode 100644 test/fixtures/shared-methods/config-defined-true/common/models/todo.js create mode 100644 test/fixtures/shared-methods/config-defined-true/common/models/todo.json create mode 100644 test/fixtures/shared-methods/config-defined-true/server/config.json create mode 100644 test/fixtures/shared-methods/config-defined-true/server/datasources.json create mode 100644 test/fixtures/shared-methods/config-defined-true/server/model-config.json create mode 100644 test/fixtures/shared-methods/config-defined-true/server/server.js create mode 100644 test/fixtures/shared-methods/model-config-default-false/common/models/todo.js create mode 100644 test/fixtures/shared-methods/model-config-default-false/common/models/todo.json create mode 100644 test/fixtures/shared-methods/model-config-default-false/server/config.json create mode 100644 test/fixtures/shared-methods/model-config-default-false/server/datasources.json create mode 100644 test/fixtures/shared-methods/model-config-default-false/server/model-config.json create mode 100644 test/fixtures/shared-methods/model-config-default-false/server/server.js create mode 100644 test/fixtures/shared-methods/model-config-default-true/common/models/todo.js create mode 100644 test/fixtures/shared-methods/model-config-default-true/common/models/todo.json create mode 100644 test/fixtures/shared-methods/model-config-default-true/server/config.json create mode 100644 test/fixtures/shared-methods/model-config-default-true/server/datasources.json create mode 100644 test/fixtures/shared-methods/model-config-default-true/server/model-config.json create mode 100644 test/fixtures/shared-methods/model-config-default-true/server/server.js create mode 100644 test/fixtures/shared-methods/model-config-defined-false/common/models/todo.js create mode 100644 test/fixtures/shared-methods/model-config-defined-false/common/models/todo.json create mode 100644 test/fixtures/shared-methods/model-config-defined-false/server/config.json create mode 100644 test/fixtures/shared-methods/model-config-defined-false/server/datasources.json create mode 100644 test/fixtures/shared-methods/model-config-defined-false/server/model-config.json create mode 100644 test/fixtures/shared-methods/model-config-defined-false/server/server.js create mode 100644 test/fixtures/shared-methods/model-config-defined-true/common/models/todo.js create mode 100644 test/fixtures/shared-methods/model-config-defined-true/common/models/todo.json create mode 100644 test/fixtures/shared-methods/model-config-defined-true/server/config.json create mode 100644 test/fixtures/shared-methods/model-config-defined-true/server/datasources.json create mode 100644 test/fixtures/shared-methods/model-config-defined-true/server/model-config.json create mode 100644 test/fixtures/shared-methods/model-config-defined-true/server/server.js diff --git a/test/fixtures/shared-methods/both-configs-set/common/models/todo.js b/test/fixtures/shared-methods/both-configs-set/common/models/todo.js new file mode 100644 index 00000000..43ab55fb --- /dev/null +++ b/test/fixtures/shared-methods/both-configs-set/common/models/todo.js @@ -0,0 +1,3 @@ +module.exports = function(Todo) { + +}; diff --git a/test/fixtures/shared-methods/both-configs-set/common/models/todo.json b/test/fixtures/shared-methods/both-configs-set/common/models/todo.json new file mode 100644 index 00000000..356ba10d --- /dev/null +++ b/test/fixtures/shared-methods/both-configs-set/common/models/todo.json @@ -0,0 +1,18 @@ +{ + "name": "Todo", + "base": "PersistedModel", + "idInjection": true, + "options": { + "validateUpsert": true + }, + "properties": { + "content": { + "type": "string", + "required": true + } + }, + "validations": [], + "relations": {}, + "acls": [], + "methods": {} +} diff --git a/test/fixtures/shared-methods/both-configs-set/server/config.json b/test/fixtures/shared-methods/both-configs-set/server/config.json new file mode 100644 index 00000000..13db709e --- /dev/null +++ b/test/fixtures/shared-methods/both-configs-set/server/config.json @@ -0,0 +1,32 @@ +{ + "restApiRoot": "/api", + "host": "0.0.0.0", + "port": 3000, + "remoting": { + "context": { + "enableHttpContext": false + }, + "rest": { + "normalizeHttpPath": false, + "xml": false + }, + "json": { + "strict": false, + "limit": "100kb" + }, + "urlencoded": { + "extended": true, + "limit": "100kb" + }, + "cors": false, + "errorHandler": { + "disableStackTrace": false + }, + "sharedMethods": { + "*": false, + "destroyAll": true + } + }, + "legacyExplorer": false +} + diff --git a/test/fixtures/shared-methods/both-configs-set/server/datasources.json b/test/fixtures/shared-methods/both-configs-set/server/datasources.json new file mode 100644 index 00000000..d6caf56d --- /dev/null +++ b/test/fixtures/shared-methods/both-configs-set/server/datasources.json @@ -0,0 +1,6 @@ +{ + "db": { + "name": "db", + "connector": "memory" + } +} diff --git a/test/fixtures/shared-methods/both-configs-set/server/model-config.json b/test/fixtures/shared-methods/both-configs-set/server/model-config.json new file mode 100644 index 00000000..ad066605 --- /dev/null +++ b/test/fixtures/shared-methods/both-configs-set/server/model-config.json @@ -0,0 +1,46 @@ +{ + "_meta": { + "sources": [ + "loopback/common/models", + "loopback/server/models", + "../common/models", + "./models" + ], + "mixins": [ + "loopback/common/mixins", + "loopback/server/mixins", + "../common/mixins", + "./mixins" + ] + }, + "User": { + "dataSource": "db" + }, + "AccessToken": { + "dataSource": "db", + "public": false + }, + "ACL": { + "dataSource": "db", + "public": false + }, + "RoleMapping": { + "dataSource": "db", + "public": false + }, + "Role": { + "dataSource": "db", + "public": false + }, + "Todo": { + "dataSource": "db", + "public": true, + "options": { + "remoting": { + "sharedMethods": { + "destroyAll": false + } + } + } + } +} diff --git a/test/fixtures/shared-methods/both-configs-set/server/server.js b/test/fixtures/shared-methods/both-configs-set/server/server.js new file mode 100644 index 00000000..7876752e --- /dev/null +++ b/test/fixtures/shared-methods/both-configs-set/server/server.js @@ -0,0 +1,6 @@ +var boot = require('loopback-boot'); +var loopback = require('../../../../../index'); + +var app = module.exports = loopback(); +boot(app, __dirname); +app.use(loopback.rest()); diff --git a/test/fixtures/shared-methods/config-default-false/common/models/todo.js b/test/fixtures/shared-methods/config-default-false/common/models/todo.js new file mode 100644 index 00000000..43ab55fb --- /dev/null +++ b/test/fixtures/shared-methods/config-default-false/common/models/todo.js @@ -0,0 +1,3 @@ +module.exports = function(Todo) { + +}; diff --git a/test/fixtures/shared-methods/config-default-false/common/models/todo.json b/test/fixtures/shared-methods/config-default-false/common/models/todo.json new file mode 100644 index 00000000..356ba10d --- /dev/null +++ b/test/fixtures/shared-methods/config-default-false/common/models/todo.json @@ -0,0 +1,18 @@ +{ + "name": "Todo", + "base": "PersistedModel", + "idInjection": true, + "options": { + "validateUpsert": true + }, + "properties": { + "content": { + "type": "string", + "required": true + } + }, + "validations": [], + "relations": {}, + "acls": [], + "methods": {} +} diff --git a/test/fixtures/shared-methods/config-default-false/server/config.json b/test/fixtures/shared-methods/config-default-false/server/config.json new file mode 100644 index 00000000..4a919642 --- /dev/null +++ b/test/fixtures/shared-methods/config-default-false/server/config.json @@ -0,0 +1,31 @@ +{ + "restApiRoot": "/api", + "host": "0.0.0.0", + "port": 3000, + "remoting": { + "context": { + "enableHttpContext": false + }, + "rest": { + "normalizeHttpPath": false, + "xml": false + }, + "json": { + "strict": false, + "limit": "100kb" + }, + "urlencoded": { + "extended": true, + "limit": "100kb" + }, + "cors": false, + "errorHandler": { + "disableStackTrace": false + }, + "sharedMethods": { + "*": false + } + }, + "legacyExplorer": false +} + diff --git a/test/fixtures/shared-methods/config-default-false/server/datasources.json b/test/fixtures/shared-methods/config-default-false/server/datasources.json new file mode 100644 index 00000000..d6caf56d --- /dev/null +++ b/test/fixtures/shared-methods/config-default-false/server/datasources.json @@ -0,0 +1,6 @@ +{ + "db": { + "name": "db", + "connector": "memory" + } +} diff --git a/test/fixtures/shared-methods/config-default-false/server/model-config.json b/test/fixtures/shared-methods/config-default-false/server/model-config.json new file mode 100644 index 00000000..80233c50 --- /dev/null +++ b/test/fixtures/shared-methods/config-default-false/server/model-config.json @@ -0,0 +1,39 @@ +{ + "_meta": { + "sources": [ + "loopback/common/models", + "loopback/server/models", + "../common/models", + "./models" + ], + "mixins": [ + "loopback/common/mixins", + "loopback/server/mixins", + "../common/mixins", + "./mixins" + ] + }, + "User": { + "dataSource": "db" + }, + "AccessToken": { + "dataSource": "db", + "public": false + }, + "ACL": { + "dataSource": "db", + "public": false + }, + "RoleMapping": { + "dataSource": "db", + "public": false + }, + "Role": { + "dataSource": "db", + "public": false + }, + "Todo": { + "dataSource": "db", + "public": true + } +} diff --git a/test/fixtures/shared-methods/config-default-false/server/server.js b/test/fixtures/shared-methods/config-default-false/server/server.js new file mode 100644 index 00000000..7876752e --- /dev/null +++ b/test/fixtures/shared-methods/config-default-false/server/server.js @@ -0,0 +1,6 @@ +var boot = require('loopback-boot'); +var loopback = require('../../../../../index'); + +var app = module.exports = loopback(); +boot(app, __dirname); +app.use(loopback.rest()); diff --git a/test/fixtures/shared-methods/config-default-true/common/models/todo.js b/test/fixtures/shared-methods/config-default-true/common/models/todo.js new file mode 100644 index 00000000..43ab55fb --- /dev/null +++ b/test/fixtures/shared-methods/config-default-true/common/models/todo.js @@ -0,0 +1,3 @@ +module.exports = function(Todo) { + +}; diff --git a/test/fixtures/shared-methods/config-default-true/common/models/todo.json b/test/fixtures/shared-methods/config-default-true/common/models/todo.json new file mode 100644 index 00000000..356ba10d --- /dev/null +++ b/test/fixtures/shared-methods/config-default-true/common/models/todo.json @@ -0,0 +1,18 @@ +{ + "name": "Todo", + "base": "PersistedModel", + "idInjection": true, + "options": { + "validateUpsert": true + }, + "properties": { + "content": { + "type": "string", + "required": true + } + }, + "validations": [], + "relations": {}, + "acls": [], + "methods": {} +} diff --git a/test/fixtures/shared-methods/config-default-true/server/config.json b/test/fixtures/shared-methods/config-default-true/server/config.json new file mode 100644 index 00000000..15c6c80f --- /dev/null +++ b/test/fixtures/shared-methods/config-default-true/server/config.json @@ -0,0 +1,31 @@ +{ + "restApiRoot": "/api", + "host": "0.0.0.0", + "port": 3000, + "remoting": { + "context": { + "enableHttpContext": false + }, + "rest": { + "normalizeHttpPath": false, + "xml": false + }, + "json": { + "strict": false, + "limit": "100kb" + }, + "urlencoded": { + "extended": true, + "limit": "100kb" + }, + "cors": false, + "errorHandler": { + "disableStackTrace": false + }, + "sharedMethods": { + "*": true + } + }, + "legacyExplorer": false +} + diff --git a/test/fixtures/shared-methods/config-default-true/server/datasources.json b/test/fixtures/shared-methods/config-default-true/server/datasources.json new file mode 100644 index 00000000..d6caf56d --- /dev/null +++ b/test/fixtures/shared-methods/config-default-true/server/datasources.json @@ -0,0 +1,6 @@ +{ + "db": { + "name": "db", + "connector": "memory" + } +} diff --git a/test/fixtures/shared-methods/config-default-true/server/model-config.json b/test/fixtures/shared-methods/config-default-true/server/model-config.json new file mode 100644 index 00000000..80233c50 --- /dev/null +++ b/test/fixtures/shared-methods/config-default-true/server/model-config.json @@ -0,0 +1,39 @@ +{ + "_meta": { + "sources": [ + "loopback/common/models", + "loopback/server/models", + "../common/models", + "./models" + ], + "mixins": [ + "loopback/common/mixins", + "loopback/server/mixins", + "../common/mixins", + "./mixins" + ] + }, + "User": { + "dataSource": "db" + }, + "AccessToken": { + "dataSource": "db", + "public": false + }, + "ACL": { + "dataSource": "db", + "public": false + }, + "RoleMapping": { + "dataSource": "db", + "public": false + }, + "Role": { + "dataSource": "db", + "public": false + }, + "Todo": { + "dataSource": "db", + "public": true + } +} diff --git a/test/fixtures/shared-methods/config-default-true/server/server.js b/test/fixtures/shared-methods/config-default-true/server/server.js new file mode 100644 index 00000000..7876752e --- /dev/null +++ b/test/fixtures/shared-methods/config-default-true/server/server.js @@ -0,0 +1,6 @@ +var boot = require('loopback-boot'); +var loopback = require('../../../../../index'); + +var app = module.exports = loopback(); +boot(app, __dirname); +app.use(loopback.rest()); diff --git a/test/fixtures/shared-methods/config-defined-false/common/models/todo.js b/test/fixtures/shared-methods/config-defined-false/common/models/todo.js new file mode 100644 index 00000000..43ab55fb --- /dev/null +++ b/test/fixtures/shared-methods/config-defined-false/common/models/todo.js @@ -0,0 +1,3 @@ +module.exports = function(Todo) { + +}; diff --git a/test/fixtures/shared-methods/config-defined-false/common/models/todo.json b/test/fixtures/shared-methods/config-defined-false/common/models/todo.json new file mode 100644 index 00000000..356ba10d --- /dev/null +++ b/test/fixtures/shared-methods/config-defined-false/common/models/todo.json @@ -0,0 +1,18 @@ +{ + "name": "Todo", + "base": "PersistedModel", + "idInjection": true, + "options": { + "validateUpsert": true + }, + "properties": { + "content": { + "type": "string", + "required": true + } + }, + "validations": [], + "relations": {}, + "acls": [], + "methods": {} +} diff --git a/test/fixtures/shared-methods/config-defined-false/server/config.json b/test/fixtures/shared-methods/config-defined-false/server/config.json new file mode 100644 index 00000000..21ff03a3 --- /dev/null +++ b/test/fixtures/shared-methods/config-defined-false/server/config.json @@ -0,0 +1,31 @@ +{ + "restApiRoot": "/api", + "host": "0.0.0.0", + "port": 3000, + "remoting": { + "context": { + "enableHttpContext": false + }, + "rest": { + "normalizeHttpPath": false, + "xml": false + }, + "json": { + "strict": false, + "limit": "100kb" + }, + "urlencoded": { + "extended": true, + "limit": "100kb" + }, + "cors": false, + "errorHandler": { + "disableStackTrace": false + }, + "sharedMethods": { + "find": false + } + }, + "legacyExplorer": false +} + diff --git a/test/fixtures/shared-methods/config-defined-false/server/datasources.json b/test/fixtures/shared-methods/config-defined-false/server/datasources.json new file mode 100644 index 00000000..d6caf56d --- /dev/null +++ b/test/fixtures/shared-methods/config-defined-false/server/datasources.json @@ -0,0 +1,6 @@ +{ + "db": { + "name": "db", + "connector": "memory" + } +} diff --git a/test/fixtures/shared-methods/config-defined-false/server/model-config.json b/test/fixtures/shared-methods/config-defined-false/server/model-config.json new file mode 100644 index 00000000..80233c50 --- /dev/null +++ b/test/fixtures/shared-methods/config-defined-false/server/model-config.json @@ -0,0 +1,39 @@ +{ + "_meta": { + "sources": [ + "loopback/common/models", + "loopback/server/models", + "../common/models", + "./models" + ], + "mixins": [ + "loopback/common/mixins", + "loopback/server/mixins", + "../common/mixins", + "./mixins" + ] + }, + "User": { + "dataSource": "db" + }, + "AccessToken": { + "dataSource": "db", + "public": false + }, + "ACL": { + "dataSource": "db", + "public": false + }, + "RoleMapping": { + "dataSource": "db", + "public": false + }, + "Role": { + "dataSource": "db", + "public": false + }, + "Todo": { + "dataSource": "db", + "public": true + } +} diff --git a/test/fixtures/shared-methods/config-defined-false/server/server.js b/test/fixtures/shared-methods/config-defined-false/server/server.js new file mode 100644 index 00000000..7876752e --- /dev/null +++ b/test/fixtures/shared-methods/config-defined-false/server/server.js @@ -0,0 +1,6 @@ +var boot = require('loopback-boot'); +var loopback = require('../../../../../index'); + +var app = module.exports = loopback(); +boot(app, __dirname); +app.use(loopback.rest()); diff --git a/test/fixtures/shared-methods/config-defined-true/common/models/todo.js b/test/fixtures/shared-methods/config-defined-true/common/models/todo.js new file mode 100644 index 00000000..43ab55fb --- /dev/null +++ b/test/fixtures/shared-methods/config-defined-true/common/models/todo.js @@ -0,0 +1,3 @@ +module.exports = function(Todo) { + +}; diff --git a/test/fixtures/shared-methods/config-defined-true/common/models/todo.json b/test/fixtures/shared-methods/config-defined-true/common/models/todo.json new file mode 100644 index 00000000..356ba10d --- /dev/null +++ b/test/fixtures/shared-methods/config-defined-true/common/models/todo.json @@ -0,0 +1,18 @@ +{ + "name": "Todo", + "base": "PersistedModel", + "idInjection": true, + "options": { + "validateUpsert": true + }, + "properties": { + "content": { + "type": "string", + "required": true + } + }, + "validations": [], + "relations": {}, + "acls": [], + "methods": {} +} diff --git a/test/fixtures/shared-methods/config-defined-true/server/config.json b/test/fixtures/shared-methods/config-defined-true/server/config.json new file mode 100644 index 00000000..e59e3e58 --- /dev/null +++ b/test/fixtures/shared-methods/config-defined-true/server/config.json @@ -0,0 +1,31 @@ +{ + "restApiRoot": "/api", + "host": "0.0.0.0", + "port": 3000, + "remoting": { + "context": { + "enableHttpContext": false + }, + "rest": { + "normalizeHttpPath": false, + "xml": false + }, + "json": { + "strict": false, + "limit": "100kb" + }, + "urlencoded": { + "extended": true, + "limit": "100kb" + }, + "cors": false, + "errorHandler": { + "disableStackTrace": false + }, + "sharedMethods": { + "find": true + } + }, + "legacyExplorer": false +} + diff --git a/test/fixtures/shared-methods/config-defined-true/server/datasources.json b/test/fixtures/shared-methods/config-defined-true/server/datasources.json new file mode 100644 index 00000000..d6caf56d --- /dev/null +++ b/test/fixtures/shared-methods/config-defined-true/server/datasources.json @@ -0,0 +1,6 @@ +{ + "db": { + "name": "db", + "connector": "memory" + } +} diff --git a/test/fixtures/shared-methods/config-defined-true/server/model-config.json b/test/fixtures/shared-methods/config-defined-true/server/model-config.json new file mode 100644 index 00000000..80233c50 --- /dev/null +++ b/test/fixtures/shared-methods/config-defined-true/server/model-config.json @@ -0,0 +1,39 @@ +{ + "_meta": { + "sources": [ + "loopback/common/models", + "loopback/server/models", + "../common/models", + "./models" + ], + "mixins": [ + "loopback/common/mixins", + "loopback/server/mixins", + "../common/mixins", + "./mixins" + ] + }, + "User": { + "dataSource": "db" + }, + "AccessToken": { + "dataSource": "db", + "public": false + }, + "ACL": { + "dataSource": "db", + "public": false + }, + "RoleMapping": { + "dataSource": "db", + "public": false + }, + "Role": { + "dataSource": "db", + "public": false + }, + "Todo": { + "dataSource": "db", + "public": true + } +} diff --git a/test/fixtures/shared-methods/config-defined-true/server/server.js b/test/fixtures/shared-methods/config-defined-true/server/server.js new file mode 100644 index 00000000..7876752e --- /dev/null +++ b/test/fixtures/shared-methods/config-defined-true/server/server.js @@ -0,0 +1,6 @@ +var boot = require('loopback-boot'); +var loopback = require('../../../../../index'); + +var app = module.exports = loopback(); +boot(app, __dirname); +app.use(loopback.rest()); diff --git a/test/fixtures/shared-methods/model-config-default-false/common/models/todo.js b/test/fixtures/shared-methods/model-config-default-false/common/models/todo.js new file mode 100644 index 00000000..43ab55fb --- /dev/null +++ b/test/fixtures/shared-methods/model-config-default-false/common/models/todo.js @@ -0,0 +1,3 @@ +module.exports = function(Todo) { + +}; diff --git a/test/fixtures/shared-methods/model-config-default-false/common/models/todo.json b/test/fixtures/shared-methods/model-config-default-false/common/models/todo.json new file mode 100644 index 00000000..356ba10d --- /dev/null +++ b/test/fixtures/shared-methods/model-config-default-false/common/models/todo.json @@ -0,0 +1,18 @@ +{ + "name": "Todo", + "base": "PersistedModel", + "idInjection": true, + "options": { + "validateUpsert": true + }, + "properties": { + "content": { + "type": "string", + "required": true + } + }, + "validations": [], + "relations": {}, + "acls": [], + "methods": {} +} diff --git a/test/fixtures/shared-methods/model-config-default-false/server/config.json b/test/fixtures/shared-methods/model-config-default-false/server/config.json new file mode 100644 index 00000000..61ed16d6 --- /dev/null +++ b/test/fixtures/shared-methods/model-config-default-false/server/config.json @@ -0,0 +1,28 @@ +{ + "restApiRoot": "/api", + "host": "0.0.0.0", + "port": 3000, + "remoting": { + "context": { + "enableHttpContext": false + }, + "rest": { + "normalizeHttpPath": false, + "xml": false + }, + "json": { + "strict": false, + "limit": "100kb" + }, + "urlencoded": { + "extended": true, + "limit": "100kb" + }, + "cors": false, + "errorHandler": { + "disableStackTrace": false + } + }, + "legacyExplorer": false +} + diff --git a/test/fixtures/shared-methods/model-config-default-false/server/datasources.json b/test/fixtures/shared-methods/model-config-default-false/server/datasources.json new file mode 100644 index 00000000..d6caf56d --- /dev/null +++ b/test/fixtures/shared-methods/model-config-default-false/server/datasources.json @@ -0,0 +1,6 @@ +{ + "db": { + "name": "db", + "connector": "memory" + } +} diff --git a/test/fixtures/shared-methods/model-config-default-false/server/model-config.json b/test/fixtures/shared-methods/model-config-default-false/server/model-config.json new file mode 100644 index 00000000..3a4c07cd --- /dev/null +++ b/test/fixtures/shared-methods/model-config-default-false/server/model-config.json @@ -0,0 +1,46 @@ +{ + "_meta": { + "sources": [ + "loopback/common/models", + "loopback/server/models", + "../common/models", + "./models" + ], + "mixins": [ + "loopback/common/mixins", + "loopback/server/mixins", + "../common/mixins", + "./mixins" + ] + }, + "User": { + "dataSource": "db" + }, + "AccessToken": { + "dataSource": "db", + "public": false + }, + "ACL": { + "dataSource": "db", + "public": false + }, + "RoleMapping": { + "dataSource": "db", + "public": false + }, + "Role": { + "dataSource": "db", + "public": false + }, + "Todo": { + "dataSource": "db", + "public": true, + "options": { + "remoting": { + "sharedMethods": { + "*": false + } + } + } + } +} diff --git a/test/fixtures/shared-methods/model-config-default-false/server/server.js b/test/fixtures/shared-methods/model-config-default-false/server/server.js new file mode 100644 index 00000000..7876752e --- /dev/null +++ b/test/fixtures/shared-methods/model-config-default-false/server/server.js @@ -0,0 +1,6 @@ +var boot = require('loopback-boot'); +var loopback = require('../../../../../index'); + +var app = module.exports = loopback(); +boot(app, __dirname); +app.use(loopback.rest()); diff --git a/test/fixtures/shared-methods/model-config-default-true/common/models/todo.js b/test/fixtures/shared-methods/model-config-default-true/common/models/todo.js new file mode 100644 index 00000000..43ab55fb --- /dev/null +++ b/test/fixtures/shared-methods/model-config-default-true/common/models/todo.js @@ -0,0 +1,3 @@ +module.exports = function(Todo) { + +}; diff --git a/test/fixtures/shared-methods/model-config-default-true/common/models/todo.json b/test/fixtures/shared-methods/model-config-default-true/common/models/todo.json new file mode 100644 index 00000000..356ba10d --- /dev/null +++ b/test/fixtures/shared-methods/model-config-default-true/common/models/todo.json @@ -0,0 +1,18 @@ +{ + "name": "Todo", + "base": "PersistedModel", + "idInjection": true, + "options": { + "validateUpsert": true + }, + "properties": { + "content": { + "type": "string", + "required": true + } + }, + "validations": [], + "relations": {}, + "acls": [], + "methods": {} +} diff --git a/test/fixtures/shared-methods/model-config-default-true/server/config.json b/test/fixtures/shared-methods/model-config-default-true/server/config.json new file mode 100644 index 00000000..61ed16d6 --- /dev/null +++ b/test/fixtures/shared-methods/model-config-default-true/server/config.json @@ -0,0 +1,28 @@ +{ + "restApiRoot": "/api", + "host": "0.0.0.0", + "port": 3000, + "remoting": { + "context": { + "enableHttpContext": false + }, + "rest": { + "normalizeHttpPath": false, + "xml": false + }, + "json": { + "strict": false, + "limit": "100kb" + }, + "urlencoded": { + "extended": true, + "limit": "100kb" + }, + "cors": false, + "errorHandler": { + "disableStackTrace": false + } + }, + "legacyExplorer": false +} + diff --git a/test/fixtures/shared-methods/model-config-default-true/server/datasources.json b/test/fixtures/shared-methods/model-config-default-true/server/datasources.json new file mode 100644 index 00000000..d6caf56d --- /dev/null +++ b/test/fixtures/shared-methods/model-config-default-true/server/datasources.json @@ -0,0 +1,6 @@ +{ + "db": { + "name": "db", + "connector": "memory" + } +} diff --git a/test/fixtures/shared-methods/model-config-default-true/server/model-config.json b/test/fixtures/shared-methods/model-config-default-true/server/model-config.json new file mode 100644 index 00000000..d1934701 --- /dev/null +++ b/test/fixtures/shared-methods/model-config-default-true/server/model-config.json @@ -0,0 +1,46 @@ +{ + "_meta": { + "sources": [ + "loopback/common/models", + "loopback/server/models", + "../common/models", + "./models" + ], + "mixins": [ + "loopback/common/mixins", + "loopback/server/mixins", + "../common/mixins", + "./mixins" + ] + }, + "User": { + "dataSource": "db" + }, + "AccessToken": { + "dataSource": "db", + "public": false + }, + "ACL": { + "dataSource": "db", + "public": false + }, + "RoleMapping": { + "dataSource": "db", + "public": false + }, + "Role": { + "dataSource": "db", + "public": false + }, + "Todo": { + "dataSource": "db", + "public": true, + "options": { + "remoting": { + "sharedMethods": { + "*": true + } + } + } + } +} diff --git a/test/fixtures/shared-methods/model-config-default-true/server/server.js b/test/fixtures/shared-methods/model-config-default-true/server/server.js new file mode 100644 index 00000000..7876752e --- /dev/null +++ b/test/fixtures/shared-methods/model-config-default-true/server/server.js @@ -0,0 +1,6 @@ +var boot = require('loopback-boot'); +var loopback = require('../../../../../index'); + +var app = module.exports = loopback(); +boot(app, __dirname); +app.use(loopback.rest()); diff --git a/test/fixtures/shared-methods/model-config-defined-false/common/models/todo.js b/test/fixtures/shared-methods/model-config-defined-false/common/models/todo.js new file mode 100644 index 00000000..43ab55fb --- /dev/null +++ b/test/fixtures/shared-methods/model-config-defined-false/common/models/todo.js @@ -0,0 +1,3 @@ +module.exports = function(Todo) { + +}; diff --git a/test/fixtures/shared-methods/model-config-defined-false/common/models/todo.json b/test/fixtures/shared-methods/model-config-defined-false/common/models/todo.json new file mode 100644 index 00000000..356ba10d --- /dev/null +++ b/test/fixtures/shared-methods/model-config-defined-false/common/models/todo.json @@ -0,0 +1,18 @@ +{ + "name": "Todo", + "base": "PersistedModel", + "idInjection": true, + "options": { + "validateUpsert": true + }, + "properties": { + "content": { + "type": "string", + "required": true + } + }, + "validations": [], + "relations": {}, + "acls": [], + "methods": {} +} diff --git a/test/fixtures/shared-methods/model-config-defined-false/server/config.json b/test/fixtures/shared-methods/model-config-defined-false/server/config.json new file mode 100644 index 00000000..61ed16d6 --- /dev/null +++ b/test/fixtures/shared-methods/model-config-defined-false/server/config.json @@ -0,0 +1,28 @@ +{ + "restApiRoot": "/api", + "host": "0.0.0.0", + "port": 3000, + "remoting": { + "context": { + "enableHttpContext": false + }, + "rest": { + "normalizeHttpPath": false, + "xml": false + }, + "json": { + "strict": false, + "limit": "100kb" + }, + "urlencoded": { + "extended": true, + "limit": "100kb" + }, + "cors": false, + "errorHandler": { + "disableStackTrace": false + } + }, + "legacyExplorer": false +} + diff --git a/test/fixtures/shared-methods/model-config-defined-false/server/datasources.json b/test/fixtures/shared-methods/model-config-defined-false/server/datasources.json new file mode 100644 index 00000000..d6caf56d --- /dev/null +++ b/test/fixtures/shared-methods/model-config-defined-false/server/datasources.json @@ -0,0 +1,6 @@ +{ + "db": { + "name": "db", + "connector": "memory" + } +} diff --git a/test/fixtures/shared-methods/model-config-defined-false/server/model-config.json b/test/fixtures/shared-methods/model-config-defined-false/server/model-config.json new file mode 100644 index 00000000..4f01d722 --- /dev/null +++ b/test/fixtures/shared-methods/model-config-defined-false/server/model-config.json @@ -0,0 +1,46 @@ +{ + "_meta": { + "sources": [ + "loopback/common/models", + "loopback/server/models", + "../common/models", + "./models" + ], + "mixins": [ + "loopback/common/mixins", + "loopback/server/mixins", + "../common/mixins", + "./mixins" + ] + }, + "User": { + "dataSource": "db" + }, + "AccessToken": { + "dataSource": "db", + "public": false + }, + "ACL": { + "dataSource": "db", + "public": false + }, + "RoleMapping": { + "dataSource": "db", + "public": false + }, + "Role": { + "dataSource": "db", + "public": false + }, + "Todo": { + "dataSource": "db", + "public": true, + "options": { + "remoting": { + "sharedMethods": { + "find": false + } + } + } + } +} diff --git a/test/fixtures/shared-methods/model-config-defined-false/server/server.js b/test/fixtures/shared-methods/model-config-defined-false/server/server.js new file mode 100644 index 00000000..7876752e --- /dev/null +++ b/test/fixtures/shared-methods/model-config-defined-false/server/server.js @@ -0,0 +1,6 @@ +var boot = require('loopback-boot'); +var loopback = require('../../../../../index'); + +var app = module.exports = loopback(); +boot(app, __dirname); +app.use(loopback.rest()); diff --git a/test/fixtures/shared-methods/model-config-defined-true/common/models/todo.js b/test/fixtures/shared-methods/model-config-defined-true/common/models/todo.js new file mode 100644 index 00000000..43ab55fb --- /dev/null +++ b/test/fixtures/shared-methods/model-config-defined-true/common/models/todo.js @@ -0,0 +1,3 @@ +module.exports = function(Todo) { + +}; diff --git a/test/fixtures/shared-methods/model-config-defined-true/common/models/todo.json b/test/fixtures/shared-methods/model-config-defined-true/common/models/todo.json new file mode 100644 index 00000000..356ba10d --- /dev/null +++ b/test/fixtures/shared-methods/model-config-defined-true/common/models/todo.json @@ -0,0 +1,18 @@ +{ + "name": "Todo", + "base": "PersistedModel", + "idInjection": true, + "options": { + "validateUpsert": true + }, + "properties": { + "content": { + "type": "string", + "required": true + } + }, + "validations": [], + "relations": {}, + "acls": [], + "methods": {} +} diff --git a/test/fixtures/shared-methods/model-config-defined-true/server/config.json b/test/fixtures/shared-methods/model-config-defined-true/server/config.json new file mode 100644 index 00000000..61ed16d6 --- /dev/null +++ b/test/fixtures/shared-methods/model-config-defined-true/server/config.json @@ -0,0 +1,28 @@ +{ + "restApiRoot": "/api", + "host": "0.0.0.0", + "port": 3000, + "remoting": { + "context": { + "enableHttpContext": false + }, + "rest": { + "normalizeHttpPath": false, + "xml": false + }, + "json": { + "strict": false, + "limit": "100kb" + }, + "urlencoded": { + "extended": true, + "limit": "100kb" + }, + "cors": false, + "errorHandler": { + "disableStackTrace": false + } + }, + "legacyExplorer": false +} + diff --git a/test/fixtures/shared-methods/model-config-defined-true/server/datasources.json b/test/fixtures/shared-methods/model-config-defined-true/server/datasources.json new file mode 100644 index 00000000..d6caf56d --- /dev/null +++ b/test/fixtures/shared-methods/model-config-defined-true/server/datasources.json @@ -0,0 +1,6 @@ +{ + "db": { + "name": "db", + "connector": "memory" + } +} diff --git a/test/fixtures/shared-methods/model-config-defined-true/server/model-config.json b/test/fixtures/shared-methods/model-config-defined-true/server/model-config.json new file mode 100644 index 00000000..f5cf5b93 --- /dev/null +++ b/test/fixtures/shared-methods/model-config-defined-true/server/model-config.json @@ -0,0 +1,46 @@ +{ + "_meta": { + "sources": [ + "loopback/common/models", + "loopback/server/models", + "../common/models", + "./models" + ], + "mixins": [ + "loopback/common/mixins", + "loopback/server/mixins", + "../common/mixins", + "./mixins" + ] + }, + "User": { + "dataSource": "db" + }, + "AccessToken": { + "dataSource": "db", + "public": false + }, + "ACL": { + "dataSource": "db", + "public": false + }, + "RoleMapping": { + "dataSource": "db", + "public": false + }, + "Role": { + "dataSource": "db", + "public": false + }, + "Todo": { + "dataSource": "db", + "public": true, + "options": { + "remoting": { + "sharedMethods": { + "find": true + } + } + } + } +} diff --git a/test/fixtures/shared-methods/model-config-defined-true/server/server.js b/test/fixtures/shared-methods/model-config-defined-true/server/server.js new file mode 100644 index 00000000..7876752e --- /dev/null +++ b/test/fixtures/shared-methods/model-config-defined-true/server/server.js @@ -0,0 +1,6 @@ +var boot = require('loopback-boot'); +var loopback = require('../../../../../index'); + +var app = module.exports = loopback(); +boot(app, __dirname); +app.use(loopback.rest()); From 26af1472e75f98269fb5c10b31d39320958a8930 Mon Sep 17 00:00:00 2001 From: Simon Ho Date: Fri, 18 Sep 2015 19:13:30 -0700 Subject: [PATCH 2/2] Check configs for shared method settings --- lib/application.js | 46 ++++++++++++ lib/persisted-model.js | 15 +++- package.json | 2 +- test/remoting.integration.js | 9 +-- test/rest.middleware.test.js | 136 +++++++++++++++++++++++++++++++++++ test/user.integration.js | 8 +-- 6 files changed, 204 insertions(+), 12 deletions(-) diff --git a/lib/application.js b/lib/application.js index 062394d0..1952156e 100644 --- a/lib/application.js +++ b/lib/application.js @@ -11,6 +11,7 @@ var RemoteObjects = require('strong-remoting'); var classify = require('underscore.string/classify'); var camelize = require('underscore.string/camelize'); var path = require('path'); +var util = require('util'); /** * The `App` object represents a Loopback application. @@ -435,9 +436,54 @@ function configureModel(ModelCtor, config, app) { config = extend({}, config); config.dataSource = dataSource; + setSharedMethodSharedProperties(ModelCtor, app, config); + app.registry.configureModel(ModelCtor, config); } +function setSharedMethodSharedProperties(model, app, modelConfigs) { + var settings = {}; + + // apply config.json settings + var config = app.get('remoting'); + var configHasSharedMethodsSettings = config && + config.sharedMethods && + typeof config.sharedMethods === 'object'; + if (configHasSharedMethodsSettings) + util._extend(settings, config.sharedMethods); + + // apply model-config.json settings + var modelConfig = modelConfigs.options; + var modelConfigHasSharedMethodsSettings = modelConfig && + modelConfig.remoting && + modelConfig.remoting.sharedMethods && + typeof modelConfig.remoting.sharedMethods === 'object'; + if (modelConfigHasSharedMethodsSettings) + util._extend(settings, modelConfig.remoting.sharedMethods); + + // validate setting values + Object.keys(settings).forEach(function(setting) { + var settingValue = settings[setting]; + var settingValueType = typeof settingValue; + if (settingValueType !== 'boolean') + throw new TypeError('Expected boolean, got ' + settingValueType); + }); + + // set sharedMethod.shared using the merged settings + var sharedMethods = model.sharedClass.methods({includeDisabled: true}); + sharedMethods.forEach(function(sharedMethod) { + // use the specific setting if it exists + var hasSpecificSetting = settings.hasOwnProperty(sharedMethod.name); + if (hasSpecificSetting) { + sharedMethod.shared = settings[sharedMethod.name]; + } else { // otherwise, use the default setting if it exists + var hasDefaultSetting = settings.hasOwnProperty('*'); + if (hasDefaultSetting) + sharedMethod.shared = settings['*']; + } + }); +} + function clearHandlerCache(app) { app._handlers = undefined; } diff --git a/lib/persisted-model.js b/lib/persisted-model.js index ebf057d0..c33e7583 100644 --- a/lib/persisted-model.js +++ b/lib/persisted-model.js @@ -618,6 +618,12 @@ module.exports = function(registry) { description: 'Delete all matching records.', accessType: 'WRITE', accepts: {arg: 'where', type: 'object', description: 'filter.where object'}, + returns: { + arg: 'count', + type: 'object', + description: 'The number of instances deleted', + root: true + }, http: {verb: 'del', path: '/'}, shared: false }); @@ -632,6 +638,12 @@ module.exports = function(registry) { {arg: 'data', type: 'object', http: {source: 'body'}, description: 'An object of model property name/value pairs'}, ], + returns: { + arg: 'count', + description: 'The number of instances updated', + type: 'object', + root: true + }, http: {verb: 'post', path: '/update'} }); @@ -641,7 +653,8 @@ module.exports = function(registry) { accessType: 'WRITE', accepts: {arg: 'id', type: 'any', description: 'Model id', required: true, http: {source: 'path'}}, - http: {verb: 'del', path: '/:id'} + http: {verb: 'del', path: '/:id'}, + returns: {arg: 'count', type: 'object', root: true} }); setRemoting(PersistedModel, 'count', { diff --git a/package.json b/package.json index d78877dd..5c68e13c 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "nodemailer-stub-transport": "^0.1.5", "serve-favicon": "^2.2.0", "stable": "^0.1.5", - "strong-remoting": "^2.15.0", + "strong-remoting": "^2.21.0", "uid2": "0.0.3", "underscore.string": "^3.0.3" }, diff --git a/test/remoting.integration.js b/test/remoting.integration.js index a5bc6389..c3288d79 100644 --- a/test/remoting.integration.js +++ b/test/remoting.integration.js @@ -117,14 +117,15 @@ describe('remoting - integration', function() { 'findById(id:any,filter:object):store GET /stores/:id', 'find(filter:object):store GET /stores', 'findOne(filter:object):store GET /stores/findOne', - 'updateAll(where:object,data:object) POST /stores/update', - 'deleteById(id:any) DELETE /stores/:id', + 'updateAll(where:object,data:object):object POST /stores/update', + 'deleteById(id:any):object DELETE /stores/:id', 'count(where:object):number GET /stores/count', - 'prototype.updateAttributes(data:object):store PUT /stores/:id' + 'prototype.updateAttributes(data:object):store PUT /stores/:id', + 'createChangeStream(options:object):ReadableStream POST /stores/change-stream' ]; // The list of methods is from docs: - // http://docs.strongloop.com/display/LB/Exposing+models+over+a+REST+API + // https://docs.strongloop.com/display/public/LB/Exposing+models+over+REST expect(methods).to.include.members(expectedMethods); }); diff --git a/test/rest.middleware.test.js b/test/rest.middleware.test.js index 8168a491..5757c44b 100644 --- a/test/rest.middleware.test.js +++ b/test/rest.middleware.test.js @@ -1,3 +1,5 @@ +var path = require('path'); + describe('loopback.rest', function() { var MyModel; beforeEach(function() { @@ -14,6 +16,20 @@ describe('loopback.rest', function() { .end(done); }); + it('should report 200 for DELETE /:id found', function(done) { + app.set('legacyExplorer', false); + app.model(MyModel); + app.use(loopback.rest()); + MyModel.create({name: 'm1'}, function(err, inst) { + request(app) + .del('/mymodels/' + inst.id) + .expect(200, function(err, res) { + expect(res.body.count).to.equal(1); + done(); + }); + }); + }); + it('should report 404 for GET /:id not found', function(done) { app.model(MyModel); app.use(loopback.rest()); @@ -337,4 +353,124 @@ describe('loopback.rest', function() { User.login(credentials, cb); }); } + + describe('shared methods', function() { + function getFixturePath(dirName) { + return path.join(__dirname, 'fixtures/shared-methods/' + dirName + + '/server/server.js'); + } + + describe('with specific definitions in model-config.json', function() { + it('should not be exposed when the definition value is false', + function(done) { + var app = require(getFixturePath('model-config-defined-false')); + request(app) + .get('/todos') + .expect(404, done); + }); + + it('should be exposed when the definition value is true', function(done) { + var app = require(getFixturePath('model-config-defined-true')); + request(app) + .get('/todos') + .expect(200, done); + }); + }); + + describe('with default definitions in model-config.json', function() { + it('should not be exposed when the definition value is false', + function(done) { + var app = require(getFixturePath('model-config-default-false')); + request(app) + .get('/todos') + .expect(404, done); + }); + + it('should be exposed when the definition value is true', function(done) { + var app = require(getFixturePath('model-config-default-true')); + app.models.Todo.create([ + {content: 'a'}, + {content: 'b'}, + {content: 'c'} + ], function() { + request(app) + .del('/todos') + .expect(200) + .end(function(err, res) { + if (err) return done(err); + expect(res.body.count).to.equal(3); + done(); + }); + }); + }); + }); + + describe('with specific definitions in config.json', function() { + it('should not be exposed when the definition value is false', + function(done) { + var app = require(getFixturePath('config-defined-false')); + request(app) + .get('/todos') + .expect(404, done); + }); + + it('should be exposed when the definition value is true', + function(done) { + var app = require(getFixturePath('config-defined-true')); + request(app) + .get('/todos') + .expect(200, done); + }); + }); + + describe('with default definitions in config.json', function() { + it('should not be exposed when the definition value is false', + function(done) { + var app = require(getFixturePath('config-default-false')); + request(app) + .get('/todos') + .expect(404, done); + }); + + it('should be exposed when the definition value is true', function(done) { + var app = require(getFixturePath('config-default-true')); + app.models.Todo.create([ + {content: 'a'}, + {content: 'b'}, + {content: 'c'} + ], function() { + request(app) + .del('/todos') + .expect(200) + .end(function(err, res) { + if (err) return done(err); + expect(res.body.count).to.equal(3); + done(); + }); + }); + }); + }); + + // The fixture in `shared-method/both-configs-set/config.json` has `*:false` + // set which disables the REST endpoints for built-in models such as User as + // a side effect since tests share the same loopback instance. As a + // consequence, this causes the tests in user.integration to fail. + describe.skip('with definitions in both config.json and model-config.json', + function() { + it('should prioritize the settings in model-config.json', function(done) { + var app = require(getFixturePath('both-configs-set')); + request(app) + .del('/todos') + .expect(404, done); + }); + + it('should fall back to config.json settings if setting is not found in' + + 'model-config.json', function(done) { + var app = require(getFixturePath('both-configs-set')); + request(app) + .get('/todos') + .expect(404, done); + }); + }); + }); }); diff --git a/test/user.integration.js b/test/user.integration.js index 14dfe2ef..b2a92537 100644 --- a/test/user.integration.js +++ b/test/user.integration.js @@ -34,14 +34,10 @@ describe('users - integration', function() { var accessToken; it('should create a new user', function(done) { - var url = '/api/users'; - - this.post(url) + this.post('/api/users') .send({username: 'x', email: 'x@y.com', password: 'x'}) .expect(200, function(err, res) { - if (err) { - return done(err); - } + if (err) return done(err); expect(res.body.id).to.exist; userId = res.body.id; done();