Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Douglas
jio
Commits
8ad93226
Commit
8ad93226
authored
Apr 27, 2015
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5 storage: handle 404 status code
parent
299a0345
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
137 additions
and
11 deletions
+137
-11
src/jio.storage/erp5storage.js
src/jio.storage/erp5storage.js
+21
-11
test/jio.storage/erp5storage.tests.js
test/jio.storage/erp5storage.tests.js
+116
-0
No files found.
src/jio.storage/erp5storage.js
View file @
8ad93226
...
...
@@ -38,17 +38,27 @@
return
getSiteDocument
(
storage
)
.
push
(
function
(
site_hal
)
{
// XXX need to get modified metadata
return
jIO
.
util
.
ajax
({
"
type
"
:
"
GET
"
,
"
url
"
:
UriTemplate
.
parse
(
site_hal
.
_links
.
traverse
.
href
)
.
expand
({
relative_url
:
id
,
view
:
options
.
_view
}),
"
xhrFields
"
:
{
withCredentials
:
true
}
});
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
jIO
.
util
.
ajax
({
"
type
"
:
"
GET
"
,
"
url
"
:
UriTemplate
.
parse
(
site_hal
.
_links
.
traverse
.
href
)
.
expand
({
relative_url
:
id
,
view
:
options
.
_view
}),
"
xhrFields
"
:
{
withCredentials
:
true
}
});
})
.
push
(
undefined
,
function
(
error
)
{
if
((
error
.
target
!==
undefined
)
&&
(
error
.
target
.
status
===
404
))
{
throw
new
jIO
.
util
.
jIOError
(
"
Cannot find document:
"
+
id
,
404
);
}
throw
error
;
});
});
}
...
...
test/jio.storage/erp5storage.tests.js
View file @
8ad93226
...
...
@@ -64,6 +64,35 @@
}
});
test
(
"
get inexistent document
"
,
function
()
{
var
id
=
"
person_module/20150119_azerty
"
,
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
encodeURIComponent
(
id
);
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
.
get
(
id
)
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
Cannot find document:
"
+
id
);
equal
(
error
.
status_code
,
404
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
get ERP5 document
"
,
function
()
{
var
id
=
"
person_module/20150119_azerty
"
,
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
...
...
@@ -136,6 +165,35 @@
}
});
test
(
"
allAttachments on inexistent document
"
,
function
()
{
var
id
=
"
person_module/20150119_azerty
"
,
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
encodeURIComponent
(
id
);
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
.
allAttachments
(
id
)
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
Cannot find document:
"
+
id
);
equal
(
error
.
status_code
,
404
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
allAttachments ERP5 document
"
,
function
()
{
var
id
=
"
person_module/20150119_azerty
"
,
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
...
...
@@ -322,6 +380,35 @@
});
});
test
(
"
getAttachment: view on inexistent document
"
,
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
,
"
view
"
)
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
Cannot find document:
"
+
id
);
equal
(
error
.
status_code
,
404
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
getAttachment: view uses default form
"
,
function
()
{
var
id
=
"
person_module/1
"
,
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
...
...
@@ -379,6 +466,35 @@
});
});
test
(
"
getAttachment: links on inexistent document
"
,
function
()
{
var
id
=
"
person_module/1
"
,
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
encodeURIComponent
(
id
);
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
,
"
links
"
)
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
Cannot find document:
"
+
id
);
equal
(
error
.
status_code
,
404
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
getAttachment: links uses no form
"
,
function
()
{
var
id
=
"
person_module/1
"
,
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment