Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
wattsworth
/
lumen-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7b39aaf0
authored
May 13, 2017
by
John Doe
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fixed bugs in data view handling
parent
4cff7d2e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
1 deletions
app/controllers/data_views_controller.rb
spec/controllers/data_views_controller_spec.rb
spec/factories/db_folder.rb
app/controllers/data_views_controller.rb
View file @
7b39aaf0
...
@@ -32,6 +32,7 @@ class DataViewsController < ApplicationController
...
@@ -32,6 +32,7 @@ class DataViewsController < ApplicationController
@service
=
StubService
.
new
@service
=
StubService
.
new
@data_view
.
destroy
@data_view
.
destroy
@service
.
set_notice
(
'removed data view'
)
@service
.
set_notice
(
'removed data view'
)
render
'helpers/empty_response'
,
status: :ok
end
end
private
private
...
...
spec/controllers/data_views_controller_spec.rb
View file @
7b39aaf0
...
@@ -79,4 +79,42 @@ RSpec.describe DataViewsController, type: :request do
...
@@ -79,4 +79,42 @@ RSpec.describe DataViewsController, type: :request do
end
end
end
end
end
end
describe
'DELETE destroy'
do
before
do
service
=
CreateDataView
.
new
service
.
run
(
{
name:
'created'
},
viewed_streams
.
map
{
|
x
|
x
.
id
},
viewer
)
@my_view
=
service
.
data_view
end
context
'with view owner'
do
it
'removes the data view'
do
@auth_headers
=
viewer
.
create_new_auth_token
delete
"/data_views/
#{
@my_view
.
id
}
.json"
,
headers:
@auth_headers
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_notice_message
expect
(
DataView
.
exists?
(
@my_view
.
id
)).
to
be
false
# make sure the associated permissions are destroyed
expect
(
DataViewsNilm
.
count
).
to
eq
(
0
)
end
end
context
'with anybody else'
do
it
'returns unauthorized'
do
other_user
=
create
(
:user
)
@auth_headers
=
other_user
.
create_new_auth_token
delete
"/data_views/
#{
@my_view
.
id
}
.json"
,
headers:
@auth_headers
expect
(
response
).
to
have_http_status
(
:unauthorized
)
expect
(
DataView
.
exists?
(
@my_view
.
id
)).
to
be
true
end
end
context
'without sign-in'
do
it
'returns unauthorized'
do
delete
"/data_views/
#{
@my_view
.
id
}
.json"
expect
(
response
).
to
have_http_status
(
:unauthorized
)
expect
(
DataView
.
exists?
(
@my_view
.
id
)).
to
be
true
end
end
end
end
end
spec/factories/db_folder.rb
View file @
7b39aaf0
...
@@ -9,6 +9,6 @@ FactoryGirl.define do
...
@@ -9,6 +9,6 @@ FactoryGirl.define do
end_time
{
start_time
+
Faker
::
Number
.
number
(
5
)
}
end_time
{
start_time
+
Faker
::
Number
.
number
(
5
)
}
size_on_disk
{
Faker
::
Number
.
number
(
6
)
}
size_on_disk
{
Faker
::
Number
.
number
(
6
)
}
hidden
false
hidden
false
path
{
"/root/
#{
Faker
::
Lorem
.
unique
.
word
}
"
}
path
{
"/root/
#{
Faker
::
Lorem
.
word
}
/
#{
Faker
::
Number
.
unique
.
number
(
4
)
}
"
}
end
end
end
end
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