Fix legislation options not being updated
We broke this behaviour by introducing translations and not allowing the `id` parameter anymore.
This commit is contained in:
@@ -47,7 +47,7 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll
|
||||
def question_params
|
||||
params.require(:legislation_question).permit(
|
||||
translation_params(::Legislation::Question),
|
||||
question_options_attributes: [translation_params(::Legislation::QuestionOption)])
|
||||
question_options_attributes: [:id, translation_params(::Legislation::QuestionOption)])
|
||||
end
|
||||
|
||||
def resource
|
||||
|
||||
@@ -113,11 +113,8 @@ feature 'Admin legislation questions' do
|
||||
end
|
||||
end
|
||||
|
||||
context "Special translation behaviour" do
|
||||
|
||||
let!(:question) { create(:legislation_question,
|
||||
title_en: "Title in English",
|
||||
title_es: "Título en Español") }
|
||||
context "Legislation options" do
|
||||
let!(:question) { create(:legislation_question) }
|
||||
|
||||
let(:edit_question_url) do
|
||||
edit_admin_legislation_process_question_path(question.process, question)
|
||||
@@ -132,6 +129,24 @@ feature 'Admin legislation questions' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Edit an existing option", :js do
|
||||
create(:legislation_question_option, question: question, value: "Original")
|
||||
|
||||
visit edit_question_url
|
||||
find("#nested-question-options input").set("Changed")
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).not_to have_css "#error_explanation"
|
||||
|
||||
visit edit_question_url
|
||||
expect(page).to have_field(field_en[:id], with: "Changed")
|
||||
end
|
||||
|
||||
context "Special translation behaviour" do
|
||||
before do
|
||||
question.update_attributes(title_en: "Title in English", title_es: "Título en Español")
|
||||
end
|
||||
|
||||
scenario 'Add translation for question option', :js do
|
||||
visit edit_question_url
|
||||
|
||||
@@ -177,4 +192,5 @@ feature 'Admin legislation questions' do
|
||||
expect(page).to have_field(field_es[:id], with: 'Opción 1')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user