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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aurel
jio
Commits
19cff054
Commit
19cff054
authored
Feb 19, 2015
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ERP5Storage tests
parent
205247b1
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
639 additions
and
16 deletions
+639
-16
src/jio.storage/erp5storage.js
src/jio.storage/erp5storage.js
+15
-16
test/jio.storage/erp5storage.tests.js
test/jio.storage/erp5storage.tests.js
+623
-0
test/tests.html
test/tests.html
+1
-0
No files found.
src/jio.storage/erp5storage.js
View file @
19cff054
...
...
@@ -10,10 +10,9 @@
// }
/*jslint nomen: true */
/*global jIO, UriTemplate, FormData, RSVP, URI,
Blob, btoa */
/*global jIO, UriTemplate, FormData, RSVP, URI, Blob*/
(
function
(
jIO
,
UriTemplate
,
RSVP
,
URI
,
Blob
)
{
(
function
(
jIO
,
UriTemplate
,
FormData
,
RSVP
,
URI
,
Blob
)
{
"
use strict
"
;
function
getSiteDocument
(
storage
)
{
...
...
@@ -75,8 +74,6 @@
result
.
_id
=
param
.
_id
;
result
.
portal_type
=
result
.
_links
.
type
.
name
;
result
.
_attachments
=
attachments
;
// Remove all ERP5 hateoas links / convert them into jIO ID
for
(
key
in
result
)
{
if
(
result
.
hasOwnProperty
(
key
))
{
...
...
@@ -86,6 +83,8 @@
}
}
result
.
_attachments
=
attachments
;
return
result
;
});
};
...
...
@@ -105,19 +104,19 @@
// if Base_edit, do put URN
// if others, do post URN (ie, unique new attachment name)
// XXX Except this attachment name should be generated when
return
new
Blob
(
return
{
data
:
new
Blob
(
[
JSON
.
stringify
(
result
)],
{
"
type
"
:
'
application/hal+json
'
}
);
)
}
;
});
}
if
(
action
===
"
links
"
)
{
return
getDocumentAndHateoas
(
this
,
param
)
.
push
(
function
(
response
)
{
return
new
Blob
(
return
{
data
:
new
Blob
(
[
JSON
.
stringify
(
JSON
.
parse
(
response
.
target
.
responseText
))],
{
"
type
"
:
'
application/hal+json
'
}
);
)
}
;
});
}
if
(
action
.
indexOf
(
this
.
_url
)
===
0
)
{
...
...
@@ -134,20 +133,21 @@
.
push
(
function
(
evt
)
{
var
result
=
JSON
.
parse
(
evt
.
target
.
responseText
);
result
.
_id
=
param
.
_id
;
return
new
Blob
(
return
{
data
:
new
Blob
(
[
JSON
.
stringify
(
result
)],
{
"
type
"
:
evt
.
target
.
getResponseHeader
(
"
Content-Type
"
)}
);
)
}
;
});
}
throw
new
Error
(
"
ERP5: not support get attachment:
"
+
action
);
throw
new
jIO
.
util
.
jIOError
(
"
ERP5: not support get attachment:
"
+
action
,
400
);
};
ERP5Storage
.
prototype
.
putAttachment
=
function
(
metadata
)
{
// Assert we use a callable on a document from the ERP5 site
if
(
metadata
.
_attachment
.
indexOf
(
this
.
_url
)
!==
0
)
{
throw
new
Error
(
"
Can not store outside ERP5:
"
+
metadata
.
_attachment
);
throw
new
jIO
.
util
.
jIO
Error
(
"
Can not store outside ERP5:
"
+
metadata
.
_attachment
,
400
);
}
return
new
RSVP
.
Queue
()
...
...
@@ -217,7 +217,6 @@
delete
item
.
_links
;
result
.
push
({
id
:
uri
.
segment
(
2
),
doc
:
{},
value
:
item
});
}
...
...
@@ -227,4 +226,4 @@
jIO
.
addStorage
(
"
erp5
"
,
ERP5Storage
);
}(
jIO
,
UriTemplate
,
RSVP
,
URI
,
Blob
));
}(
jIO
,
UriTemplate
,
FormData
,
RSVP
,
URI
,
Blob
));
test/jio.storage/erp5storage.tests.js
0 → 100644
View file @
19cff054
This diff is collapsed.
Click to expand it.
test/tests.html
View file @
19cff054
...
...
@@ -32,6 +32,7 @@
<script
src=
"jio.storage/davstorage.tests.js"
></script>
<script
src=
"jio.storage/drivetojiomapping.tests.js"
></script>
<script
src=
"jio.storage/unionstorage.tests.js"
></script>
<script
src=
"jio.storage/erp5storage.tests.js"
></script>
<!--script src="jio.storage/indexeddbstorage.tests.js"></script-->
<!--script src="jio.storage/indexstorage.tests.js"></script-->
...
...
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