diff --git a/app/controllers/waste_carriers_engine/business_type_forms_controller.rb b/app/controllers/waste_carriers_engine/business_type_forms_controller.rb index 77cd0b9f8..b3a419d37 100644 --- a/app/controllers/waste_carriers_engine/business_type_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/business_type_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:business_type_form).permit(:business_type, :reg_identifier) + params.fetch(:business_type_form, {}).permit(:business_type, :reg_identifier) end end end diff --git a/app/controllers/waste_carriers_engine/cards_forms_controller.rb b/app/controllers/waste_carriers_engine/cards_forms_controller.rb index fb0723895..a2b4e3e70 100644 --- a/app/controllers/waste_carriers_engine/cards_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/cards_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:cards_form).permit(:temp_cards) + params.fetch(:cards_form, {}).permit(:temp_cards) end end end diff --git a/app/controllers/waste_carriers_engine/cbd_type_forms_controller.rb b/app/controllers/waste_carriers_engine/cbd_type_forms_controller.rb index 0a785d917..958d5a3c7 100644 --- a/app/controllers/waste_carriers_engine/cbd_type_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/cbd_type_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:cbd_type_form).permit(:registration_type) + params.fetch(:cbd_type_form, {}).permit(:registration_type) end end end diff --git a/app/controllers/waste_carriers_engine/company_name_forms_controller.rb b/app/controllers/waste_carriers_engine/company_name_forms_controller.rb index 44d5ef5b4..68ec018e0 100644 --- a/app/controllers/waste_carriers_engine/company_name_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/company_name_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:company_name_form).permit(:company_name) + params.fetch(:company_name_form, {}).permit(:company_name) end end end diff --git a/app/controllers/waste_carriers_engine/company_postcode_forms_controller.rb b/app/controllers/waste_carriers_engine/company_postcode_forms_controller.rb index 903cf372f..5d8e15b4c 100644 --- a/app/controllers/waste_carriers_engine/company_postcode_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/company_postcode_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:company_postcode_form).permit(:temp_company_postcode) + params.fetch(:company_postcode_form, {}).permit(:temp_company_postcode) end end end diff --git a/app/controllers/waste_carriers_engine/construction_demolition_forms_controller.rb b/app/controllers/waste_carriers_engine/construction_demolition_forms_controller.rb index bbc9a7d97..d678e0304 100644 --- a/app/controllers/waste_carriers_engine/construction_demolition_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/construction_demolition_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:construction_demolition_form).permit(:construction_waste) + params.fetch(:construction_demolition_form, {}).permit(:construction_waste) end end end diff --git a/app/controllers/waste_carriers_engine/contact_email_forms_controller.rb b/app/controllers/waste_carriers_engine/contact_email_forms_controller.rb index 5e54080d6..e2ebcaa74 100644 --- a/app/controllers/waste_carriers_engine/contact_email_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/contact_email_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:contact_email_form).permit(:contact_email, :confirmed_email) + params.fetch(:contact_email_form, {}).permit(:contact_email, :confirmed_email) end end end diff --git a/app/controllers/waste_carriers_engine/contact_name_forms_controller.rb b/app/controllers/waste_carriers_engine/contact_name_forms_controller.rb index a8c4df172..5826d8191 100644 --- a/app/controllers/waste_carriers_engine/contact_name_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/contact_name_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:contact_name_form).permit(:first_name, :last_name) + params.fetch(:contact_name_form, {}).permit(:first_name, :last_name) end end end diff --git a/app/controllers/waste_carriers_engine/contact_phone_forms_controller.rb b/app/controllers/waste_carriers_engine/contact_phone_forms_controller.rb index 25c4c6c00..b973194c5 100644 --- a/app/controllers/waste_carriers_engine/contact_phone_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/contact_phone_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:contact_phone_form).permit(:phone_number) + params.fetch(:contact_phone_form, {}).permit(:phone_number) end end end diff --git a/app/controllers/waste_carriers_engine/contact_postcode_forms_controller.rb b/app/controllers/waste_carriers_engine/contact_postcode_forms_controller.rb index 1a6e7a387..a84833910 100644 --- a/app/controllers/waste_carriers_engine/contact_postcode_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/contact_postcode_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:contact_postcode_form).permit(:temp_contact_postcode) + params.fetch(:contact_postcode_form, {}).permit(:temp_contact_postcode) end end end diff --git a/app/controllers/waste_carriers_engine/declaration_forms_controller.rb b/app/controllers/waste_carriers_engine/declaration_forms_controller.rb index c7b2c7207..63bc196bb 100644 --- a/app/controllers/waste_carriers_engine/declaration_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/declaration_forms_controller.rb @@ -16,7 +16,7 @@ def create private def transient_registration_attributes - params.require(:declaration_form).permit(:declaration) + params.fetch(:declaration_form, {}).permit(:declaration) end end end diff --git a/app/controllers/waste_carriers_engine/declare_convictions_forms_controller.rb b/app/controllers/waste_carriers_engine/declare_convictions_forms_controller.rb index 8a90658ea..267099adf 100644 --- a/app/controllers/waste_carriers_engine/declare_convictions_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/declare_convictions_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:declare_convictions_form).permit(:declared_convictions) + params.fetch(:declare_convictions_form, {}).permit(:declared_convictions) end end end diff --git a/app/controllers/waste_carriers_engine/location_forms_controller.rb b/app/controllers/waste_carriers_engine/location_forms_controller.rb index 7b6c6c509..dcdc76be5 100644 --- a/app/controllers/waste_carriers_engine/location_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/location_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:location_form).permit(:location) + params.fetch(:location_form, {}).permit(:location) end end end diff --git a/app/controllers/waste_carriers_engine/other_businesses_forms_controller.rb b/app/controllers/waste_carriers_engine/other_businesses_forms_controller.rb index 0e0471438..17543a045 100644 --- a/app/controllers/waste_carriers_engine/other_businesses_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/other_businesses_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:other_businesses_form).permit(:other_businesses) + params.fetch(:other_businesses_form, {}).permit(:other_businesses) end end end diff --git a/app/controllers/waste_carriers_engine/registration_number_forms_controller.rb b/app/controllers/waste_carriers_engine/registration_number_forms_controller.rb index 6f63b699e..3e91c5b33 100644 --- a/app/controllers/waste_carriers_engine/registration_number_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/registration_number_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:registration_number_form).permit(:company_no) + params.fetch(:registration_number_form, {}).permit(:company_no) end end end diff --git a/app/controllers/waste_carriers_engine/service_provided_forms_controller.rb b/app/controllers/waste_carriers_engine/service_provided_forms_controller.rb index 9281152c3..f2672805f 100644 --- a/app/controllers/waste_carriers_engine/service_provided_forms_controller.rb +++ b/app/controllers/waste_carriers_engine/service_provided_forms_controller.rb @@ -13,7 +13,7 @@ def create private def transient_registration_attributes - params.require(:service_provided_form).permit(:is_main_service) + params.fetch(:service_provided_form, {}).permit(:is_main_service) end end end diff --git a/spec/support/shared_examples/request_post_form.rb b/spec/support/shared_examples/post_form.rb similarity index 95% rename from spec/support/shared_examples/request_post_form.rb rename to spec/support/shared_examples/post_form.rb index 57317f421..21444af72 100644 --- a/spec/support/shared_examples/request_post_form.rb +++ b/spec/support/shared_examples/post_form.rb @@ -94,6 +94,16 @@ end end + context "when the params are empty" do + it "does not throw an error" do + # rubocop:disable Style/BlockDelimiters + expect { + post_with_params(form, reg_identifier: transient_registration.reg_identifier) + }.not_to raise_error + # rubocop:enable Style/BlockDelimiters + end + end + context "when the reg_identifier is invalid" do before do valid_params[:reg_identifier] = "foo"