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 @@
}
DavStorage.prototype.put = function (id, param) {
var that = this;
id = restrictDocumentId(id);
if (Object.getOwnPropertyNames(param).length > 0) {
// Reject if param has some properties
throw new jIO.util.jIOError("Can not store properties: " +
Object.getOwnPropertyNames(param), 400);
}
return ajax(this, {
type: "MKCOL",
url: this._url + id
});
return new RSVP.Queue()
.push(function () {
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) {
......
......@@ -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 () {
stop();
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