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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Junming
jio
Commits
a6d76543
Commit
a6d76543
authored
Sep 10, 2015
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DocumentStorage: remove should also drop document attachments
parent
29effa3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
15 deletions
+66
-15
src/jio.storage/documentstorage.js
src/jio.storage/documentstorage.js
+21
-7
test/jio.storage/documentstorage.tests.js
test/jio.storage/documentstorage.tests.js
+45
-8
No files found.
src/jio.storage/documentstorage.js
View file @
a6d76543
/*jslint nomen: true*/
/*jslint nomen: true*/
/*global Blob, atob, btoa*/
/*global Blob, atob, btoa
, RSVP
*/
(
function
(
jIO
,
Blob
,
atob
,
btoa
)
{
(
function
(
jIO
,
Blob
,
atob
,
btoa
,
RSVP
)
{
"
use strict
"
;
"
use strict
"
;
/**
/**
...
@@ -74,10 +74,24 @@
...
@@ -74,10 +74,24 @@
};
};
DocumentStorage
.
prototype
.
remove
=
function
(
id
)
{
DocumentStorage
.
prototype
.
remove
=
function
(
id
)
{
return
this
.
_sub_storage
.
removeAttachment
(
var
context
=
this
;
this
.
_document_id
,
return
this
.
allAttachments
(
id
)
getSubAttachmentIdFromParam
(
id
)
.
push
(
function
(
result
)
{
)
var
key
,
promise_list
=
[];
for
(
key
in
result
)
{
if
(
result
.
hasOwnProperty
(
key
))
{
promise_list
.
push
(
context
.
removeAttachment
(
id
,
key
));
}
}
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
()
{
return
context
.
_sub_storage
.
removeAttachment
(
context
.
_document_id
,
getSubAttachmentIdFromParam
(
id
)
);
})
.
push
(
function
()
{
.
push
(
function
()
{
return
id
;
return
id
;
});
});
...
@@ -141,4 +155,4 @@
...
@@ -141,4 +155,4 @@
jIO
.
addStorage
(
'
document
'
,
DocumentStorage
);
jIO
.
addStorage
(
'
document
'
,
DocumentStorage
);
}(
jIO
,
Blob
,
atob
,
btoa
));
}(
jIO
,
Blob
,
atob
,
btoa
,
RSVP
));
test/jio.storage/documentstorage.tests.js
View file @
a6d76543
...
@@ -226,22 +226,59 @@
...
@@ -226,22 +226,59 @@
// documentStorage.remove
// documentStorage.remove
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
documentStorage.remove
"
);
module
(
"
documentStorage.remove
"
);
test
(
"
remove called substorage removeAttachment
"
,
function
()
{
test
(
"
remove called substorage removeAttachment
"
,
function
()
{
stop
();
stop
();
expect
(
3
);
expect
(
8
);
var
jio
=
jIO
.
createJIO
({
var
i
=
0
,
jio
;
function
StorageRemoveWithAttachment
()
{
return
this
;
}
StorageRemoveWithAttachment
.
prototype
.
allAttachments
=
function
(
id
)
{
equal
(
id
,
"
foo
"
,
"
allAttachments 200 called
"
);
var
result
=
{};
result
[
'
jio_attachment/
'
+
btoa
(
"
bar
"
)
+
"
/
"
+
btoa
(
"
bar1
"
)]
=
{};
result
[
'
jio_attachment/
'
+
btoa
(
"
bar
"
)
+
"
/
"
+
btoa
(
"
bar2
"
)]
=
{};
result
[
'
jio_attachment/
'
+
btoa
(
"
foo
"
)
+
"
/
"
+
btoa
(
"
foo3
"
)]
=
{};
return
result
;
};
StorageRemoveWithAttachment
.
prototype
.
removeAttachment
=
function
(
id
,
name
)
{
if
(
i
===
0
)
{
equal
(
id
,
"
foo
"
,
"
removeAttachment called
"
);
equal
(
name
,
"
jio_attachment/YmFy/YmFyMQ==
"
,
"
removeAttachment called
"
);
}
else
if
(
i
===
1
)
{
equal
(
id
,
"
foo
"
,
"
removeAttachment called
"
);
equal
(
name
,
"
jio_attachment/YmFy/YmFyMg==
"
,
"
removeAttachment called
"
);
}
else
if
(
i
===
2
)
{
equal
(
id
,
"
foo
"
,
"
removeAttachment called
"
);
equal
(
name
,
"
jio_document/YmFy.json
"
,
"
removeAttachment called
"
);
}
else
{
ok
(
false
,
"
Unexpected removeAttachment call:
"
+
id
+
"
"
+
name
);
}
i
+=
1
;
return
id
;
};
jIO
.
addStorage
(
'
documentstorageremovewithattachment
'
,
StorageRemoveWithAttachment
);
jio
=
jIO
.
createJIO
({
type
:
"
document
"
,
type
:
"
document
"
,
document_id
:
"
foo
"
,
document_id
:
"
foo
"
,
sub_storage
:
{
sub_storage
:
{
type
:
"
documentstorage
200
"
type
:
"
documentstorage
removewithattachment
"
}
}
});
});
Storage200
.
prototype
.
removeAttachment
=
function
(
id
,
name
)
{
equal
(
id
,
"
foo
"
,
"
removeAttachment 200 called
"
);
equal
(
name
,
"
jio_document/YmFy.json
"
,
"
removeAttachment 200 called
"
);
return
id
;
};
jio
.
remove
(
"
bar
"
)
jio
.
remove
(
"
bar
"
)
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
...
...
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