Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
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
Hardik Juneja
jio-main
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 @@
...
@@ -38,17 +38,27 @@
return
getSiteDocument
(
storage
)
return
getSiteDocument
(
storage
)
.
push
(
function
(
site_hal
)
{
.
push
(
function
(
site_hal
)
{
// XXX need to get modified metadata
// XXX need to get modified metadata
return
jIO
.
util
.
ajax
({
return
new
RSVP
.
Queue
()
"
type
"
:
"
GET
"
,
.
push
(
function
()
{
"
url
"
:
UriTemplate
.
parse
(
site_hal
.
_links
.
traverse
.
href
)
return
jIO
.
util
.
ajax
({
.
expand
({
"
type
"
:
"
GET
"
,
relative_url
:
id
,
"
url
"
:
UriTemplate
.
parse
(
site_hal
.
_links
.
traverse
.
href
)
view
:
options
.
_view
.
expand
({
}),
relative_url
:
id
,
"
xhrFields
"
:
{
view
:
options
.
_view
withCredentials
:
true
}),
}
"
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 @@
...
@@ -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
()
{
test
(
"
get ERP5 document
"
,
function
()
{
var
id
=
"
person_module/20150119_azerty
"
,
var
id
=
"
person_module/20150119_azerty
"
,
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
...
@@ -136,6 +165,35 @@
...
@@ -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
()
{
test
(
"
allAttachments ERP5 document
"
,
function
()
{
var
id
=
"
person_module/20150119_azerty
"
,
var
id
=
"
person_module/20150119_azerty
"
,
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
...
@@ -322,6 +380,35 @@
...
@@ -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
()
{
test
(
"
getAttachment: view uses default form
"
,
function
()
{
var
id
=
"
person_module/1
"
,
var
id
=
"
person_module/1
"
,
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
...
@@ -379,6 +466,35 @@
...
@@ -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
()
{
test
(
"
getAttachment: links uses no form
"
,
function
()
{
var
id
=
"
person_module/1
"
,
var
id
=
"
person_module/1
"
,
traverse_url
=
domain
+
"
?mode=traverse&relative_url=
"
+
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