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
1ef89956
authored
Jun 02, 2017
by
John Doe
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fixed legacy parser for discrete streams
parent
9fa9dffb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
18 deletions
app/adapters/db_adapter.rb
spec/controllers/db_elements_controller_spec.rb
app/adapters/db_adapter.rb
View file @
1ef89956
...
...
@@ -55,18 +55,6 @@ class DbAdapter
# The streams are not pure attributes, pull them out
elements
=
metadata
.
delete
(
:streams
)
||
[]
elements
.
each
(
&
:symbolize_keys!
)
# map the legacy discrete flag to new type setting
# discrete == True => type = event
# discrete == False => type = continuous
elements
.
map!
do
|
e
|
next
unless
e
[
:type
].
nil?
e
[
:display_type
]
=
if
e
[
:discrete
]
'event'
else
'continuous'
end
e
end
# Create the schema:
# 3 elements: path, attributes, elements
{
...
...
@@ -197,8 +185,18 @@ class DbAdapter
# sanitize 'streams' (elements) parameters
element_attrs
=
DbElement
.
attribute_names
.
map
(
&
:to_sym
)
metadata
[
'streams'
].
map!
do
|
element
|
element
.
symbolize_keys
.
slice
(
*
element_attrs
)
# map the legacy discrete flag to new type setting
# discrete == True => type = event
# discrete == False => type = continuous
element
.
symbolize_keys!
if
element
[
:display_type
].
nil?
if
element
[
:discrete
]
element
[
:display_type
]
=
'event'
else
element
[
:display_type
]
=
'continuous'
end
end
element
.
slice
(
*
element_attrs
)
end
end
metadata
.
symbolize_keys
...
...
spec/controllers/db_elements_controller_spec.rb
View file @
1ef89956
...
...
@@ -17,7 +17,7 @@ RSpec.describe DbElementsController, type: :request do
stream
.
db_elements
<<
@elem1
stream
.
db_elements
<<
@elem2
end
it
"returns elements with data
and updates the user's home view
"
do
it
"returns elements with data"
do
@service_data
=
[{
id:
@elem1
.
id
,
data:
'mock1'
},
...
...
@@ -33,14 +33,12 @@ RSpec.describe DbElementsController, type: :request do
@auth_headers
=
user1
.
create_new_auth_token
get
'/db_elements/data.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
},
headers:
@auth_headers
expect
(
response
).
to
have_http_status
(
:ok
)
# check to make sure JSON renders the elements
body
=
JSON
.
parse
(
response
.
body
)
expect
(
body
[
'data'
].
count
).
to
eq
(
2
)
# check the user home view
expect
(
user1
.
reload
.
home_data_view
.
redux_json
).
to
eq
(
'new home view'
)
end
it
'returns error if time bounds are invalid'
do
@auth_headers
=
user1
.
create_new_auth_token
...
...
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