Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
hh1966
chemotion_eln_server
Commits
f395c3c5
Commit
f395c3c5
authored
Mar 25, 2019
by
hh1966
Browse files
Add spec for Export/Import in CollectionAPI
parent
89da2cff
Pipeline
#44308
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
spec/api/collection_api_spec.rb
View file @
f395c3c5
...
...
@@ -520,6 +520,72 @@ describe Chemotion::CollectionAPI do
end
end
end
describe
'POST /api/v1/collections/exports'
do
let
(
:c1
)
{
create
(
:collection
,
user:
user
)
}
let
(
:c2
)
{
create
(
:collection
,
user:
u2
)
}
context
'with the correct collection'
do
let
(
:params
)
{
{
collections:
[
c1
.
id
],
format:
'zip'
,
nested:
true
}
}
it
'creates an export job'
do
post
'/api/v1/collections/exports'
,
params
.
to_json
,
'CONTENT_TYPE'
=>
'application/json'
expect
(
response
.
status
).
to
eq
(
201
)
end
end
context
'with the wrong collection'
do
let
(
:params
)
{
{
collections:
[
c2
.
id
],
format:
'zip'
,
nested:
true
}
}
it
'returns 401 Unauthorized'
do
post
'/api/v1/collections/exports'
,
params
.
to_json
,
'CONTENT_TYPE'
=>
'application/json'
expect
(
response
.
status
).
to
eq
(
401
)
end
end
context
'with a non existing collection'
do
let
(
:params
)
{
{
collections:
[
666
],
format:
'zip'
,
nested:
true
}
}
it
'returns 401 Unauthorized'
do
post
'/api/v1/collections/exports'
,
params
.
to_json
,
'CONTENT_TYPE'
=>
'application/json'
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
describe
'POST /api/v1/collections/imports,'
do
context
'with a valid file,'
do
let
(
:file_upload
)
{
{
file:
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/import/2541a423-11d9-4c76-a7e1-0da470644012.zip'
),
'application/gzip'
)
}
}
it
'creates an import job'
do
status
=
post
'/api/v1/collections/imports'
,
file_upload
expect
(
response
.
status
).
to
eq
(
201
)
end
end
end
end
context
'no user logged in'
do
...
...
@@ -559,5 +625,39 @@ describe Chemotion::CollectionAPI do
expect
(
c
).
to
be_nil
end
end
describe
'POST /api/v1/collections/exports'
do
context
'with the correct collection'
do
let
(
:params
)
{
{
collections:
[
1
,
2
,
3
],
format:
'zip'
,
nested:
true
}
}
it
'responds with 401 status code'
do
post
'/api/v1/collections/exports'
,
params
.
to_json
,
'CONTENT_TYPE'
=>
'application/json'
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
describe
'POST /api/v1/collections/imports'
do
context
'with a valid file,'
do
let
(
:file_upload
)
{
{
file:
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/import/2541a423-11d9-4c76-a7e1-0da470644012.zip'
),
'application/gzip'
)
}
}
it
'responds with 401 status code'
do
status
=
post
'/api/v1/collections/imports'
,
file_upload
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
end
end
spec/fixtures/import/wrong.txt
0 → 100644
View file @
f395c3c5
this is not a ZIP file!
\ No newline at end of file
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