From 6148fd30fd8254a2400df3ed33ee21705803a5b0 Mon Sep 17 00:00:00 2001 From: stephanie rousset Date: Wed, 13 May 2026 14:57:44 +0200 Subject: [PATCH 1/2] fix: add context to ResponseForm --- decidim-forms/app/forms/decidim/forms/questionnaire_form.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decidim-forms/app/forms/decidim/forms/questionnaire_form.rb b/decidim-forms/app/forms/decidim/forms/questionnaire_form.rb index 5832dce44011a..f8c40ed500ed1 100644 --- a/decidim-forms/app/forms/decidim/forms/questionnaire_form.rb +++ b/decidim-forms/app/forms/decidim/forms/questionnaire_form.rb @@ -30,7 +30,7 @@ def map_model(model) def add_responses!(questionnaire:, session_token:, ip_hash:) self.responses = questionnaire.questions.map do |question| - ResponseForm.from_model(Decidim::Forms::Response.where(question:, user: current_user, session_token:, ip_hash:).first_or_initialize) + ResponseForm.from_model(Decidim::Forms::Response.where(question:, user: current_user, session_token:, ip_hash:).first_or_initialize).with_context(context) end end From f6722298b8782f3df113f788a03f7b983fe082b1 Mon Sep 17 00:00:00 2001 From: stephanie rousset Date: Wed, 13 May 2026 14:58:38 +0200 Subject: [PATCH 2/2] test: edit responses with condition question --- decidim-surveys/spec/system/survey_spec.rb | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/decidim-surveys/spec/system/survey_spec.rb b/decidim-surveys/spec/system/survey_spec.rb index a4e2f14d90a61..71c4385a597dd 100644 --- a/decidim-surveys/spec/system/survey_spec.rb +++ b/decidim-surveys/spec/system/survey_spec.rb @@ -198,6 +198,42 @@ it_behaves_like "has embedded video in description", :question_description end end + + context "when the survey allows to edit responses, and question has display conditions" do + let!(:question_two) do + create(:questionnaire_question, + questionnaire:, + question_type: "short_response", + position: 1, + options: []) + end + let!(:display_condition) do + create(:display_condition, + condition_type: "not_responded", + question: question_two, + condition_question: question) + end + + before do + survey.update!( + allow_responses: true, + allow_editing_responses: true + ) + login_as user, scope: :user + visit_component + click_on translated_attribute(questionnaire.title) + fill_in "questionnaire_responses_0", with: "test" + check "questionnaire_tos_agreement" + click_on "Submit" + expect(page).to have_callout("Survey successfully responded.") + end + + it "allows to edit the responses" do + click_on "Edit your responses" + expect(page).to have_content(translated_attribute(survey.title)) + expect(page).to have_content(translated_attribute(question.body)) + end + end end context "when survey has a custom announcement" do