From 26fa079c55310c2429da20b68d084ea3fa66af09 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 29 Aug 2017 14:56:43 +0200 Subject: [PATCH] Fix REPORT method when going through Backbone-Webdav adapter --- core/js/oc-backbone-webdav.js | 12 +++- core/js/tests/specs/oc-backbone-webdavSpec.js | 67 +++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/core/js/oc-backbone-webdav.js b/core/js/oc-backbone-webdav.js index 0503abea8bda..5b8146dc51ac 100644 --- a/core/js/oc-backbone-webdav.js +++ b/core/js/oc-backbone-webdav.js @@ -252,12 +252,20 @@ } function callMethod(client, options, model, headers) { - headers['Content-Type'] = 'application/json'; + var data = options.data; + if (_.isObject(data)) { + headers['Content-Type'] = 'application/json'; + data = JSON.stringify(data); + } else if (_.isString(data) && data.substr(0, 6) === ''; + body += ''; + model.customCall(body); + + expect(davClientRequestStub.calledOnce).toEqual(true); + expect(davClientRequestStub.getCall(0).args[0]) + .toEqual('REPORT'); + expect(davClientRequestStub.getCall(0).args[1]) + .toEqual('http://example.com/owncloud/remote.php/test/1'); + expect(davClientRequestStub.getCall(0).args[2]['Content-Type']) + .toEqual('application/xml'); + expect(davClientRequestStub.getCall(0).args[2]['X-Requested-With']) + .toEqual('XMLHttpRequest'); + expect(davClientRequestStub.getCall(0).args[3]) + .toEqual(body); + }); + }); });