Permalink
Browse files

fix(entity): do not delete id from request body in update calls

Previous functionality unnecessarily limited common alternative API conventions.

BREAKING CHANGE: id properties are now included in the request body of update calls. Fixes #185.
  • Loading branch information...
Josh Dovishaw
Josh Dovishaw committed Feb 7, 2017
1 parent a813afc commit cfd6cf67a21f72494a40d92a32c5025b4a594e02
Showing with 4 additions and 5 deletions.
  1. +0 −2 src/entity.js
  2. +4 −3 test/entity.spec.js
@@ -172,8 +172,6 @@ export class Entity {
let requestBody = this.asObject(true);
let response;
delete requestBody[this.getIdProperty()];
return this.getTransport()
.update(this.getResource(), this.getId(), requestBody)
.then(updated => { response = updated; })
@@ -189,7 +189,7 @@ describe('Entity', function() {
entity.idTag = 1337;
entity.save().then(response => {
expect(response.body).toEqual({foo: 'bar'});
expect(response.body).toEqual({idTag: 1337, foo: 'bar'});
expect(response.path).toEqual('/with-resource/1337');
expect(response.method).toEqual('PUT');
@@ -251,7 +251,7 @@ describe('Entity', function() {
entity.id = 1991;
entity.save().then(response => {
expect(response.body).toEqual({bacon: 'great!'});
expect(response.body).toEqual({id: 1991, bacon: 'great!'});
expect(response.path).toEqual('/default-entity/1991');
expect(response.method).toEqual('PUT');
@@ -416,7 +416,7 @@ describe('Entity', function() {
entity.city = {awesome: true};
entity.update().then(response => {
expect(response.body).toEqual({foo: 'bar', city: {awesome: true}});
expect(response.body).toEqual({idTag: 666, foo: 'bar', city: {awesome: true}});
expect(response.path).toEqual('/with-resource/666');
expect(response.method).toEqual('PUT');
@@ -474,6 +474,7 @@ describe('Entity', function() {
expect(response.path).toEqual('/withassociations/1');
expect(response.method).toEqual('PUT');
expect(response.body).toEqual({
id: 1,
bar: {
baby: 'steps'
},

0 comments on commit cfd6cf6

Please sign in to comment.