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
0cb19bd8
Commit
0cb19bd8
authored
Apr 02, 2015
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Memory storage: throw 404 if attachment is undefined
parent
f8efbe05
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
src/jio.storage/memorystorage.js
src/jio.storage/memorystorage.js
+8
-1
test/jio.storage/memorystorage.tests.js
test/jio.storage/memorystorage.tests.js
+28
-0
No files found.
src/jio.storage/memorystorage.js
View file @
0cb19bd8
...
...
@@ -81,7 +81,14 @@
MemoryStorage
.
prototype
.
getAttachment
=
function
(
param
)
{
try
{
return
{
data
:
this
.
_database
[
param
.
_id
].
attachments
[
param
.
_attachment
]};
var
result
=
this
.
_database
[
param
.
_id
].
attachments
[
param
.
_attachment
];
if
(
result
===
undefined
)
{
throw
new
jIO
.
util
.
jIOError
(
"
Cannot find attachment:
"
+
param
.
_id
+
"
,
"
+
param
.
_attachment
,
404
);
}
return
{
data
:
result
};
}
catch
(
error
)
{
if
(
error
instanceof
TypeError
)
{
throw
new
jIO
.
util
.
jIOError
(
...
...
test/jio.storage/memorystorage.tests.js
View file @
0cb19bd8
...
...
@@ -273,6 +273,34 @@
});
});
test
(
"
get inexistent attachment from document with other attachments
"
,
function
()
{
var
id
=
"
b
"
;
stop
();
expect
(
3
);
this
.
jio
.
__storage
.
_database
[
id
]
=
{
"
doc
"
:
JSON
.
stringify
({}),
attachments
:
{
"
foo
"
:
"
bar
"
}
};
this
.
jio
.
getAttachment
({
"
_id
"
:
id
,
"
_attachment
"
:
"
inexistent
"
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
Cannot find attachment: b , inexistent
"
);
equal
(
error
.
status_code
,
404
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
get attachment from document
"
,
function
()
{
var
id
=
"
putattmt1
"
,
attachment
=
"
putattmt2
"
,
...
...
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