Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Citizen science #381

Merged
merged 11 commits into from
Mar 13, 2019
Merged

Citizen science #381

merged 11 commits into from
Mar 13, 2019

Conversation

peichins
Copy link
Member

closes #346
All tests passing

Copy link
Member

@atruskie atruskie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall a great set of changes.

Some minor nitpicks need to be addressed.


render_error(
:method_not_allowed,
'HTTP method not allowed for this resource.2',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'HTTP method not allowed for this resource.2',
'HTTP method not allowed for this resource.,

:method_not_allowed,
'HTTP method not allowed for this resource.2',
nil,
'method_not_allowed_error_1',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the _1 suffix denote? Choose a better name please


def question_params
# empty array is replaced with nil by rails. Revert to empty array
# to avoid errors with strong parameters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add in that link to the rails issue that describes this problem and the recommended work around?


@responses, opts = Settings.api_response.response_advanced(
api_filter_params,
Access::ByPermission.responses(current_user, params[:study_id]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if params[:study_id] is nil is that a problem?

You special-cased it in the Questions controller

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was only a problem in questions because it was an array (due to HABTM).


def response_params
# params[:response] = params[:response] || {}
# params[:response][:study_id] = params[:study_id]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General comment:

Code is commented out with no space:

#variable = value

Comments are space separated.

Is this code or a comment? It looks like code, formatted like a comment, but to my limited understanding imparts no meaning. Please clarify

create_entire_hierarchy

describe "GET #index" do
it "returns http success" do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the next three test cases seem to have mislabeled descriptions with their results.

also, why do we expect 401 responses here?

@@ -0,0 +1,54 @@
require 'rails_helper'

describe QuestionsController, type: :controller do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't really determine the point of this class.

Can you add one line of comment context to each controller test explaining why/what we are testing?

@@ -0,0 +1,43 @@
require 'rails_helper'

describe ResponsesController, type: :controller do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comments as previous for controller specs: add context and fix string labels mismatching with tests

it { expect(post('/studies/filter')).to route_to('studies#filter', format: 'json') }
it { expect(post('/studies')).to route_to('studies#create', format: 'json') }
it { expect(put('/studies/1')).to route_to('studies#update', id: '1', format: 'json') }
it { expect(delete('/studies/1')).to route_to('studies#destroy', id: '1', format: 'json') }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the controller, there were comments suggesting questions and responses can be nested under studies. please add route tests for the nested routed.

resources :responses, except: :update, defaults: {format: 'json'}
get '/studies/:study_id/questions' => 'questions#index', defaults: {format: 'json'}
get '/studies/:study_id/responses' => 'responses#index', defaults: {format: 'json'}
post '/studies/:study_id/questions/:question_id/responses' => 'responses#create', defaults: {format: 'json'}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please redefine this whole block of routes in terms of resources definitions, as is the style in the rest of this file

@atruskie atruskie merged commit d69a299 into develop Mar 13, 2019
@atruskie atruskie deleted the citizen-science branch July 24, 2020 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update database schema to accommodate citizen science
2 participants