Skip to content

Commit 40e0aa6

Browse files
committed
Merge pull request eneuhauser#6 from andrewbranch/master
Replace PUT verb with PATCH
2 parents e14e460 + 089c512 commit 40e0aa6

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

dist/ember-json-api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ define("json-api-adapter",
122122
var data = this._serializeData(store, type, snapshot);
123123
var id = get(snapshot, 'id');
124124

125-
return this.ajax(this.buildURL(type.typeKey, id, snapshot), 'PUT', {
125+
return this.ajax(this.buildURL(type.typeKey, id, snapshot), 'PATCH', {
126126
data: data
127127
});
128128
},

dist/ember-json-api.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/json-api-adapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ DS.JsonApiAdapter = DS.RESTAdapter.extend({
118118
var data = this._serializeData(store, type, snapshot);
119119
var id = get(snapshot, 'id');
120120

121-
return this.ajax(this.buildURL(type.typeKey, id, snapshot), 'PUT', {
121+
return this.ajax(this.buildURL(type.typeKey, id, snapshot), 'PATCH', {
122122
data: data
123123
});
124124
},

tests/helpers/pretender.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var stubServer = function() {
1313

1414
availableRequests: {
1515
'post': [],
16-
'put': []
16+
'patch': []
1717
},
1818

1919
get: function(url, response) {
@@ -44,19 +44,19 @@ var stubServer = function() {
4444
});
4545
},
4646

47-
put: function(url, expectedRequest, response) {
47+
patch: function(url, expectedRequest, response) {
4848
var _this = this;
4949

50-
this.validatePayload(expectedRequest, 'PUT', url);
51-
this.validatePayload(response, 'PUT', url);
50+
this.validatePayload(expectedRequest, 'PATCH', url);
51+
this.validatePayload(response, 'PATCH', url);
5252

53-
this.availableRequests.put.push({
53+
this.availableRequests.patch.push({
5454
request: expectedRequest,
5555
response: response
5656
});
5757

58-
this.pretender.put(url, function(request){
59-
var responseForRequest = _this.responseForRequest('put', request);
58+
this.pretender.patch(url, function(request){
59+
var responseForRequest = _this.responseForRequest('patch', request);
6060

6161
var string = JSON.stringify(responseForRequest);
6262
return [200, {"Content-Type": "application/json"}, string]

tests/integration/specs/updating-an-individual-resource-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module('integration/specs/updating-an-individual-resource', {
7171
}
7272
});
7373

74-
asyncTest("PUT /posts/1 won't push an array", function() {
74+
asyncTest("PATCH /posts/1 won't push an array", function() {
7575
var request = {
7676
data: {
7777
id: '1',
@@ -87,7 +87,7 @@ asyncTest("PUT /posts/1 won't push an array", function() {
8787
};
8888

8989
fakeServer.get('/posts/1', responses.post);
90-
fakeServer.put('/posts/1', request, responses.postAfterUpdate);
90+
fakeServer.patch('/posts/1', request, responses.postAfterUpdate);
9191

9292
Em.run(function() {
9393
env.store.find('post', '1').then(function(post) {
@@ -129,8 +129,8 @@ asyncTest("Update a post with an author", function() {
129129
fakeServer.get('/authors/1', responses.author);
130130
// FIXME This call shouldn't have to be made since it already exists
131131
fakeServer.get('/posts/1/author', responses.author);
132-
// FIXME Need a way to PUT to /posts/1/links/author
133-
fakeServer.put('/posts/1', request, responses.postAfterUpdateAuthor);
132+
// FIXME Need a way to PATCH to /posts/1/links/author
133+
fakeServer.patch('/posts/1', request, responses.postAfterUpdateAuthor);
134134

135135
Em.run(function() {
136136
var findPost = env.store.find('post', '1'),

0 commit comments

Comments
 (0)