Commit d85fc772 authored by lucas.parsy's avatar lucas.parsy

davstorage: Don't fail when put an existing document and add test related

parent c73d13c1
...@@ -82,16 +82,27 @@ ...@@ -82,16 +82,27 @@
} }
DavStorage.prototype.put = function (id, param) { DavStorage.prototype.put = function (id, param) {
var that = this;
id = restrictDocumentId(id); id = restrictDocumentId(id);
if (Object.getOwnPropertyNames(param).length > 0) { if (Object.getOwnPropertyNames(param).length > 0) {
// Reject if param has some properties // Reject if param has some properties
throw new jIO.util.jIOError("Can not store properties: " + throw new jIO.util.jIOError("Can not store properties: " +
Object.getOwnPropertyNames(param), 400); Object.getOwnPropertyNames(param), 400);
} }
return ajax(this, { return new RSVP.Queue()
type: "MKCOL", .push(function () {
url: this._url + id return ajax(that, {
}); type: "MKCOL",
url: that._url + id
});
})
.push(undefined, function (err) {
if ((err.target !== undefined) &&
(err.target.status === 405)) {
return;
}
throw err;
});
}; };
DavStorage.prototype.remove = function (id) { DavStorage.prototype.remove = function (id) {
......
...@@ -94,6 +94,26 @@ ...@@ -94,6 +94,26 @@
}); });
}); });
test("don't throw error when putting existing directory", function () {
var url = domain + "/existing/",
server = this.server;
this.server.respondWith("MKCOL", url, [405, {
"Content-Type": "text/xml"
}, "MKCOL https://example.org/existing/ 405 (Method Not Allowed)"]);
stop();
expect(1);
this.jio.put("/existing/", {})
.then(function () {
equal(server.requests[0].status, 405);
})
.fail(function (error) {
ok(false, error);
})
.always(function () {
start();
});
});
test("reject ID not starting with /", function () { test("reject ID not starting with /", function () {
stop(); stop();
expect(3); expect(3);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment