Merge pull request #1907 from tgriesser/patch-bug

Fixing issue in patch not sending data
This commit is contained in:
Jeremy Ashkenas
2012-12-12 17:27:24 -08:00
2 changed files with 3 additions and 2 deletions

View File

@@ -1446,7 +1446,7 @@
}
// Ensure that we have the appropriate request data.
if (options.data == null && model && (method === 'create' || method === 'update')) {
if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) {
params.contentType = 'application/json';
params.data = JSON.stringify(options.attrs || model.toJSON(options));
}
@@ -1459,7 +1459,7 @@
// For older servers, emulate HTTP by mimicking the HTTP method with `_method`
// And an `X-HTTP-Method-Override` header.
if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE')) {
if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) {
params.type = 'POST';
if (options.emulateJSON) params.data._method = type;
var beforeSend = options.beforeSend;

View File

@@ -400,6 +400,7 @@ $(document).ready(function() {
equal(_.size(this.syncArgs.options.attrs), 2);
equal(this.syncArgs.options.attrs.d, 4);
equal(this.syncArgs.options.attrs.a, undefined);
equal(this.ajaxSettings.data, "{\"b\":2,\"d\":4}");
});
test("save in positional style", 1, function() {