From 4d238c5d078460880cdf9d892316b32a8d9e24a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 6 Sep 2018 13:12:50 +0200 Subject: [PATCH] Fix crash updating legislation process categories We were expecting translation parameters in legislation processes `update` action. However, those parameters aren't sent when we get to that action through the "proposals" tab. --- app/controllers/concerns/translatable.rb | 2 ++ spec/features/admin/legislation/processes_spec.rb | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/app/controllers/concerns/translatable.rb b/app/controllers/concerns/translatable.rb index aecf42fb4..b75d242c0 100644 --- a/app/controllers/concerns/translatable.rb +++ b/app/controllers/concerns/translatable.rb @@ -8,6 +8,8 @@ module Translatable private def translation_params(resource_model) + return [] unless params[:enabled_translations] + resource_model.translated_attribute_names.product(enabled_translations).map do |attr_name, loc| resource_model.localized_attr_name_for(attr_name, loc) end diff --git a/spec/features/admin/legislation/processes_spec.rb b/spec/features/admin/legislation/processes_spec.rb index 1fee8cbf0..47aff8078 100644 --- a/spec/features/admin/legislation/processes_spec.rb +++ b/spec/features/admin/legislation/processes_spec.rb @@ -130,5 +130,16 @@ feature 'Admin legislation processes' do expect(page).not_to have_content 'Draft publication' end + + scenario "Change proposal categories" do + visit edit_admin_legislation_process_path(process) + within(".admin-content") { click_link "Proposals" } + + fill_in "Categories", with: "recycling,bicycles" + click_button "Save changes" + + visit admin_legislation_process_proposals_path(process) + expect(page).to have_field("Categories", with: "bicycles, recycling") + end end end