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
dc7b714e
authored
May 26, 2017
by
John Doe
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
changed data requests to POST because they can update the view redux
parent
a1988d29
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
6 deletions
config/database.yml
config/routes.rb
spec/controllers/db_elements_controller_spec.rb
config/database.yml
View file @
dc7b714e
...
@@ -12,6 +12,7 @@ default: &default
...
@@ -12,6 +12,7 @@ default: &default
development
:
development
:
<<
:
*default
<<
:
*default
database
:
db/development.sqlite3
database
:
db/development.sqlite3
timeout
:
10000
# Warning: The database defined as "test" will be erased and
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# re-generated from your development database when you run "rake".
...
...
config/routes.rb
View file @
dc7b714e
...
@@ -19,7 +19,7 @@ Rails.application.routes.draw do
...
@@ -19,7 +19,7 @@ Rails.application.routes.draw do
end
end
resources
:db_elements
,
only:
[
:index
]
do
resources
:db_elements
,
only:
[
:index
]
do
collection
do
collection
do
ge
t
'data'
pos
t
'data'
end
end
end
end
...
...
spec/controllers/db_elements_controller_spec.rb
View file @
dc7b714e
...
@@ -4,7 +4,7 @@ require 'rails_helper'
...
@@ -4,7 +4,7 @@ require 'rails_helper'
RSpec
.
describe
DbElementsController
,
type: :request
do
RSpec
.
describe
DbElementsController
,
type: :request
do
let
(
:user1
)
{
create
(
:user
,
first_name:
'John'
)
}
let
(
:user1
)
{
create
(
:user
,
first_name:
'John'
)
}
let
(
:user2
)
{
create
(
:user
,
first_name:
'Sam'
)
}
let
(
:user2
)
{
create
(
:user
,
first_name:
'Sam'
)
}
describe
'
GE
T #data'
do
describe
'
POS
T #data'
do
# retrieve data for elements listed by array of ids
# retrieve data for elements listed by array of ids
context
'with authenticated user'
do
context
'with authenticated user'
do
before
do
before
do
...
@@ -31,7 +31,7 @@ RSpec.describe DbElementsController, type: :request do
...
@@ -31,7 +31,7 @@ RSpec.describe DbElementsController, type: :request do
allow
(
LoadElementData
).
to
receive
(
:new
).
and_return
(
@mock_service
)
allow
(
LoadElementData
).
to
receive
(
:new
).
and_return
(
@mock_service
)
@auth_headers
=
user1
.
create_new_auth_token
@auth_headers
=
user1
.
create_new_auth_token
ge
t
'/db_elements/data.json'
,
pos
t
'/db_elements/data.json'
,
params:
{
elements:
[
@elem1
.
id
,
@elem2
.
id
].
to_json
,
params:
{
elements:
[
@elem1
.
id
,
@elem2
.
id
].
to_json
,
start_time:
0
,
end_time:
100
,
redux_json:
'new home view'
},
start_time:
0
,
end_time:
100
,
redux_json:
'new home view'
},
headers:
@auth_headers
headers:
@auth_headers
...
@@ -44,7 +44,7 @@ RSpec.describe DbElementsController, type: :request do
...
@@ -44,7 +44,7 @@ RSpec.describe DbElementsController, type: :request do
end
end
it
'returns error if time bounds are invalid'
do
it
'returns error if time bounds are invalid'
do
@auth_headers
=
user1
.
create_new_auth_token
@auth_headers
=
user1
.
create_new_auth_token
ge
t
'/db_elements/data.json'
,
pos
t
'/db_elements/data.json'
,
params:
{
elements:
[
@elem1
.
id
,
@elem2
.
id
].
to_json
,
params:
{
elements:
[
@elem1
.
id
,
@elem2
.
id
].
to_json
,
start_time:
100
,
end_time:
0
},
start_time:
100
,
end_time:
0
},
headers:
@auth_headers
headers:
@auth_headers
...
@@ -59,7 +59,7 @@ RSpec.describe DbElementsController, type: :request do
...
@@ -59,7 +59,7 @@ RSpec.describe DbElementsController, type: :request do
stream2
.
db_elements
<<
@elem3
stream2
.
db_elements
<<
@elem3
@auth_headers
=
user1
.
create_new_auth_token
@auth_headers
=
user1
.
create_new_auth_token
ge
t
'/db_elements/data.json'
,
pos
t
'/db_elements/data.json'
,
params:
{
elements:
[
@elem1
.
id
,
@elem3
.
id
].
to_json
,
params:
{
elements:
[
@elem1
.
id
,
@elem3
.
id
].
to_json
,
start_time:
100
,
end_time:
0
},
start_time:
100
,
end_time:
0
},
headers:
@auth_headers
headers:
@auth_headers
...
@@ -68,7 +68,7 @@ RSpec.describe DbElementsController, type: :request do
...
@@ -68,7 +68,7 @@ RSpec.describe DbElementsController, type: :request do
end
end
context
'without sign-in'
do
context
'without sign-in'
do
it
'returns unauthorized'
do
it
'returns unauthorized'
do
ge
t
'/db_elements/data.json'
pos
t
'/db_elements/data.json'
expect
(
response
).
to
have_http_status
(
:unauthorized
)
expect
(
response
).
to
have_http_status
(
:unauthorized
)
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