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,15 +82,26 @@ ...@@ -82,15 +82,26 @@
} }
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()
.push(function () {
return ajax(that, {
type: "MKCOL", type: "MKCOL",
url: this._url + id url: that._url + id
});
})
.push(undefined, function (err) {
if ((err.target !== undefined) &&
(err.target.status === 405)) {
return;
}
throw err;
}); });
}; };
......
...@@ -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