Skip to content

Commit b80666a

Browse files
committed
Reorder PATCH Vs PUT endpoints
*Reorder PATCH Vs PUT endpoints for update* methods
1 parent 98eed72 commit b80666a

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lib/persisted-model.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ module.exports = function(registry) {
635635
};
636636

637637
if (!options.replaceOnPUT) {
638-
upsertOptions.http.push({ verb: 'put', path: '/' });
638+
upsertOptions.http.unshift({ verb: 'put', path: '/' });
639639
}
640640
setRemoting(PersistedModel, 'patchOrCreate', upsertOptions);
641641

@@ -802,7 +802,7 @@ module.exports = function(registry) {
802802
setRemoting(PersistedModel.prototype, 'patchAttributes', updateAttributesOptions);
803803

804804
if (!options.replaceOnPUT) {
805-
updateAttributesOptions.http.push({ verb: 'put', path: '/' });
805+
updateAttributesOptions.http.unshift({ verb: 'put', path: '/' });
806806
}
807807

808808
if (options.trackChanges || options.enableRemoteReplication) {

test/remoting.integration.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,26 @@ describe('With model.settings.replaceOnPUT false', function() {
198198
var methods = getFormattedMethodsExcludingRelations(storeClass.methods);
199199

200200
var expectedMethods = [
201-
'patchOrCreate(data:object):storeWithReplaceOnPUTfalse PATCH /stores-updating',
201+
'create(data:object):storeWithReplaceOnPUTfalse POST /stores-updating',
202202
'patchOrCreate(data:object):storeWithReplaceOnPUTfalse PUT /stores-updating',
203+
'patchOrCreate(data:object):storeWithReplaceOnPUTfalse PATCH /stores-updating',
203204
'replaceOrCreate(data:object):storeWithReplaceOnPUTfalse POST /stores-updating/replaceOrCreate',
205+
'exists(id:any):boolean GET /stores-updating/:id/exists',
206+
'exists(id:any):boolean HEAD /stores-updating/:id',
207+
'findById(id:any,filter:object):storeWithReplaceOnPUTfalse GET /stores-updating/:id',
204208
'replaceById(id:any,data:object):storeWithReplaceOnPUTfalse POST /stores-updating/:id/replace',
205-
'prototype.patchAttributes(data:object):storeWithReplaceOnPUTfalse PATCH /stores-updating/:id',
209+
'find(filter:object):storeWithReplaceOnPUTfalse GET /stores-updating',
210+
'findOne(filter:object):storeWithReplaceOnPUTfalse GET /stores-updating/findOne',
211+
'updateAll(where:object,data:object):object POST /stores-updating/update',
212+
'deleteById(id:any):object DELETE /stores-updating/:id',
213+
'count(where:object):number GET /stores-updating/count',
206214
'prototype.patchAttributes(data:object):storeWithReplaceOnPUTfalse PUT /stores-updating/:id',
215+
'prototype.patchAttributes(data:object):storeWithReplaceOnPUTfalse PATCH /stores-updating/:id',
216+
'createChangeStream(options:object):ReadableStream POST /stores-updating/change-stream',
217+
'createChangeStream(options:object):ReadableStream GET /stores-updating/change-stream',
207218
];
208219

209-
expect(methods).to.include.members(expectedMethods);
220+
expect(methods).to.eql(expectedMethods);
210221
});
211222
});
212223

0 commit comments

Comments
 (0)