Commit 48ea995c authored by Romain Courteaud's avatar Romain Courteaud

[erp5storage] handle non existing view

Return a 404 jIOError.
parent dcca4e59
......@@ -365,6 +365,13 @@
);
}
return evt.target.response;
}, function (error) {
if ((error.target !== undefined) &&
(error.target.status === 404)) {
throw new jIO.util.jIOError("Cannot find attachment: " + action,
404);
}
throw error;
});
}
throw new jIO.util.jIOError("ERP5: not support get attachment: " + action,
......
......@@ -965,6 +965,35 @@
});
});
test("getAttachment: view on inexistent view", function () {
var id = "person_module/1",
traverse_url = domain + "?mode=traverse&relative_url=" +
encodeURIComponent(id) + "&view=foo_view";
this.server.respondWith("GET", domain, [200, {
"Content-Type": "application/hal+json"
}, root_hateoas]);
this.server.respondWith("GET", traverse_url, [404, {
"Content-Type": "text/html"
}, ""]);
stop();
expect(3);
this.jio.getAttachment(id, traverse_url)
.fail(function (error) {
ok(error instanceof jIO.util.jIOError);
equal(error.message, "Cannot find attachment: " + traverse_url);
equal(error.status_code, 404);
})
.fail(function (error) {
ok(false, error);
})
.always(function () {
start();
});
});
test("getAttachment: view uses default form with access token", function () {
var id = "person_module/1",
traverse_url = domain + "?mode=traverse&relative_url=" +
......
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