diff --git a/test/access-control.integration.js b/test/access-control.integration.js index b3215257..bbc5a192 100644 --- a/test/access-control.integration.js +++ b/test/access-control.integration.js @@ -122,6 +122,11 @@ describe('access control - integration', function() { }); }); lt.describe.whenCalledRemotely('PUT', '/api/users/:id', function() { + beforeEach(function(done) { + app.models.user.settings.replaceOnPUT = false; + app.models.user.setup(); + done(); + }); lt.it.shouldBeAllowed(); }); }); @@ -208,7 +213,8 @@ describe('access control - integration', function() { lt.describe.whenLoggedInAsUser(CURRENT_USER, function() { beforeEach(function(done) { var self = this; - + app.models.account.settings.replaceOnPUT = true; + app.models.account.setup(); // Create an account under the given user app.models.account.create({ userId: self.user.id, @@ -220,6 +226,10 @@ describe('access control - integration', function() { }); }); + // + // TODO: How to check Model.settings.options.replaceOnPUT + // to decide whether the following test should be for + // (POST for replace and (PATCH AND PUT) for update) OR (PUT for replace and PATCH for update) lt.describe.whenCalledRemotely('PUT', '/api/accounts/:id', function() { lt.it.shouldBeAllowed(); }); diff --git a/test/remoting.integration.js b/test/remoting.integration.js index 3dd6cbff..9e41b6e1 100644 --- a/test/remoting.integration.js +++ b/test/remoting.integration.js @@ -113,7 +113,7 @@ describe('remoting - integration', function() { })[0]; } - it('has expected remote methods', function() { + it('has expected remote methods without model.settings.replaceOnPUT', function() { var storeClass = findClass('store'); var methods = storeClass.methods .filter(function(m) { @@ -145,6 +145,42 @@ describe('remoting - integration', function() { expect(methods).to.include.members(expectedMethods); }); + // TODO: apparently the way I set up model settings is not right? + it.skip('has expected remote methods with model.settings.replaceOnPUT', function() { + app.models.store.settings.replaceOnPUT = true; + app.models.store.setup(); + var storeClass = findClass('store'); + var methods = storeClass.methods + .filter(function(m) { + return m.name.indexOf('__') === -1; + }) + .map(function(m) { + return formatMethod(m); + }); + + var expectedMethods = [ + 'create(data:object):store POST /stores', + 'upsert(data:object):store PUT /stores', + 'upsert(data:object):store PATCH /stores', + 'replaceOrCreate(data:object):store PUT /stores', + 'exists(id:any):boolean GET /stores/:id/exists', + 'findById(id:any,filter:object):store GET /stores/:id', + 'replaceById(id:any,data:object):store PUT /stores/:id', + 'find(filter:object):store GET /stores', + 'findOne(filter:object):store GET /stores/findOne', + '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 PATCH /stores/:id', + 'createChangeStream(options:object):ReadableStream POST /stores/change-stream', + ]; + + // TODO: update the doc for list of methods accordingly + // https://docs.strongloop.com/display/public/LB/Exposing+models+over+REST + expect(methods).to.include.members(expectedMethods); + }); + it('has expected remote methods for scopes', function() { var storeClass = findClass('store'); var methods = storeClass.methods