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
5d4a5f51
authored
May 24, 2017
by
John Doe
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
added visibility property to dataviews
parent
ece8d62d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
157 additions
and
134 deletions
app/controllers/data_views_controller.rb
app/models/data_view.rb
app/services/data/load_stream_data.rb
app/views/db_streams/data.csv.erb
db/migrate/20170524005258_add_visibility_to_data_views.rb
db/schema.rb
spec/controllers/data_views_controller_spec.rb
spec/factories/data_views.rb
spec/models/data_view_spec.rb
spec/services/data_view/create_data_view_spec.rb
app/controllers/data_views_controller.rb
View file @
5d4a5f51
...
@@ -38,11 +38,11 @@ class DataViewsController < ApplicationController
...
@@ -38,11 +38,11 @@ class DataViewsController < ApplicationController
private
private
def
data_view_params
def
data_view_params
params
.
permit
(
:name
,
:description
,
:image
,
:redux_json
)
params
.
permit
(
:name
,
:description
,
:
visibility
,
:
image
,
:redux_json
)
end
end
def
updatable_data_view_params
def
updatable_data_view_params
params
.
permit
(
:name
,
:description
)
params
.
permit
(
:name
,
:description
,
:visibility
)
end
end
def
set_data_view
def
set_data_view
...
...
app/models/data_view.rb
View file @
5d4a5f51
...
@@ -10,6 +10,9 @@ class DataView < ApplicationRecord
...
@@ -10,6 +10,9 @@ class DataView < ApplicationRecord
#---Validations-----
#---Validations-----
validates
:name
,
:presence
=>
true
validates
:name
,
:presence
=>
true
TYPES
=
%w(public private hidden)
validates
:visibility
,
:inclusion
=>
{
:in
=>
TYPES
}
#return all DataViews that can be loaded by this user
#return all DataViews that can be loaded by this user
def
self
.
find_viewable
(
user
)
def
self
.
find_viewable
(
user
)
...
@@ -18,14 +21,20 @@ class DataView < ApplicationRecord
...
@@ -18,14 +21,20 @@ class DataView < ApplicationRecord
nilms
=
r
[
:admin
]
+
r
[
:owner
]
+
r
[
:viewer
]
nilms
=
r
[
:admin
]
+
r
[
:owner
]
+
r
[
:viewer
]
#find all DataViewsNilms that are not allowed
#find all DataViewsNilms that are not allowed
prohibited
=
DataViewsNilm
.
where
.
not
(
nilm_id:
nilms
.
pluck
(
:id
))
prohibited
=
DataViewsNilm
.
where
.
not
(
nilm_id:
nilms
.
pluck
(
:id
))
#find the *other* DataViewsNilms (allowed)
#find the *other* DataViewsNilms (allowed)
allowed_ids
=
DataViewsNilm
.
where
.
not
(
id:
prohibited
.
pluck
(
:id
))
allowed_ids
=
DataViewsNilm
.
where
.
not
(
id:
prohibited
.
pluck
(
:id
))
.
pluck
(
:data_view_id
).
uniq
.
pluck
(
:data_view_id
).
uniq
DataView
.
find
(
allowed_ids
)
#find all visible data views
visible_ids
=
DataView
.
where
(
owner:
user
).
or
(
DataView
.
where
(
visibility:
'public'
)).
pluck
(
:id
)
#permitted views must be both visible and allowed
DataView
.
where
(
id:
allowed_ids
&
visible_ids
)
end
end
def
self
.
json_keys
def
self
.
json_keys
[
:id
,
:name
,
:description
,
:image
,
:redux_json
]
[
:id
,
:name
,
:description
,
:image
,
:redux_json
,
:visibility
]
end
end
end
end
app/services/data/load_stream_data.rb
View file @
5d4a5f51
...
@@ -69,6 +69,7 @@ class LoadStreamData
...
@@ -69,6 +69,7 @@ class LoadStreamData
@data
=
__build_decimated_data
(
decimateable_elements
,
resp
)
+
@data
=
__build_decimated_data
(
decimateable_elements
,
resp
)
+
__build_intervals_from_decimated_data
(
interval_elements
,
resp
)
__build_intervals_from_decimated_data
(
interval_elements
,
resp
)
end
end
self
end
end
#===Description
#===Description
...
...
app/views/db_streams/data.csv.erb
View file @
5d4a5f51
...
@@ -9,23 +9,28 @@
...
@@ -9,23 +9,28 @@
# total time:
<%=
distance_of_time_in_words
(
@legend
[
:end_time
]
/
1
e6
-
@legend
[
:start_time
]
/
1
e6
)
%>
# total time:
<%=
distance_of_time_in_words
(
@legend
[
:end_time
]
/
1
e6
-
@legend
[
:start_time
]
/
1
e6
)
%>
# total rows:
<%=
@legend
[
:num_rows
]
%>
# total rows:
<%=
@legend
[
:num_rows
]
%>
# decimation factor:
<%=
@legend
[
:decimation_factor
]
%>
# decimation factor:
<%=
@legend
[
:decimation_factor
]
%>
# notes:
<%=
@legend
[
:notes
]
%>
# legend:
<%
@legend
[
:columns
].
each
do
|
col
|
%>
# Column
<%=
col
[
:index
]
%>
:
<%=
col
[
:name
]
%>
(
<%=
col
[
:units
]
%>
)
<%
end
%>
#
# --------- MATLAB INSTRUCTIONS ------------
#
#
# this file can be loaded directly into MATLAB
# this file can be loaded directly into MATLAB
#
#
# dataset = importdata('thisfilename.csv')
# >> x = importdata('~/Downloads/filename.csv')
# x =
# data: [1737x15 double] % the data
# textdata: {41x1 cell} % this help text
#
#
# dataset.textdata: this help text
# --------- NILMTOOL INSTRUCTIONS ----------
# dataset.data: the data
#
#
# raw data can be accessed using nilmtool, run:
# raw data can be accessed using nilmtool, run:
# nilmtool -u
<%=
@db
.
url
%>
extract -s @
<%=
@legend
[
:start_time
]
%>
-e @
<%=
@legend
[
:end_time
]
%>
<%=
@db_stream
.
path
%>
#
#
#
<%=
@legend
[
:notes
]
%>
# $> nilmtool -u
<%=
@db
.
url
%>
extract -s @
<%=
@legend
[
:start_time
]
%>
-e @
<%=
@legend
[
:end_time
]
%>
<%=
@db_stream
.
path
%>
# ----------- LEGEND ---------------
#
<%
@legend
[
:columns
].
each
do
|
col
|
%>
# ------------------------------------------
# Column
<%=
col
[
:index
]
%>
:
<%=
col
[
:name
]
%>
(
<%=
col
[
:units
]
%>
)
<%
end
%>
# -----------------------------------
#
#
<%
@data
.
each
do
|
row
|
%>
<%
@data
.
each
do
|
row
|
%>
<%=
row
.
join
(
", "
)
%>
<%=
row
.
join
(
", "
)
%>
...
...
db/migrate/20170524005258_add_visibility_to_data_views.rb
0 → 100644
View file @
5d4a5f51
class
AddVisibilityToDataViews
<
ActiveRecord
::
Migration
[
5.1
]
def
change
add_column
:data_views
,
:visibility
,
:string
end
end
db/schema.rb
View file @
5d4a5f51
...
@@ -10,16 +10,17 @@
...
@@ -10,16 +10,17 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201705
12013633
)
do
ActiveRecord
::
Schema
.
define
(
version:
201705
24005258
)
do
create_table
"data_views"
,
force: :cascade
do
|
t
|
create_table
"data_views"
,
force: :cascade
do
|
t
|
t
.
integer
"user_id"
t
.
integer
"user_id"
t
.
string
"name"
t
.
string
"name"
t
.
string
"description"
t
.
string
"description"
t
.
text
"image"
t
.
text
"image"
t
.
text
"redux_json"
t
.
text
"redux_json"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
string
"visibility"
end
end
create_table
"data_views_nilms"
,
force: :cascade
do
|
t
|
create_table
"data_views_nilms"
,
force: :cascade
do
|
t
|
...
@@ -30,77 +31,77 @@ ActiveRecord::Schema.define(version: 20170512013633) do
...
@@ -30,77 +31,77 @@ ActiveRecord::Schema.define(version: 20170512013633) do
end
end
create_table
"db_decimations"
,
force: :cascade
do
|
t
|
create_table
"db_decimations"
,
force: :cascade
do
|
t
|
t
.
integer
"start_time"
,
limit:
8
t
.
integer
"start_time"
,
limit:
8
t
.
integer
"end_time"
,
limit:
8
t
.
integer
"end_time"
,
limit:
8
t
.
integer
"total_rows"
,
limit:
8
t
.
integer
"total_rows"
,
limit:
8
t
.
integer
"total_time"
,
limit:
8
t
.
integer
"total_time"
,
limit:
8
t
.
integer
"db_stream_id"
t
.
integer
"db_stream_id"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
integer
"level"
,
limit:
8
t
.
integer
"level"
,
limit:
8
t
.
string
"data_type"
t
.
string
"data_type"
end
end
create_table
"db_elements"
,
force: :cascade
do
|
t
|
create_table
"db_elements"
,
force: :cascade
do
|
t
|
t
.
string
"name"
t
.
string
"name"
t
.
string
"units"
t
.
string
"units"
t
.
integer
"column"
t
.
integer
"column"
t
.
float
"default_max"
t
.
float
"default_max"
t
.
float
"default_min"
t
.
float
"default_min"
t
.
float
"scale_factor"
t
.
float
"scale_factor"
t
.
float
"offset"
t
.
float
"offset"
t
.
integer
"db_stream_id"
t
.
integer
"db_stream_id"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
boolean
"plottable"
t
.
boolean
"plottable"
t
.
string
"display_type"
t
.
string
"display_type"
end
end
create_table
"db_folders"
,
force: :cascade
do
|
t
|
create_table
"db_folders"
,
force: :cascade
do
|
t
|
t
.
string
"name"
t
.
string
"name"
t
.
string
"description"
t
.
string
"description"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
integer
"parent_id"
t
.
integer
"parent_id"
t
.
string
"path"
t
.
string
"path"
t
.
boolean
"hidden"
t
.
boolean
"hidden"
t
.
integer
"db_id"
t
.
integer
"db_id"
t
.
integer
"start_time"
,
limit:
8
t
.
integer
"start_time"
,
limit:
8
t
.
integer
"end_time"
,
limit:
8
t
.
integer
"end_time"
,
limit:
8
t
.
integer
"size_on_disk"
,
limit:
8
t
.
integer
"size_on_disk"
,
limit:
8
end
end
create_table
"db_streams"
,
force: :cascade
do
|
t
|
create_table
"db_streams"
,
force: :cascade
do
|
t
|
t
.
string
"name"
t
.
string
"name"
t
.
string
"description"
t
.
string
"description"
t
.
integer
"db_folder_id"
t
.
integer
"db_folder_id"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
string
"path"
t
.
string
"path"
t
.
integer
"start_time"
,
limit:
8
t
.
integer
"start_time"
,
limit:
8
t
.
integer
"end_time"
,
limit:
8
t
.
integer
"end_time"
,
limit:
8
t
.
integer
"total_rows"
,
limit:
8
t
.
integer
"total_rows"
,
limit:
8
t
.
integer
"total_time"
,
limit:
8
t
.
integer
"total_time"
,
limit:
8
t
.
string
"data_type"
t
.
string
"data_type"
t
.
string
"name_abbrev"
t
.
string
"name_abbrev"
t
.
boolean
"delete_locked"
t
.
boolean
"delete_locked"
t
.
boolean
"hidden"
t
.
boolean
"hidden"
t
.
integer
"size_on_disk"
,
limit:
8
t
.
integer
"size_on_disk"
,
limit:
8
t
.
integer
"db_id"
t
.
integer
"db_id"
end
end
create_table
"dbs"
,
force: :cascade
do
|
t
|
create_table
"dbs"
,
force: :cascade
do
|
t
|
t
.
string
"url"
t
.
string
"url"
t
.
integer
"db_folder_id"
t
.
integer
"db_folder_id"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
integer
"nilm_id"
t
.
integer
"nilm_id"
t
.
integer
"size_total"
,
limit:
8
t
.
integer
"size_total"
,
limit:
8
t
.
integer
"size_db"
,
limit:
8
t
.
integer
"size_db"
,
limit:
8
t
.
integer
"size_other"
,
limit:
8
t
.
integer
"size_other"
,
limit:
8
t
.
string
"version"
t
.
string
"version"
t
.
integer
"max_points_per_plot"
,
default:
3600
t
.
integer
"max_points_per_plot"
,
default:
3600
t
.
boolean
"available"
t
.
boolean
"available"
end
end
create_table
"memberships"
,
force: :cascade
do
|
t
|
create_table
"memberships"
,
force: :cascade
do
|
t
|
...
@@ -111,60 +112,60 @@ ActiveRecord::Schema.define(version: 20170512013633) do
...
@@ -111,60 +112,60 @@ ActiveRecord::Schema.define(version: 20170512013633) do
end
end
create_table
"nilms"
,
force: :cascade
do
|
t
|
create_table
"nilms"
,
force: :cascade
do
|
t
|
t
.
string
"name"
t
.
string
"name"
t
.
string
"description"
t
.
string
"description"
t
.
string
"url"
t
.
string
"url"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
end
end
create_table
"permissions"
,
force: :cascade
do
|
t
|
create_table
"permissions"
,
force: :cascade
do
|
t
|
t
.
integer
"nilm_id"
t
.
integer
"nilm_id"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
integer
"user_id"
t
.
integer
"user_id"
t
.
integer
"user_group_id"
t
.
integer
"user_group_id"
t
.
string
"role"
t
.
string
"role"
end
end
create_table
"user_groups"
,
force: :cascade
do
|
t
|
create_table
"user_groups"
,
force: :cascade
do
|
t
|
t
.
string
"name"
t
.
string
"name"
t
.
string
"description"
t
.
string
"description"
t
.
integer
"owner_id"
t
.
integer
"owner_id"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
end
end
create_table
"users"
,
force: :cascade
do
|
t
|
create_table
"users"
,
force: :cascade
do
|
t
|
t
.
string
"provider"
,
default:
"email"
,
null:
false
t
.
string
"provider"
,
default:
"email"
,
null:
false
t
.
string
"uid"
,
default:
""
,
null:
false
t
.
string
"uid"
,
default:
""
,
null:
false
t
.
string
"encrypted_password"
,
default:
""
t
.
string
"encrypted_password"
,
default:
""
t
.
string
"reset_password_token"
t
.
string
"reset_password_token"
t
.
datetime
"reset_password_sent_at"
t
.
datetime
"reset_password_sent_at"
t
.
datetime
"remember_created_at"
t
.
datetime
"remember_created_at"
t
.
integer
"sign_in_count"
,
default:
0
,
null:
false
t
.
integer
"sign_in_count"
,
default:
0
,
null:
false
t
.
datetime
"current_sign_in_at"
t
.
datetime
"current_sign_in_at"
t
.
datetime
"last_sign_in_at"
t
.
datetime
"last_sign_in_at"
t
.
string
"current_sign_in_ip"
t
.
string
"current_sign_in_ip"
t
.
string
"last_sign_in_ip"
t
.
string
"last_sign_in_ip"
t
.
string
"confirmation_token"
t
.
string
"confirmation_token"
t
.
datetime
"confirmed_at"
t
.
datetime
"confirmed_at"
t
.
datetime
"confirmation_sent_at"
t
.
datetime
"confirmation_sent_at"
t
.
string
"unconfirmed_email"
t
.
string
"unconfirmed_email"
t
.
string
"first_name"
t
.
string
"first_name"
t
.
string
"last_name"
t
.
string
"last_name"
t
.
string
"email"
t
.
string
"email"
t
.
text
"tokens"
t
.
text
"tokens"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
string
"invitation_token"
t
.
string
"invitation_token"
t
.
datetime
"invitation_created_at"
t
.
datetime
"invitation_created_at"
t
.
datetime
"invitation_sent_at"
t
.
datetime
"invitation_sent_at"
t
.
datetime
"invitation_accepted_at"
t
.
datetime
"invitation_accepted_at"
t
.
integer
"invitation_limit"
t
.
integer
"invitation_limit"
t
.
integer
"invited_by_id"
t
.
integer
"invited_by_id"
t
.
string
"invited_by_type"
t
.
string
"invited_by_type"
t
.
string
"invitation_url"
t
.
string
"invitation_url"
t
.
index
[
"confirmation_token"
],
name:
"index_users_on_confirmation_token"
,
unique:
true
t
.
index
[
"confirmation_token"
],
name:
"index_users_on_confirmation_token"
,
unique:
true
t
.
index
[
"email"
],
name:
"index_users_on_email"
,
unique:
true
t
.
index
[
"email"
],
name:
"index_users_on_email"
,
unique:
true
t
.
index
[
"invitation_token"
],
name:
"index_users_on_invitation_token"
,
unique:
true
t
.
index
[
"invitation_token"
],
name:
"index_users_on_invitation_token"
,
unique:
true
...
...
spec/controllers/data_views_controller_spec.rb
View file @
5d4a5f51
...
@@ -17,25 +17,24 @@ RSpec.describe DataViewsController, type: :request do
...
@@ -17,25 +17,24 @@ RSpec.describe DataViewsController, type: :request do
other_stream
=
create
(
:db_stream
,
db:
other_db
)
other_stream
=
create
(
:db_stream
,
db:
other_db
)
other_user
=
create
(
:user
)
other_user
=
create
(
:user
)
service
=
CreateDataView
.
new
service
=
CreateDataView
.
new
allowed_view
=
service
.
run
(
service
.
run
(
{
name:
'allowed'
},
[
viewed_streams
.
first
.
id
],
other_user
)
{
name:
'allowed'
,
visibility:
'public'
},
[
viewed_streams
.
first
.
id
],
other_user
)
prohibited_view
=
service
.
run
(
service
.
run
(
{
name:
'prohibited'
},
[
other_stream
.
id
],
other_user
)
{
name:
'prohibited'
,
visibility:
'public'
},
[
other_stream
.
id
],
other_user
)
my_view
=
service
.
run
(
service
.
run
(
{
name:
'created'
},
viewed_streams
.
map
{
|
x
|
x
.
id
},
viewer
)
{
name:
'private'
,
visibility:
'private'
},
[
viewed_streams
.
first
.
id
],
other_user
)
service
.
run
(
{
name:
'my_public'
,
visibility:
'public'
},
viewed_streams
.
map
{
|
x
|
x
.
id
},
viewer
)
service
.
run
(
{
name:
'my_private'
,
visibility:
'private'
},
viewed_streams
.
map
{
|
x
|
x
.
id
},
viewer
)
#viewer should receive 'allowed' and 'created'
#viewer should receive 'allowed' and 'created'
@auth_headers
=
viewer
.
create_new_auth_token
@auth_headers
=
viewer
.
create_new_auth_token
get
"/data_views.json"
,
headers:
@auth_headers
get
"/data_views.json"
,
headers:
@auth_headers
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
body
=
JSON
.
parse
(
response
.
body
)
body
=
JSON
.
parse
(
response
.
body
)
expect
(
body
.
length
).
to
eq
2
names
=
body
.
map
{
|
view
|
view
[
'name'
]}
body
.
each
do
|
view
|
expect
(
names
).
to
contain_exactly
(
'allowed'
,
'my_public'
,
'my_private'
)
if
view
[
'name'
]
==
'created'
expect
(
view
[
'owner'
]).
to
be
true
else
expect
(
view
[
'owner'
]).
to
be
false
end
end
end
end
end
end
context
'without sign-in'
do
context
'without sign-in'
do
...
@@ -53,7 +52,7 @@ RSpec.describe DataViewsController, type: :request do
...
@@ -53,7 +52,7 @@ RSpec.describe DataViewsController, type: :request do
post
"/data_views.json"
,
post
"/data_views.json"
,
params:
{
params:
{
name:
'test'
,
description:
''
,
image:
''
,
redux_json:
''
,
name:
'test'
,
description:
''
,
image:
''
,
redux_json:
''
,
stream_ids:
viewed_streams
.
map
{
|
x
|
x
.
id
}
visibility:
'public'
,
stream_ids:
viewed_streams
.
map
{
|
x
|
x
.
id
}
},
headers:
@auth_headers
},
headers:
@auth_headers
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_notice_message
expect
(
response
).
to
have_notice_message
...
@@ -66,7 +65,7 @@ RSpec.describe DataViewsController, type: :request do
...
@@ -66,7 +65,7 @@ RSpec.describe DataViewsController, type: :request do
post
"/data_views.json"
,
post
"/data_views.json"
,
params:
{
params:
{
description:
'missing name'
,
image:
''
,
redux_json:
''
,
description:
'missing name'
,
image:
''
,
redux_json:
''
,
stream_ids:
viewed_streams
.
map
{
|
x
|
x
.
id
}
visibility:
'public'
,
stream_ids:
viewed_streams
.
map
{
|
x
|
x
.
id
}
},
headers:
@auth_headers
},
headers:
@auth_headers
expect
(
response
).
to
have_http_status
(
:unprocessable_entity
)
expect
(
response
).
to
have_http_status
(
:unprocessable_entity
)
expect
(
response
).
to
have_error_message
expect
(
response
).
to
have_error_message
...
@@ -84,7 +83,7 @@ RSpec.describe DataViewsController, type: :request do
...
@@ -84,7 +83,7 @@ RSpec.describe DataViewsController, type: :request do
before
do
before
do
service
=
CreateDataView
.
new
service
=
CreateDataView
.
new
service
.
run
(
service
.
run
(
{
name:
'created'
},
viewed_streams
.
map
{
|
x
|
x
.
id
},
viewer
)
{
name:
'created'
,
visibility:
'public'
},
viewed_streams
.
map
{
|
x
|
x
.
id
},
viewer
)
@my_view
=
service
.
data_view
@my_view
=
service
.
data_view
end
end
context
'with view owner'
do
context
'with view owner'
do
...
...
spec/factories/data_views.rb
View file @
5d4a5f51
...
@@ -2,6 +2,7 @@ FactoryGirl.define do
...
@@ -2,6 +2,7 @@ FactoryGirl.define do
factory
:data_view
do
factory
:data_view
do
name
{
Faker
::
Lorem
.
words
(
3
).
join
(
' '
)
}
name
{
Faker
::
Lorem
.
words
(
3
).
join
(
' '
)
}
description
{
Faker
::
Lorem
.
sentence
}
description
{
Faker
::
Lorem
.
sentence
}
visibility
"public"
redux_json
"auto generated from factory"
redux_json
"auto generated from factory"
end
end
end
end
spec/models/data_view_spec.rb
View file @
5d4a5f51
...
@@ -8,6 +8,7 @@ RSpec.describe DataView, type: :model do
...
@@ -8,6 +8,7 @@ RSpec.describe DataView, type: :model do
specify
{
expect
(
data_view
).
to
respond_to
(
:redux_json
)
}
specify
{
expect
(
data_view
).
to
respond_to
(
:redux_json
)
}
specify
{
expect
(
data_view
).
to
respond_to
(
:owner
)
}
specify
{
expect
(
data_view
).
to
respond_to
(
:owner
)
}
specify
{
expect
(
data_view
).
to
respond_to
(
:nilms
)
}
specify
{
expect
(
data_view
).
to
respond_to
(
:nilms
)
}
specify
{
expect
(
data_view
).
to
respond_to
(
:visibility
)
}
it
'is deleted when nilm is destroyed'
do
it
'is deleted when nilm is destroyed'
do
nilm1
=
create
(
:nilm
)
nilm1
=
create
(
:nilm
)
...
...
spec/services/data_view/create_data_view_spec.rb
View file @
5d4a5f51
...
@@ -13,6 +13,7 @@ describe 'CreateDataView service' do
...
@@ -13,6 +13,7 @@ describe 'CreateDataView service' do
it
'creates a dataview'
do
it
'creates a dataview'
do
params
=
{
params
=
{
name:
'test'
,
name:
'test'
,
visibility:
'public'
,
description:
''
,
description:
''
,
image:
''
,
image:
''
,
redux_json:
''
}
redux_json:
''
}
...
...
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