Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
36 changes: 36 additions & 0 deletions decidim-surveys/spec/system/survey_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading