diff --git a/README.md b/README.md index 7d9a1cc..6937b7d 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ [![Maintainability](https://api.codeclimate.com/v1/badges/62f4dd4fb092b4211973/maintainability)](https://codeclimate.com/repos/65caed0abc0d27237b1794c9/maintainability) ![rubocop](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/barnden/c7b2d5e19079e12445b300407e383294/raw/badge.json) +**All project files in rails_root** + Links - Deployed Application - https://elrc-app-dfcfc7cd862b.herokuapp.com/ diff --git a/rails_root/.rubocop.yml b/rails_root/.rubocop.yml index 55bde9e..0272825 100644 --- a/rails_root/.rubocop.yml +++ b/rails_root/.rubocop.yml @@ -2,6 +2,7 @@ # ignore migration files AllCops: + DisabledByDefault: false Exclude: - 'db/**/*' - 'config/**/*' diff --git a/rails_root/app/controllers/survey_responses_controller.rb b/rails_root/app/controllers/survey_responses_controller.rb index 759ef0d..450f77d 100644 --- a/rails_root/app/controllers/survey_responses_controller.rb +++ b/rails_root/app/controllers/survey_responses_controller.rb @@ -48,13 +48,15 @@ def edit # POST /survey_responses or /survey_responses.json def create - if survey_response_params.values.any? { |value| value.nil? || value.empty? } + # If any of the survey_response_params values are nil, then the form is invalid + if survey_response_params.values.any? { |value| value.nil? || value.empty? || survey_response_params.keys.length != SurveyResponse.column_names.length - 3 } respond_to do |format| format.html do redirect_to new_survey_response_url, notice: 'invalid form', status: :unprocessable_entity end format.json { render json: { error: 'invalid form' }, status: :unprocessable_entity } end + else @survey_response = SurveyResponse.new(survey_response_params) diff --git a/rails_root/features/step_definitions/stepdefs.rb b/rails_root/features/step_definitions/stepdefs.rb index 8699089..e48d5a3 100644 --- a/rails_root/features/step_definitions/stepdefs.rb +++ b/rails_root/features/step_definitions/stepdefs.rb @@ -49,7 +49,7 @@ When('I try to create model instances') do post survey_profiles_url, survey_profile: @survey_profiles_attributes - post survey_responses_url, survey_response: @survey_profiles_attributes + post survey_responses_url, survey_response: @survey_responses_attributes end Given('I have a set of valid attributes') do