decidim-forms 0.30.2 → 0.31.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -10
- data/app/cells/decidim/forms/matrix_readonly/show.erb +1 -1
- data/app/cells/decidim/forms/matrix_readonly_cell.rb +3 -3
- data/app/cells/decidim/forms/question_readonly/show.erb +5 -5
- data/app/cells/decidim/forms/question_readonly/title_and_description.erb +3 -3
- data/app/cells/decidim/forms/response_readonly_cell.rb +9 -0
- data/app/cells/decidim/forms/step_navigation/show.erb +3 -3
- data/app/cells/decidim/forms/step_navigation_cell.rb +3 -3
- data/app/commands/decidim/forms/admin/update_questions.rb +6 -6
- data/app/commands/decidim/forms/{answer_questionnaire.rb → response_questionnaire.rb} +35 -35
- data/app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb +12 -12
- data/app/controllers/decidim/forms/admin/concerns/{has_questionnaire_answers.rb → has_questionnaire_responses.rb} +23 -19
- data/app/controllers/decidim/forms/concerns/has_questionnaire.rb +38 -33
- data/app/forms/decidim/forms/admin/display_condition_form.rb +14 -14
- data/app/forms/decidim/forms/admin/question_form.rb +3 -3
- data/app/forms/decidim/forms/admin/{answer_option_form.rb → response_option_form.rb} +3 -3
- data/app/forms/decidim/forms/questionnaire_form.rb +8 -9
- data/app/forms/decidim/forms/{answer_choice_form.rb → response_choice_form.rb} +5 -5
- data/app/forms/decidim/forms/{answer_form.rb → response_form.rb} +9 -9
- data/app/helpers/decidim/forms/admin/application_helper.rb +2 -2
- data/app/helpers/decidim/forms/admin/concerns/{has_questionnaire_answers_pagination_helper.rb → has_questionnaire_responses_pagination_helper.rb} +4 -4
- data/app/helpers/decidim/forms/admin/concerns/{has_questionnaire_answers_url_helper.rb → has_questionnaire_responses_url_helper.rb} +5 -5
- data/app/helpers/decidim/forms/admin/questionnaire_responses_helper.rb +32 -0
- data/app/helpers/decidim/forms/application_helper.rb +1 -2
- data/app/jobs/decidim/forms/{export_questionnaire_answers_job.rb → export_questionnaire_responses_job.rb} +5 -5
- data/app/models/decidim/forms/display_condition.rb +20 -20
- data/app/models/decidim/forms/question.rb +14 -13
- data/app/models/decidim/forms/question_matrix_row.rb +1 -1
- data/app/models/decidim/forms/questionnaire.rb +11 -6
- data/app/models/decidim/forms/{answer.rb → response.rb} +9 -9
- data/app/models/decidim/forms/response_choice.rb +22 -0
- data/app/models/decidim/forms/{answer_option.rb → response_option.rb} +5 -5
- data/app/packs/entrypoints/decidim_forms_admin.js +3 -3
- data/app/packs/src/decidim/forms/admin/collapsible_questions.js +12 -10
- data/app/packs/src/decidim/forms/admin/forms.js +35 -35
- data/app/packs/src/decidim/forms/admin/{publish_answers_buttons.js → publish_responses_buttons.js} +12 -12
- data/app/packs/src/decidim/forms/display_conditions.component.js +12 -12
- data/app/packs/src/decidim/forms/forms.js +4 -4
- data/app/packs/stylesheets/decidim/forms/forms.scss +2 -2
- data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +13 -13
- data/app/presenters/decidim/forms/admin/{questionnaire_answer_presenter.rb → questionnaire_response_presenter.rb} +15 -15
- data/app/presenters/decidim/forms/admin_log/question_presenter.rb +3 -3
- data/app/presenters/decidim/forms/{answer_option_presenter.rb → response_option_presenter.rb} +2 -2
- data/app/queries/decidim/forms/questionnaire_participant.rb +5 -5
- data/app/queries/decidim/forms/questionnaire_participants.rb +6 -6
- data/app/queries/decidim/forms/questionnaire_user_responses.rb +32 -0
- data/app/views/decidim/forms/admin/questionnaires/_display_condition.html.erb +9 -9
- data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +2 -2
- data/app/views/decidim/forms/admin/questionnaires/_matrix_row.html.erb +3 -3
- data/app/views/decidim/forms/admin/questionnaires/_question.html.erb +16 -16
- data/app/views/decidim/forms/admin/questionnaires/_questions_form.html.erb +11 -10
- data/app/views/decidim/forms/admin/questionnaires/{_answer_option.html.erb → _response_option.html.erb} +7 -7
- data/app/views/decidim/forms/admin/questionnaires/_response_option_template.html.erb +7 -0
- data/app/views/decidim/forms/admin/questionnaires/_separator.html.erb +10 -7
- data/app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb +7 -7
- data/app/views/decidim/forms/admin/questionnaires/edit.html.erb +1 -1
- data/app/views/decidim/forms/admin/questionnaires/edit_questions.html.erb +8 -8
- data/app/views/decidim/forms/admin/questionnaires/responses/index.html.erb +80 -0
- data/app/views/decidim/forms/admin/questionnaires/responses/show.html.erb +43 -0
- data/app/views/decidim/forms/questionnaires/_questionnaire.html.erb +22 -26
- data/app/views/decidim/forms/questionnaires/_questionnaire_readonly.html.erb +8 -3
- data/app/views/decidim/forms/questionnaires/_response.html.erb +61 -0
- data/app/views/decidim/forms/questionnaires/edit.html.erb +2 -2
- data/app/views/decidim/forms/questionnaires/responses/_files.html.erb +1 -0
- data/app/views/decidim/forms/questionnaires/responses/_long_response.html.erb +3 -0
- data/app/views/decidim/forms/questionnaires/{answers → responses}/_matrix_multiple.html.erb +16 -15
- data/app/views/decidim/forms/questionnaires/{answers → responses}/_matrix_single.html.erb +17 -16
- data/app/views/decidim/forms/questionnaires/responses/_multiple_option.html.erb +26 -0
- data/app/views/decidim/forms/questionnaires/responses/_separator.html.erb +1 -0
- data/app/views/decidim/forms/questionnaires/responses/_short_response.html.erb +3 -0
- data/app/views/decidim/forms/questionnaires/responses/_single_option.html.erb +33 -0
- data/app/views/decidim/forms/questionnaires/responses/_sorting.html.erb +26 -0
- data/app/views/decidim/forms/questionnaires/responses/_title_and_description.html.erb +1 -0
- data/app/views/decidim/forms/questionnaires/show.html.erb +10 -10
- data/config/assets.rb +2 -2
- data/config/locales/ar.yml +0 -22
- data/config/locales/bg.yml +3 -36
- data/config/locales/ca-IT.yml +73 -73
- data/config/locales/ca.yml +73 -73
- data/config/locales/cs.yml +72 -75
- data/config/locales/de.yml +72 -72
- data/config/locales/el.yml +3 -36
- data/config/locales/en.yml +83 -83
- data/config/locales/es-MX.yml +75 -75
- data/config/locales/es-PY.yml +75 -75
- data/config/locales/es.yml +73 -73
- data/config/locales/eu.yml +71 -71
- data/config/locales/fi-plain.yml +71 -71
- data/config/locales/fi.yml +69 -69
- data/config/locales/fr-CA.yml +70 -67
- data/config/locales/fr.yml +70 -67
- data/config/locales/ga-IE.yml +0 -7
- data/config/locales/gl.yml +0 -22
- data/config/locales/hu.yml +0 -22
- data/config/locales/id-ID.yml +0 -22
- data/config/locales/it.yml +3 -40
- data/config/locales/ja.yml +80 -80
- data/config/locales/lb.yml +3 -36
- data/config/locales/lt.yml +3 -36
- data/config/locales/lv.yml +0 -22
- data/config/locales/nl.yml +3 -36
- data/config/locales/no.yml +3 -36
- data/config/locales/pl.yml +3 -36
- data/config/locales/pt-BR.yml +3 -36
- data/config/locales/pt.yml +3 -36
- data/config/locales/ro-RO.yml +22 -51
- data/config/locales/ru.yml +0 -9
- data/config/locales/sk.yml +0 -22
- data/config/locales/sl.yml +0 -5
- data/config/locales/sv.yml +82 -54
- data/config/locales/tr-TR.yml +3 -36
- data/config/locales/zh-CN.yml +3 -36
- data/config/locales/zh-TW.yml +3 -36
- data/db/migrate/20190315203056_add_session_token_to_decidim_forms_answers.rb +1 -1
- data/db/migrate/20250314150250_rename_answer_to_response_in_decidim_forms.rb +30 -0
- data/db/migrate/20250319130003_change_question_types_in_questions.rb +14 -0
- data/lib/decidim/api/question_matrix_row_type.rb +13 -0
- data/lib/decidim/api/question_type.rb +4 -3
- data/lib/decidim/api/questionnaire_type.rb +1 -0
- data/lib/decidim/api/response_option_type.rb +13 -0
- data/lib/decidim/exporters/form_pdf.rb +33 -33
- data/lib/decidim/forms/api.rb +2 -1
- data/lib/decidim/forms/{download_your_data_user_answers_serializer.rb → download_your_data_user_responses_serializer.rb} +3 -3
- data/lib/decidim/forms/engine.rb +2 -2
- data/lib/decidim/forms/test/factories.rb +24 -24
- data/lib/decidim/forms/test/shared_examples/has_questionnaire.rb +176 -176
- data/lib/decidim/forms/test/shared_examples/manage_questionnaire_responses.rb +159 -0
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_display_conditions.rb +19 -19
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +44 -44
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb +10 -10
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +18 -18
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +4 -4
- data/lib/decidim/forms/test.rb +1 -1
- data/lib/decidim/forms/user_responses_serializer.rb +110 -0
- data/lib/decidim/forms/version.rb +1 -1
- data/lib/decidim/forms.rb +2 -2
- metadata +48 -45
- data/app/cells/decidim/forms/answer_readonly_cell.rb +0 -9
- data/app/helpers/decidim/forms/admin/questionnaire_answers_helper.rb +0 -30
- data/app/models/decidim/forms/answer_choice.rb +0 -22
- data/app/queries/decidim/forms/questionnaire_user_answers.rb +0 -32
- data/app/views/decidim/forms/admin/questionnaires/_answer_option_template.html.erb +0 -7
- data/app/views/decidim/forms/admin/questionnaires/answers/index.html.erb +0 -49
- data/app/views/decidim/forms/admin/questionnaires/answers/show.html.erb +0 -43
- data/app/views/decidim/forms/questionnaires/_answer.html.erb +0 -61
- data/app/views/decidim/forms/questionnaires/answers/_files.html.erb +0 -1
- data/app/views/decidim/forms/questionnaires/answers/_long_answer.html.erb +0 -3
- data/app/views/decidim/forms/questionnaires/answers/_multiple_option.html.erb +0 -25
- data/app/views/decidim/forms/questionnaires/answers/_separator.html.erb +0 -1
- data/app/views/decidim/forms/questionnaires/answers/_short_answer.html.erb +0 -3
- data/app/views/decidim/forms/questionnaires/answers/_single_option.html.erb +0 -32
- data/app/views/decidim/forms/questionnaires/answers/_sorting.html.erb +0 -26
- data/app/views/decidim/forms/questionnaires/answers/_title_and_description.html.erb +0 -1
- data/lib/decidim/api/answer_option_type.rb +0 -13
- data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +0 -149
- data/lib/decidim/forms/user_answers_serializer.rb +0 -105
- /data/app/cells/decidim/forms/{answer_readonly → response_readonly}/show.erb +0 -0
@@ -4,14 +4,14 @@ require "spec_helper"
|
|
4
4
|
|
5
5
|
shared_examples_for "has questionnaire" do
|
6
6
|
context "when the user is not logged in" do
|
7
|
-
it "does not allow
|
7
|
+
it "does not allow responding the questionnaire" do
|
8
8
|
visit questionnaire_public_path
|
9
9
|
see_questionnaire_questions
|
10
10
|
|
11
11
|
expect(page).to have_i18n_content(questionnaire.title)
|
12
12
|
expect(page).to have_i18n_content(questionnaire.description, strip_tags: true)
|
13
13
|
|
14
|
-
expect(page).to have_no_css(".form.
|
14
|
+
expect(page).to have_no_css(".form.response-questionnaire")
|
15
15
|
|
16
16
|
within "[data-question-readonly]" do
|
17
17
|
expect(page).to have_i18n_content(question.body)
|
@@ -37,7 +37,7 @@ shared_examples_for "has questionnaire" do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
it "allows
|
40
|
+
it "allows responding the questionnaire" do
|
41
41
|
visit questionnaire_public_path
|
42
42
|
|
43
43
|
expect(page).to have_i18n_content(questionnaire.title)
|
@@ -45,7 +45,7 @@ shared_examples_for "has questionnaire" do
|
|
45
45
|
|
46
46
|
see_questionnaire_questions
|
47
47
|
|
48
|
-
fill_in question.body["en"], with: "My first
|
48
|
+
fill_in question.body["en"], with: "My first response"
|
49
49
|
|
50
50
|
check "questionnaire_tos_agreement"
|
51
51
|
|
@@ -58,7 +58,7 @@ shared_examples_for "has questionnaire" do
|
|
58
58
|
visit questionnaire_public_path
|
59
59
|
see_questionnaire_questions
|
60
60
|
|
61
|
-
expect(page).to have_content("You have already
|
61
|
+
expect(page).to have_content("You have already responded this form.")
|
62
62
|
expect(page).to have_no_i18n_content(question.body)
|
63
63
|
end
|
64
64
|
|
@@ -67,7 +67,7 @@ shared_examples_for "has questionnaire" do
|
|
67
67
|
create(
|
68
68
|
:questionnaire_question,
|
69
69
|
questionnaire:,
|
70
|
-
question_type: "
|
70
|
+
question_type: "short_response",
|
71
71
|
position: 0,
|
72
72
|
mandatory: true
|
73
73
|
)
|
@@ -79,9 +79,9 @@ shared_examples_for "has questionnaire" do
|
|
79
79
|
|
80
80
|
it "it renders the asterisk as a separated element" do
|
81
81
|
see_questionnaire_questions
|
82
|
-
within "label.
|
82
|
+
within "label.response-questionnaire__question-label" do
|
83
83
|
expect(page).to have_content(translated_attribute(question.body).to_s)
|
84
|
-
within "span.label-required
|
84
|
+
within "span.label-required" do
|
85
85
|
expect(page).to have_content("*")
|
86
86
|
expect(page).to have_content("Required field")
|
87
87
|
end
|
@@ -98,29 +98,29 @@ shared_examples_for "has questionnaire" do
|
|
98
98
|
see_questionnaire_questions
|
99
99
|
end
|
100
100
|
|
101
|
-
it "allows
|
101
|
+
it "allows responding the first questionnaire" do
|
102
102
|
expect(page).to have_content("Step 1 of 2")
|
103
103
|
|
104
|
-
within ".
|
104
|
+
within ".response-questionnaire__submit", match: :first do
|
105
105
|
expect(page).to have_no_content("Back")
|
106
106
|
end
|
107
107
|
|
108
|
-
|
108
|
+
response_first_questionnaire
|
109
109
|
|
110
110
|
expect(page).to have_no_css(".success.flash")
|
111
111
|
end
|
112
112
|
|
113
|
-
it "allows revisiting previously-
|
114
|
-
|
113
|
+
it "allows revisiting previously-responded questionnaires with my responses" do
|
114
|
+
response_first_questionnaire
|
115
115
|
|
116
116
|
click_on "Back"
|
117
117
|
|
118
118
|
expect(page).to have_content("Step 1 of 2")
|
119
|
-
expect(page).to have_field("questionnaire_responses_0", with: "My first
|
119
|
+
expect(page).to have_field("questionnaire_responses_0", with: "My first response")
|
120
120
|
end
|
121
121
|
|
122
|
-
it "finishes the submission when
|
123
|
-
|
122
|
+
it "finishes the submission when responding the last questionnaire" do
|
123
|
+
response_first_questionnaire
|
124
124
|
|
125
125
|
check "questionnaire_tos_agreement"
|
126
126
|
accept_confirm { click_on "Submit" }
|
@@ -130,32 +130,32 @@ shared_examples_for "has questionnaire" do
|
|
130
130
|
visit questionnaire_public_path
|
131
131
|
see_questionnaire_questions
|
132
132
|
|
133
|
-
expect(page).to have_content("You have already
|
133
|
+
expect(page).to have_content("You have already responded this form.")
|
134
134
|
end
|
135
135
|
|
136
|
-
def
|
136
|
+
def response_first_questionnaire
|
137
137
|
within "#step-0" do
|
138
138
|
expect(page).to have_no_css("#questionnaire_tos_agreement")
|
139
139
|
|
140
|
-
fill_in question.body["en"], with: "My first
|
140
|
+
fill_in question.body["en"], with: "My first response"
|
141
141
|
click_on "Continue"
|
142
142
|
end
|
143
143
|
expect(page).to have_content("Step 2 of 2")
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
-
it "requires confirmation when exiting mid-
|
147
|
+
it "requires confirmation when exiting mid-responding" do
|
148
148
|
visit questionnaire_public_path
|
149
149
|
see_questionnaire_questions
|
150
150
|
|
151
|
-
fill_in question.body["en"], with: "My first
|
151
|
+
fill_in question.body["en"], with: "My first response"
|
152
152
|
|
153
153
|
click_on translated_attribute(component.name)
|
154
154
|
|
155
155
|
expect(page).to have_current_path(questionnaire_public_path)
|
156
156
|
end
|
157
157
|
|
158
|
-
context "when the questionnaire has already been
|
158
|
+
context "when the questionnaire has already been responded by someone else" do
|
159
159
|
let!(:question) do
|
160
160
|
create(
|
161
161
|
:questionnaire_question,
|
@@ -170,15 +170,15 @@ shared_examples_for "has questionnaire" do
|
|
170
170
|
end
|
171
171
|
|
172
172
|
before do
|
173
|
-
|
173
|
+
response = create(:response, id: 1, questionnaire:, question:)
|
174
174
|
|
175
|
-
|
176
|
-
|
175
|
+
response.choices.create!(
|
176
|
+
response_option: Decidim::Forms::ResponseOption.first,
|
177
177
|
body: "Lalalilo"
|
178
178
|
)
|
179
179
|
end
|
180
180
|
|
181
|
-
it "does not leak defaults from other
|
181
|
+
it "does not leak defaults from other responses" do
|
182
182
|
visit questionnaire_public_path
|
183
183
|
see_questionnaire_questions
|
184
184
|
|
@@ -188,12 +188,12 @@ shared_examples_for "has questionnaire" do
|
|
188
188
|
|
189
189
|
shared_examples_for "a correctly ordered questionnaire" do
|
190
190
|
it "displays the questions ordered by position starting with one" do
|
191
|
-
form_fields = all(".
|
191
|
+
form_fields = all(".response-questionnaire__question")
|
192
192
|
|
193
193
|
expect(form_fields[0]).to have_i18n_content(question.body)
|
194
194
|
expect(form_fields[1]).to have_i18n_content(other_question.body)
|
195
195
|
2.times do |index|
|
196
|
-
expect(form_fields[index]).to have_css("[data-
|
196
|
+
expect(form_fields[index]).to have_css("[data-response-idx='#{index + 1}']")
|
197
197
|
end
|
198
198
|
end
|
199
199
|
end
|
@@ -226,7 +226,7 @@ shared_examples_for "has questionnaire" do
|
|
226
226
|
create(
|
227
227
|
:questionnaire_question,
|
228
228
|
questionnaire:,
|
229
|
-
question_type: "
|
229
|
+
question_type: "short_response",
|
230
230
|
position: 0,
|
231
231
|
mandatory: true
|
232
232
|
)
|
@@ -286,7 +286,7 @@ shared_examples_for "has questionnaire" do
|
|
286
286
|
it "submits the form and shows errors" do
|
287
287
|
expect(page).to have_css ".alert.flash"
|
288
288
|
expect(page).to have_admin_callout(callout_failure)
|
289
|
-
different_error = I18n.t("decidim.forms.questionnaires.
|
289
|
+
different_error = I18n.t("decidim.forms.questionnaires.response.max_choices_alert")
|
290
290
|
expect(different_error).to eq("There are too many choices selected")
|
291
291
|
expect(page).to have_no_content(different_error)
|
292
292
|
|
@@ -336,7 +336,7 @@ shared_examples_for "has questionnaire" do
|
|
336
336
|
end
|
337
337
|
|
338
338
|
describe "free text options" do
|
339
|
-
let(:
|
339
|
+
let(:response_option_bodies) { Array.new(3) { Decidim::Faker::Localized.sentence } }
|
340
340
|
let(:max_characters) { 0 }
|
341
341
|
let!(:question) do
|
342
342
|
create(
|
@@ -346,9 +346,9 @@ shared_examples_for "has questionnaire" do
|
|
346
346
|
max_characters:,
|
347
347
|
position: 1,
|
348
348
|
options: [
|
349
|
-
{ "body" =>
|
350
|
-
{ "body" =>
|
351
|
-
{ "body" =>
|
349
|
+
{ "body" => response_option_bodies[0] },
|
350
|
+
{ "body" => response_option_bodies[1] },
|
351
|
+
{ "body" => response_option_bodies[2], "free_text" => true }
|
352
352
|
]
|
353
353
|
)
|
354
354
|
end
|
@@ -381,34 +381,34 @@ shared_examples_for "has questionnaire" do
|
|
381
381
|
|
382
382
|
expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", disabled: true, count: 1)
|
383
383
|
|
384
|
-
choose
|
384
|
+
choose response_option_bodies[2]["en"]
|
385
385
|
|
386
386
|
expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", disabled: false, count: 1)
|
387
387
|
end
|
388
388
|
|
389
389
|
it "saves the free text in a separate field if submission correct" do
|
390
|
-
choose
|
390
|
+
choose response_option_bodies[2]["en"]
|
391
391
|
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
|
392
392
|
|
393
393
|
check "questionnaire_tos_agreement"
|
394
394
|
accept_confirm { click_on "Submit" }
|
395
395
|
|
396
396
|
expect(page).to have_admin_callout(callout_success)
|
397
|
-
expect(Decidim::Forms::
|
397
|
+
expect(Decidim::Forms::Response.first.choices.first.custom_body).to eq("Cacatua")
|
398
398
|
end
|
399
399
|
|
400
400
|
it "preserves the previous custom body if submission not correct" do
|
401
|
-
check other_question.
|
402
|
-
check other_question.
|
403
|
-
check other_question.
|
401
|
+
check other_question.response_options.first.body["en"]
|
402
|
+
check other_question.response_options.second.body["en"]
|
403
|
+
check other_question.response_options.third.body["en"]
|
404
404
|
|
405
|
-
choose
|
405
|
+
choose response_option_bodies[2]["en"]
|
406
406
|
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
|
407
407
|
|
408
408
|
check "questionnaire_tos_agreement"
|
409
409
|
accept_confirm { click_on "Submit" }
|
410
410
|
|
411
|
-
expect(page).to have_admin_callout("There was a problem
|
411
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
412
412
|
expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", with: "Cacatua")
|
413
413
|
end
|
414
414
|
|
@@ -423,20 +423,20 @@ shared_examples_for "has questionnaire" do
|
|
423
423
|
|
424
424
|
expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", disabled: true, count: 1)
|
425
425
|
|
426
|
-
check
|
426
|
+
check response_option_bodies[2]["en"]
|
427
427
|
|
428
428
|
expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", disabled: false, count: 1)
|
429
429
|
end
|
430
430
|
|
431
431
|
it "saves the free text in a separate field if submission correct" do
|
432
|
-
check
|
432
|
+
check response_option_bodies[2]["en"]
|
433
433
|
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
|
434
434
|
|
435
435
|
check "questionnaire_tos_agreement"
|
436
436
|
accept_confirm { click_on "Submit" }
|
437
437
|
|
438
438
|
expect(page).to have_admin_callout(callout_success)
|
439
|
-
expect(Decidim::Forms::
|
439
|
+
expect(Decidim::Forms::Response.first.choices.first.custom_body).to eq("Cacatua")
|
440
440
|
end
|
441
441
|
|
442
442
|
it "preserves the previous custom body if submission not correct" do
|
@@ -444,13 +444,13 @@ shared_examples_for "has questionnaire" do
|
|
444
444
|
check "questionnaire_responses_1_choices_1_body"
|
445
445
|
check "questionnaire_responses_1_choices_2_body"
|
446
446
|
|
447
|
-
check
|
447
|
+
check response_option_bodies[2]["en"]
|
448
448
|
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
|
449
449
|
|
450
450
|
check "questionnaire_tos_agreement"
|
451
451
|
accept_confirm { click_on "Submit" }
|
452
452
|
|
453
|
-
expect(page).to have_admin_callout("There was a problem
|
453
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
454
454
|
expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", with: "Cacatua")
|
455
455
|
end
|
456
456
|
|
@@ -458,11 +458,11 @@ shared_examples_for "has questionnaire" do
|
|
458
458
|
end
|
459
459
|
end
|
460
460
|
|
461
|
-
context "when question type is long
|
461
|
+
context "when question type is long response" do
|
462
462
|
let(:max_characters) { 0 }
|
463
|
-
let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "
|
463
|
+
let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "long_response", max_characters:) }
|
464
464
|
|
465
|
-
it "renders the
|
465
|
+
it "renders the response as a textarea" do
|
466
466
|
visit questionnaire_public_path
|
467
467
|
see_questionnaire_questions
|
468
468
|
|
@@ -472,11 +472,11 @@ shared_examples_for "has questionnaire" do
|
|
472
472
|
it_behaves_like "question has a character limit"
|
473
473
|
end
|
474
474
|
|
475
|
-
context "when question type is short
|
475
|
+
context "when question type is short response" do
|
476
476
|
let(:max_characters) { 0 }
|
477
|
-
let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "
|
477
|
+
let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "short_response", max_characters:) }
|
478
478
|
|
479
|
-
it "renders the
|
479
|
+
it "renders the response as a text field" do
|
480
480
|
visit questionnaire_public_path
|
481
481
|
see_questionnaire_questions
|
482
482
|
|
@@ -487,16 +487,16 @@ shared_examples_for "has questionnaire" do
|
|
487
487
|
end
|
488
488
|
|
489
489
|
context "when question type is single option" do
|
490
|
-
let(:
|
491
|
-
let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "single_option", options:
|
490
|
+
let(:response_options) { Array.new(2) { { "body" => Decidim::Faker::Localized.sentence } } }
|
491
|
+
let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "single_option", options: response_options) }
|
492
492
|
|
493
|
-
it "renders
|
493
|
+
it "renders responses as a collection of radio buttons" do
|
494
494
|
visit questionnaire_public_path
|
495
495
|
see_questionnaire_questions
|
496
496
|
|
497
497
|
expect(page).to have_css(".js-radio-button-collection input[type=radio]", count: 2)
|
498
498
|
|
499
|
-
choose
|
499
|
+
choose response_options[0]["body"][:en]
|
500
500
|
|
501
501
|
check "questionnaire_tos_agreement"
|
502
502
|
|
@@ -507,16 +507,16 @@ shared_examples_for "has questionnaire" do
|
|
507
507
|
visit questionnaire_public_path
|
508
508
|
see_questionnaire_questions
|
509
509
|
|
510
|
-
expect(page).to have_content("You have already
|
510
|
+
expect(page).to have_content("You have already responded this form.")
|
511
511
|
expect(page).to have_no_i18n_content(question.body)
|
512
512
|
end
|
513
513
|
end
|
514
514
|
|
515
515
|
context "when question type is multiple option" do
|
516
|
-
let(:
|
517
|
-
let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "multiple_option", options:
|
516
|
+
let(:response_options) { Array.new(3) { { "body" => Decidim::Faker::Localized.sentence } } }
|
517
|
+
let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "multiple_option", options: response_options) }
|
518
518
|
|
519
|
-
it "renders
|
519
|
+
it "renders responses as a collection of radio buttons" do
|
520
520
|
visit questionnaire_public_path
|
521
521
|
see_questionnaire_questions
|
522
522
|
|
@@ -524,8 +524,8 @@ shared_examples_for "has questionnaire" do
|
|
524
524
|
|
525
525
|
expect(page).to have_no_content("Max choices:")
|
526
526
|
|
527
|
-
check
|
528
|
-
check
|
527
|
+
check response_options[0]["body"][:en]
|
528
|
+
check response_options[1]["body"][:en]
|
529
529
|
|
530
530
|
check "questionnaire_tos_agreement"
|
531
531
|
|
@@ -536,7 +536,7 @@ shared_examples_for "has questionnaire" do
|
|
536
536
|
visit questionnaire_public_path
|
537
537
|
see_questionnaire_questions
|
538
538
|
|
539
|
-
expect(page).to have_content("You have already
|
539
|
+
expect(page).to have_content("You have already responded this form.")
|
540
540
|
expect(page).to have_no_i18n_content(question.body)
|
541
541
|
end
|
542
542
|
|
@@ -548,9 +548,9 @@ shared_examples_for "has questionnaire" do
|
|
548
548
|
|
549
549
|
expect(page).to have_content("Max choices: 2")
|
550
550
|
|
551
|
-
check
|
552
|
-
check
|
553
|
-
check
|
551
|
+
check response_options[0]["body"][:en]
|
552
|
+
check response_options[1]["body"][:en]
|
553
|
+
check response_options[2]["body"][:en]
|
554
554
|
|
555
555
|
expect(page).to have_content("too many choices")
|
556
556
|
|
@@ -558,10 +558,10 @@ shared_examples_for "has questionnaire" do
|
|
558
558
|
|
559
559
|
accept_confirm { click_on "Submit" }
|
560
560
|
|
561
|
-
expect(page).to have_admin_callout("There was a problem
|
561
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
562
562
|
expect(page).to have_content("are too many")
|
563
563
|
|
564
|
-
uncheck
|
564
|
+
uncheck response_options[2]["body"][:en]
|
565
565
|
|
566
566
|
accept_confirm { click_on "Submit" }
|
567
567
|
|
@@ -585,11 +585,11 @@ shared_examples_for "has questionnaire" do
|
|
585
585
|
)
|
586
586
|
end
|
587
587
|
|
588
|
-
it "renders the question
|
588
|
+
it "renders the question responses as a collection of divs sortable on drag and drop" do
|
589
589
|
visit questionnaire_public_path
|
590
590
|
see_questionnaire_questions
|
591
591
|
|
592
|
-
expect(page).to have_css("div.
|
592
|
+
expect(page).to have_css("div.response-questionnaire__sorting.js-collection-input", count: 5)
|
593
593
|
|
594
594
|
%w(We all like dark chocolate).each do |term|
|
595
595
|
expect(page).to have_content(term)
|
@@ -601,7 +601,7 @@ shared_examples_for "has questionnaire" do
|
|
601
601
|
see_questionnaire_questions
|
602
602
|
|
603
603
|
%w(We all like dark chocolate).reverse.each do |text|
|
604
|
-
find("div.
|
604
|
+
find("div.response-questionnaire__sorting", text:).drag_to(find("div.response-questionnaire__sorting", match: :first))
|
605
605
|
end
|
606
606
|
|
607
607
|
check "questionnaire_tos_agreement"
|
@@ -609,7 +609,7 @@ shared_examples_for "has questionnaire" do
|
|
609
609
|
accept_confirm { click_on "Submit" }
|
610
610
|
|
611
611
|
expect(page).to have_admin_callout(callout_success)
|
612
|
-
expect(Decidim::Forms::
|
612
|
+
expect(Decidim::Forms::Response.first.choices.pluck(:position, :body)).to eq(
|
613
613
|
[[0, "We"], [1, "all"], [2, "like"], [3, "dark"], [4, "chocolate"]]
|
614
614
|
)
|
615
615
|
end
|
@@ -617,7 +617,7 @@ shared_examples_for "has questionnaire" do
|
|
617
617
|
|
618
618
|
context "when question type is matrix_single" do
|
619
619
|
let(:matrix_rows) { Array.new(2) { { "body" => Decidim::Faker::Localized.sentence } } }
|
620
|
-
let(:
|
620
|
+
let(:response_options) { Array.new(2) { { "body" => Decidim::Faker::Localized.sentence } } }
|
621
621
|
let(:mandatory) { false }
|
622
622
|
|
623
623
|
let!(:question) do
|
@@ -626,19 +626,19 @@ shared_examples_for "has questionnaire" do
|
|
626
626
|
questionnaire:,
|
627
627
|
question_type: "matrix_single",
|
628
628
|
rows: matrix_rows,
|
629
|
-
options:
|
629
|
+
options: response_options,
|
630
630
|
mandatory:
|
631
631
|
)
|
632
632
|
end
|
633
633
|
|
634
|
-
it "renders the question
|
634
|
+
it "renders the question responses as a collection of radio buttons" do
|
635
635
|
visit questionnaire_public_path
|
636
636
|
see_questionnaire_questions
|
637
637
|
|
638
638
|
expect(page).to have_css(".js-radio-button-collection input[type=radio]", count: 4)
|
639
639
|
|
640
640
|
expect(page).to have_content(matrix_rows.map { |row| row["body"]["en"] }.join("\n"))
|
641
|
-
expect(page).to have_content(
|
641
|
+
expect(page).to have_content(response_options.map { |option| option["body"]["en"] }.join(" "))
|
642
642
|
|
643
643
|
radio_buttons = page.all(".js-radio-button-collection input[type=radio]")
|
644
644
|
|
@@ -654,16 +654,16 @@ shared_examples_for "has questionnaire" do
|
|
654
654
|
visit questionnaire_public_path
|
655
655
|
see_questionnaire_questions
|
656
656
|
|
657
|
-
expect(page).to have_content("You have already
|
657
|
+
expect(page).to have_content("You have already responded this form.")
|
658
658
|
expect(page).to have_no_i18n_content(question.body)
|
659
659
|
|
660
|
-
first_choice, last_choice = Decidim::Forms::
|
660
|
+
first_choice, last_choice = Decidim::Forms::Response.last.choices.pluck(:decidim_response_option_id, :decidim_question_matrix_row_id)
|
661
661
|
|
662
|
-
expect(first_choice).to eq([question.
|
663
|
-
expect(last_choice).to eq([question.
|
662
|
+
expect(first_choice).to eq([question.response_options.first.id, question.matrix_rows.first.id])
|
663
|
+
expect(last_choice).to eq([question.response_options.last.id, question.matrix_rows.last.id])
|
664
664
|
end
|
665
665
|
|
666
|
-
it "preserves the chosen
|
666
|
+
it "preserves the chosen responses if submission not correct" do
|
667
667
|
visit questionnaire_public_path
|
668
668
|
see_questionnaire_questions
|
669
669
|
|
@@ -672,16 +672,16 @@ shared_examples_for "has questionnaire" do
|
|
672
672
|
|
673
673
|
accept_confirm { click_on "Submit" }
|
674
674
|
|
675
|
-
expect(page).to have_admin_callout("There was a problem
|
675
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
676
676
|
|
677
677
|
radio_buttons = page.all(".js-radio-button-collection input[type=radio]")
|
678
678
|
expect(radio_buttons.pluck(:checked)).to eq([nil, "true", nil, nil])
|
679
679
|
end
|
680
680
|
|
681
|
-
context "when the question is mandatory and the
|
681
|
+
context "when the question is mandatory and the response is not complete" do
|
682
682
|
let!(:mandatory) { true }
|
683
683
|
|
684
|
-
it "shows an error if the question is mandatory and the
|
684
|
+
it "shows an error if the question is mandatory and the response is not complete" do
|
685
685
|
visit questionnaire_public_path
|
686
686
|
see_questionnaire_questions
|
687
687
|
|
@@ -691,7 +691,7 @@ shared_examples_for "has questionnaire" do
|
|
691
691
|
check "questionnaire_tos_agreement"
|
692
692
|
accept_confirm { click_on "Submit" }
|
693
693
|
|
694
|
-
expect(page).to have_admin_callout("There was a problem
|
694
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
695
695
|
expect(page).to have_content("Choices are not complete")
|
696
696
|
end
|
697
697
|
end
|
@@ -699,7 +699,7 @@ shared_examples_for "has questionnaire" do
|
|
699
699
|
|
700
700
|
context "when question type is matrix_multiple" do
|
701
701
|
let(:matrix_rows) { Array.new(2) { { "body" => Decidim::Faker::Localized.sentence } } }
|
702
|
-
let(:
|
702
|
+
let(:response_options) { Array.new(3) { { "body" => Decidim::Faker::Localized.sentence } } }
|
703
703
|
let(:max_choices) { nil }
|
704
704
|
let(:mandatory) { false }
|
705
705
|
|
@@ -709,20 +709,20 @@ shared_examples_for "has questionnaire" do
|
|
709
709
|
questionnaire:,
|
710
710
|
question_type: "matrix_multiple",
|
711
711
|
rows: matrix_rows,
|
712
|
-
options:
|
712
|
+
options: response_options,
|
713
713
|
max_choices:,
|
714
714
|
mandatory:
|
715
715
|
)
|
716
716
|
end
|
717
717
|
|
718
|
-
it "renders the question
|
718
|
+
it "renders the question responses as a collection of check boxes" do
|
719
719
|
visit questionnaire_public_path
|
720
720
|
see_questionnaire_questions
|
721
721
|
|
722
722
|
expect(page).to have_css(".js-check-box-collection input[type=checkbox]", count: 6)
|
723
723
|
|
724
724
|
expect(page).to have_content(matrix_rows.map { |row| row["body"]["en"] }.join("\n"))
|
725
|
-
expect(page).to have_content(
|
725
|
+
expect(page).to have_content(response_options.map { |option| option["body"]["en"] }.join(" "))
|
726
726
|
|
727
727
|
checkboxes = page.all(".js-check-box-collection input[type=checkbox]")
|
728
728
|
|
@@ -739,14 +739,14 @@ shared_examples_for "has questionnaire" do
|
|
739
739
|
visit questionnaire_public_path
|
740
740
|
see_questionnaire_questions
|
741
741
|
|
742
|
-
expect(page).to have_content("You have already
|
742
|
+
expect(page).to have_content("You have already responded this form.")
|
743
743
|
expect(page).to have_no_i18n_content(question.body)
|
744
744
|
|
745
|
-
first_choice, second_choice, third_choice = Decidim::Forms::
|
745
|
+
first_choice, second_choice, third_choice = Decidim::Forms::Response.last.choices.pluck(:decidim_response_option_id, :decidim_question_matrix_row_id)
|
746
746
|
|
747
|
-
expect(first_choice).to eq([question.
|
748
|
-
expect(second_choice).to eq([question.
|
749
|
-
expect(third_choice).to eq([question.
|
747
|
+
expect(first_choice).to eq([question.response_options.first.id, question.matrix_rows.first.id])
|
748
|
+
expect(second_choice).to eq([question.response_options.second.id, question.matrix_rows.first.id])
|
749
|
+
expect(third_choice).to eq([question.response_options.first.id, question.matrix_rows.last.id])
|
750
750
|
end
|
751
751
|
|
752
752
|
context "when the question has max_choices defined" do
|
@@ -781,7 +781,7 @@ shared_examples_for "has questionnaire" do
|
|
781
781
|
|
782
782
|
accept_confirm { click_on "Submit" }
|
783
783
|
|
784
|
-
expect(page).to have_admin_callout("There was a problem
|
784
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
785
785
|
expect(page).to have_content("are too many")
|
786
786
|
|
787
787
|
checkboxes = page.all(".js-check-box-collection input[type=checkbox]")
|
@@ -794,7 +794,7 @@ shared_examples_for "has questionnaire" do
|
|
794
794
|
end
|
795
795
|
end
|
796
796
|
|
797
|
-
context "when the question is mandatory and the
|
797
|
+
context "when the question is mandatory and the response is not complete" do
|
798
798
|
let!(:mandatory) { true }
|
799
799
|
|
800
800
|
it "shows an error" do
|
@@ -807,7 +807,7 @@ shared_examples_for "has questionnaire" do
|
|
807
807
|
check "questionnaire_tos_agreement"
|
808
808
|
accept_confirm { click_on "Submit" }
|
809
809
|
|
810
|
-
expect(page).to have_admin_callout("There was a problem
|
810
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
811
811
|
expect(page).to have_content("Choices are not complete")
|
812
812
|
end
|
813
813
|
end
|
@@ -815,7 +815,7 @@ shared_examples_for "has questionnaire" do
|
|
815
815
|
context "when the submission is not correct" do
|
816
816
|
let!(:max_choices) { 2 }
|
817
817
|
|
818
|
-
it "preserves the chosen
|
818
|
+
it "preserves the chosen responses" do
|
819
819
|
visit questionnaire_public_path
|
820
820
|
see_questionnaire_questions
|
821
821
|
|
@@ -828,7 +828,7 @@ shared_examples_for "has questionnaire" do
|
|
828
828
|
check "questionnaire_tos_agreement"
|
829
829
|
accept_confirm { click_on "Submit" }
|
830
830
|
|
831
|
-
expect(page).to have_admin_callout("There was a problem
|
831
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
832
832
|
|
833
833
|
checkboxes = page.all(".js-check-box-collection input[type=checkbox]")
|
834
834
|
expect(checkboxes.pluck(:checked)).to eq(["true", "true", "true", nil, nil, "true"])
|
@@ -837,7 +837,7 @@ shared_examples_for "has questionnaire" do
|
|
837
837
|
end
|
838
838
|
|
839
839
|
describe "display conditions" do
|
840
|
-
let(:
|
840
|
+
let(:response_options) do
|
841
841
|
3.times.to_a.map do |x|
|
842
842
|
{
|
843
843
|
"body" => Decidim::Faker::Localized.sentence,
|
@@ -857,10 +857,10 @@ shared_examples_for "has questionnaire" do
|
|
857
857
|
end
|
858
858
|
|
859
859
|
context "when a question has a display condition" do
|
860
|
-
context "when condition is of type '
|
860
|
+
context "when condition is of type 'responded'" do
|
861
861
|
let!(:display_condition) do
|
862
862
|
create(:display_condition,
|
863
|
-
condition_type: "
|
863
|
+
condition_type: "responded",
|
864
864
|
question:,
|
865
865
|
condition_question:)
|
866
866
|
end
|
@@ -870,8 +870,8 @@ shared_examples_for "has questionnaire" do
|
|
870
870
|
see_questionnaire_questions
|
871
871
|
end
|
872
872
|
|
873
|
-
context "when the condition_question type is short
|
874
|
-
let!(:condition_question_type) { "
|
873
|
+
context "when the condition_question type is short response" do
|
874
|
+
let!(:condition_question_type) { "short_response" }
|
875
875
|
|
876
876
|
it "shows the question only if the condition is fulfilled" do
|
877
877
|
expect_question_to_be_visible(false)
|
@@ -888,8 +888,8 @@ shared_examples_for "has questionnaire" do
|
|
888
888
|
end
|
889
889
|
end
|
890
890
|
|
891
|
-
context "when the condition_question type is long
|
892
|
-
let!(:condition_question_type) { "
|
891
|
+
context "when the condition_question type is long response" do
|
892
|
+
let!(:condition_question_type) { "long_response" }
|
893
893
|
let!(:conditioned_question_id) { "#questionnaire_responses_0" }
|
894
894
|
|
895
895
|
it "shows the question only if the condition is fulfilled" do
|
@@ -909,16 +909,16 @@ shared_examples_for "has questionnaire" do
|
|
909
909
|
|
910
910
|
context "when the condition_question type is single option" do
|
911
911
|
let!(:condition_question_type) { "single_option" }
|
912
|
-
let!(:condition_question_options) {
|
912
|
+
let!(:condition_question_options) { response_options }
|
913
913
|
|
914
914
|
it "shows the question only if the condition is fulfilled" do
|
915
915
|
expect_question_to_be_visible(false)
|
916
916
|
|
917
|
-
choose condition_question.
|
917
|
+
choose condition_question.response_options.first.body["en"]
|
918
918
|
|
919
919
|
expect_question_to_be_visible(true)
|
920
920
|
|
921
|
-
choose condition_question.
|
921
|
+
choose condition_question.response_options.second.body["en"]
|
922
922
|
|
923
923
|
expect_question_to_be_visible(false)
|
924
924
|
end
|
@@ -926,34 +926,34 @@ shared_examples_for "has questionnaire" do
|
|
926
926
|
|
927
927
|
context "when the condition_question type is multiple option" do
|
928
928
|
let!(:condition_question_type) { "multiple_option" }
|
929
|
-
let!(:condition_question_options) {
|
929
|
+
let!(:condition_question_options) { response_options }
|
930
930
|
|
931
931
|
it "shows the question only if the condition is fulfilled" do
|
932
932
|
expect_question_to_be_visible(false)
|
933
933
|
|
934
|
-
check condition_question.
|
934
|
+
check condition_question.response_options.first.body["en"]
|
935
935
|
|
936
936
|
expect_question_to_be_visible(true)
|
937
937
|
|
938
|
-
uncheck condition_question.
|
938
|
+
uncheck condition_question.response_options.first.body["en"]
|
939
939
|
|
940
940
|
expect_question_to_be_visible(false)
|
941
941
|
|
942
|
-
check condition_question.
|
942
|
+
check condition_question.response_options.second.body["en"]
|
943
943
|
|
944
944
|
expect_question_to_be_visible(false)
|
945
945
|
|
946
|
-
check condition_question.
|
946
|
+
check condition_question.response_options.first.body["en"]
|
947
947
|
|
948
948
|
expect_question_to_be_visible(true)
|
949
949
|
end
|
950
950
|
end
|
951
951
|
end
|
952
952
|
|
953
|
-
context "when a question has a display condition of type '
|
953
|
+
context "when a question has a display condition of type 'not_responded'" do
|
954
954
|
let!(:display_condition) do
|
955
955
|
create(:display_condition,
|
956
|
-
condition_type: "
|
956
|
+
condition_type: "not_responded",
|
957
957
|
question:,
|
958
958
|
condition_question:)
|
959
959
|
end
|
@@ -963,8 +963,8 @@ shared_examples_for "has questionnaire" do
|
|
963
963
|
see_questionnaire_questions
|
964
964
|
end
|
965
965
|
|
966
|
-
context "when the condition_question type is short
|
967
|
-
let!(:condition_question_type) { "
|
966
|
+
context "when the condition_question type is short response" do
|
967
|
+
let!(:condition_question_type) { "short_response" }
|
968
968
|
|
969
969
|
it "shows the question only if the condition is fulfilled" do
|
970
970
|
expect_question_to_be_visible(true)
|
@@ -981,8 +981,8 @@ shared_examples_for "has questionnaire" do
|
|
981
981
|
end
|
982
982
|
end
|
983
983
|
|
984
|
-
context "when the condition_question type is long
|
985
|
-
let!(:condition_question_type) { "
|
984
|
+
context "when the condition_question type is long response" do
|
985
|
+
let!(:condition_question_type) { "long_response" }
|
986
986
|
let!(:conditioned_question_id) { "#questionnaire_responses_0" }
|
987
987
|
|
988
988
|
it "shows the question only if the condition is fulfilled" do
|
@@ -1002,12 +1002,12 @@ shared_examples_for "has questionnaire" do
|
|
1002
1002
|
|
1003
1003
|
context "when the condition_question type is single option" do
|
1004
1004
|
let!(:condition_question_type) { "single_option" }
|
1005
|
-
let!(:condition_question_options) {
|
1005
|
+
let!(:condition_question_options) { response_options }
|
1006
1006
|
|
1007
1007
|
it "shows the question only if the condition is fulfilled" do
|
1008
1008
|
expect_question_to_be_visible(true)
|
1009
1009
|
|
1010
|
-
choose condition_question.
|
1010
|
+
choose condition_question.response_options.first.body["en"]
|
1011
1011
|
|
1012
1012
|
expect_question_to_be_visible(false)
|
1013
1013
|
end
|
@@ -1015,16 +1015,16 @@ shared_examples_for "has questionnaire" do
|
|
1015
1015
|
|
1016
1016
|
context "when the condition_question type is multiple option" do
|
1017
1017
|
let!(:condition_question_type) { "multiple_option" }
|
1018
|
-
let!(:condition_question_options) {
|
1018
|
+
let!(:condition_question_options) { response_options }
|
1019
1019
|
|
1020
1020
|
it "shows the question only if the condition is fulfilled" do
|
1021
1021
|
expect_question_to_be_visible(true)
|
1022
1022
|
|
1023
|
-
check condition_question.
|
1023
|
+
check condition_question.response_options.first.body["en"]
|
1024
1024
|
|
1025
1025
|
expect_question_to_be_visible(false)
|
1026
1026
|
|
1027
|
-
uncheck condition_question.
|
1027
|
+
uncheck condition_question.response_options.first.body["en"]
|
1028
1028
|
|
1029
1029
|
expect_question_to_be_visible(true)
|
1030
1030
|
end
|
@@ -1037,7 +1037,7 @@ shared_examples_for "has questionnaire" do
|
|
1037
1037
|
condition_type: "equal",
|
1038
1038
|
question:,
|
1039
1039
|
condition_question:,
|
1040
|
-
|
1040
|
+
response_option: condition_question.response_options.first)
|
1041
1041
|
end
|
1042
1042
|
|
1043
1043
|
before do
|
@@ -1047,16 +1047,16 @@ shared_examples_for "has questionnaire" do
|
|
1047
1047
|
|
1048
1048
|
context "when the condition_question type is single option" do
|
1049
1049
|
let!(:condition_question_type) { "single_option" }
|
1050
|
-
let!(:condition_question_options) {
|
1050
|
+
let!(:condition_question_options) { response_options }
|
1051
1051
|
|
1052
1052
|
it "shows the question only if the condition is fulfilled" do
|
1053
1053
|
expect_question_to_be_visible(false)
|
1054
1054
|
|
1055
|
-
choose condition_question.
|
1055
|
+
choose condition_question.response_options.first.body["en"]
|
1056
1056
|
|
1057
1057
|
expect_question_to_be_visible(true)
|
1058
1058
|
|
1059
|
-
choose condition_question.
|
1059
|
+
choose condition_question.response_options.second.body["en"]
|
1060
1060
|
|
1061
1061
|
expect_question_to_be_visible(false)
|
1062
1062
|
end
|
@@ -1064,24 +1064,24 @@ shared_examples_for "has questionnaire" do
|
|
1064
1064
|
|
1065
1065
|
context "when the condition_question type is multiple option" do
|
1066
1066
|
let!(:condition_question_type) { "multiple_option" }
|
1067
|
-
let!(:condition_question_options) {
|
1067
|
+
let!(:condition_question_options) { response_options }
|
1068
1068
|
|
1069
1069
|
it "shows the question only if the condition is fulfilled" do
|
1070
1070
|
expect_question_to_be_visible(false)
|
1071
1071
|
|
1072
|
-
check condition_question.
|
1072
|
+
check condition_question.response_options.first.body["en"]
|
1073
1073
|
|
1074
1074
|
expect_question_to_be_visible(true)
|
1075
1075
|
|
1076
|
-
uncheck condition_question.
|
1076
|
+
uncheck condition_question.response_options.first.body["en"]
|
1077
1077
|
|
1078
1078
|
expect_question_to_be_visible(false)
|
1079
1079
|
|
1080
|
-
check condition_question.
|
1080
|
+
check condition_question.response_options.second.body["en"]
|
1081
1081
|
|
1082
1082
|
expect_question_to_be_visible(false)
|
1083
1083
|
|
1084
|
-
check condition_question.
|
1084
|
+
check condition_question.response_options.first.body["en"]
|
1085
1085
|
|
1086
1086
|
expect_question_to_be_visible(true)
|
1087
1087
|
end
|
@@ -1094,7 +1094,7 @@ shared_examples_for "has questionnaire" do
|
|
1094
1094
|
condition_type: "not_equal",
|
1095
1095
|
question:,
|
1096
1096
|
condition_question:,
|
1097
|
-
|
1097
|
+
response_option: condition_question.response_options.first)
|
1098
1098
|
end
|
1099
1099
|
|
1100
1100
|
before do
|
@@ -1104,16 +1104,16 @@ shared_examples_for "has questionnaire" do
|
|
1104
1104
|
|
1105
1105
|
context "when the condition_question type is single option" do
|
1106
1106
|
let!(:condition_question_type) { "single_option" }
|
1107
|
-
let!(:condition_question_options) {
|
1107
|
+
let!(:condition_question_options) { response_options }
|
1108
1108
|
|
1109
1109
|
it "shows the question only if the condition is fulfilled" do
|
1110
1110
|
expect_question_to_be_visible(false)
|
1111
1111
|
|
1112
|
-
choose condition_question.
|
1112
|
+
choose condition_question.response_options.second.body["en"]
|
1113
1113
|
|
1114
1114
|
expect_question_to_be_visible(true)
|
1115
1115
|
|
1116
|
-
choose condition_question.
|
1116
|
+
choose condition_question.response_options.first.body["en"]
|
1117
1117
|
|
1118
1118
|
expect_question_to_be_visible(false)
|
1119
1119
|
end
|
@@ -1121,24 +1121,24 @@ shared_examples_for "has questionnaire" do
|
|
1121
1121
|
|
1122
1122
|
context "when the condition_question type is multiple option" do
|
1123
1123
|
let!(:condition_question_type) { "multiple_option" }
|
1124
|
-
let!(:condition_question_options) {
|
1124
|
+
let!(:condition_question_options) { response_options }
|
1125
1125
|
|
1126
1126
|
it "shows the question only if the condition is fulfilled" do
|
1127
1127
|
expect_question_to_be_visible(false)
|
1128
1128
|
|
1129
|
-
check condition_question.
|
1129
|
+
check condition_question.response_options.second.body["en"]
|
1130
1130
|
|
1131
1131
|
expect_question_to_be_visible(true)
|
1132
1132
|
|
1133
|
-
uncheck condition_question.
|
1133
|
+
uncheck condition_question.response_options.second.body["en"]
|
1134
1134
|
|
1135
1135
|
expect_question_to_be_visible(false)
|
1136
1136
|
|
1137
|
-
check condition_question.
|
1137
|
+
check condition_question.response_options.first.body["en"]
|
1138
1138
|
|
1139
1139
|
expect_question_to_be_visible(false)
|
1140
1140
|
|
1141
|
-
check condition_question.
|
1141
|
+
check condition_question.response_options.second.body["en"]
|
1142
1142
|
|
1143
1143
|
expect_question_to_be_visible(true)
|
1144
1144
|
end
|
@@ -1160,8 +1160,8 @@ shared_examples_for "has questionnaire" do
|
|
1160
1160
|
see_questionnaire_questions
|
1161
1161
|
end
|
1162
1162
|
|
1163
|
-
context "when the condition_question type is short
|
1164
|
-
let!(:condition_question_type) { "
|
1163
|
+
context "when the condition_question type is short response" do
|
1164
|
+
let!(:condition_question_type) { "short_response" }
|
1165
1165
|
|
1166
1166
|
it "shows the question only if the condition is fulfilled" do
|
1167
1167
|
expect_question_to_be_visible(false)
|
@@ -1183,8 +1183,8 @@ shared_examples_for "has questionnaire" do
|
|
1183
1183
|
end
|
1184
1184
|
end
|
1185
1185
|
|
1186
|
-
context "when the condition_question type is long
|
1187
|
-
let!(:condition_question_type) { "
|
1186
|
+
context "when the condition_question type is long response" do
|
1187
|
+
let!(:condition_question_type) { "long_response" }
|
1188
1188
|
|
1189
1189
|
it "shows the question only if the condition is fulfilled" do
|
1190
1190
|
expect_question_to_be_visible(false)
|
@@ -1208,13 +1208,13 @@ shared_examples_for "has questionnaire" do
|
|
1208
1208
|
|
1209
1209
|
context "when the condition_question type is single option" do
|
1210
1210
|
let!(:condition_question_type) { "single_option" }
|
1211
|
-
let!(:condition_question_options) {
|
1212
|
-
let!(:condition_value) { { en: condition_question.
|
1211
|
+
let!(:condition_question_options) { response_options }
|
1212
|
+
let!(:condition_value) { { en: condition_question.response_options.first.body["en"].split.second.upcase } }
|
1213
1213
|
|
1214
1214
|
it "shows the question only if the condition is fulfilled" do
|
1215
1215
|
expect_question_to_be_visible(false)
|
1216
1216
|
|
1217
|
-
choose condition_question.
|
1217
|
+
choose condition_question.response_options.first.body["en"]
|
1218
1218
|
|
1219
1219
|
expect_question_to_be_visible(true)
|
1220
1220
|
end
|
@@ -1222,22 +1222,22 @@ shared_examples_for "has questionnaire" do
|
|
1222
1222
|
|
1223
1223
|
context "when the condition_question type is single option with free text" do
|
1224
1224
|
let!(:condition_question_type) { "single_option" }
|
1225
|
-
let!(:condition_question_options) {
|
1225
|
+
let!(:condition_question_options) { response_options }
|
1226
1226
|
let!(:condition_value) { { en: "forty two" } }
|
1227
1227
|
|
1228
1228
|
it "shows the question only if the condition is fulfilled" do
|
1229
1229
|
expect_question_to_be_visible(false)
|
1230
1230
|
|
1231
|
-
choose condition_question.
|
1232
|
-
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "The
|
1231
|
+
choose condition_question.response_options.third.body["en"]
|
1232
|
+
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "The response is #{condition_value[:en]}"
|
1233
1233
|
change_focus
|
1234
1234
|
|
1235
1235
|
expect_question_to_be_visible(true)
|
1236
1236
|
|
1237
|
-
choose condition_question.
|
1237
|
+
choose condition_question.response_options.first.body["en"]
|
1238
1238
|
expect_question_to_be_visible(false)
|
1239
1239
|
|
1240
|
-
choose condition_question.
|
1240
|
+
choose condition_question.response_options.third.body["en"]
|
1241
1241
|
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "oh no not 42 again"
|
1242
1242
|
change_focus
|
1243
1243
|
|
@@ -1247,25 +1247,25 @@ shared_examples_for "has questionnaire" do
|
|
1247
1247
|
|
1248
1248
|
context "when the condition_question type is multiple option" do
|
1249
1249
|
let!(:condition_question_type) { "multiple_option" }
|
1250
|
-
let!(:condition_question_options) {
|
1250
|
+
let!(:condition_question_options) { response_options }
|
1251
1251
|
let!(:condition_value) { { en: "forty two" } }
|
1252
1252
|
|
1253
1253
|
it "shows the question only if the condition is fulfilled" do
|
1254
1254
|
expect_question_to_be_visible(false)
|
1255
1255
|
|
1256
|
-
check condition_question.
|
1257
|
-
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "The
|
1256
|
+
check condition_question.response_options.third.body["en"]
|
1257
|
+
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "The response is #{condition_value[:en]}"
|
1258
1258
|
change_focus
|
1259
1259
|
|
1260
1260
|
expect_question_to_be_visible(true)
|
1261
1261
|
|
1262
|
-
check condition_question.
|
1262
|
+
check condition_question.response_options.first.body["en"]
|
1263
1263
|
expect_question_to_be_visible(true)
|
1264
1264
|
|
1265
|
-
uncheck condition_question.
|
1265
|
+
uncheck condition_question.response_options.third.body["en"]
|
1266
1266
|
expect_question_to_be_visible(false)
|
1267
1267
|
|
1268
|
-
check condition_question.
|
1268
|
+
check condition_question.response_options.third.body["en"]
|
1269
1269
|
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "oh no not 42 again"
|
1270
1270
|
change_focus
|
1271
1271
|
|
@@ -1283,11 +1283,11 @@ shared_examples_for "has questionnaire" do
|
|
1283
1283
|
|
1284
1284
|
context "when all conditions are mandatory" do
|
1285
1285
|
let!(:condition_question_type) { "single_option" }
|
1286
|
-
let!(:condition_question_options) {
|
1286
|
+
let!(:condition_question_options) { response_options }
|
1287
1287
|
let!(:display_conditions) do
|
1288
1288
|
[
|
1289
1289
|
create(:display_condition,
|
1290
|
-
condition_type: "
|
1290
|
+
condition_type: "responded",
|
1291
1291
|
question:,
|
1292
1292
|
condition_question:,
|
1293
1293
|
mandatory: true),
|
@@ -1296,18 +1296,18 @@ shared_examples_for "has questionnaire" do
|
|
1296
1296
|
question:,
|
1297
1297
|
condition_question:,
|
1298
1298
|
mandatory: true,
|
1299
|
-
|
1299
|
+
response_option: condition_question.response_options.second)
|
1300
1300
|
]
|
1301
1301
|
end
|
1302
1302
|
|
1303
1303
|
it "is displayed only if all conditions are fulfilled" do
|
1304
1304
|
expect_question_to_be_visible(false)
|
1305
1305
|
|
1306
|
-
choose condition_question.
|
1306
|
+
choose condition_question.response_options.second.body["en"]
|
1307
1307
|
|
1308
1308
|
expect_question_to_be_visible(false)
|
1309
1309
|
|
1310
|
-
choose condition_question.
|
1310
|
+
choose condition_question.response_options.first.body["en"]
|
1311
1311
|
|
1312
1312
|
expect_question_to_be_visible(true)
|
1313
1313
|
end
|
@@ -1315,7 +1315,7 @@ shared_examples_for "has questionnaire" do
|
|
1315
1315
|
|
1316
1316
|
context "when all conditions are non-mandatory" do
|
1317
1317
|
let!(:condition_question_type) { "multiple_option" }
|
1318
|
-
let!(:condition_question_options) {
|
1318
|
+
let!(:condition_question_options) { response_options }
|
1319
1319
|
let!(:display_conditions) do
|
1320
1320
|
[
|
1321
1321
|
create(:display_condition,
|
@@ -1323,36 +1323,36 @@ shared_examples_for "has questionnaire" do
|
|
1323
1323
|
question:,
|
1324
1324
|
condition_question:,
|
1325
1325
|
mandatory: false,
|
1326
|
-
|
1326
|
+
response_option: condition_question.response_options.first),
|
1327
1327
|
create(:display_condition,
|
1328
1328
|
condition_type: "not_equal",
|
1329
1329
|
question:,
|
1330
1330
|
condition_question:,
|
1331
1331
|
mandatory: false,
|
1332
|
-
|
1332
|
+
response_option: condition_question.response_options.third)
|
1333
1333
|
]
|
1334
1334
|
end
|
1335
1335
|
|
1336
1336
|
it "is displayed if any of the conditions is fulfilled" do
|
1337
1337
|
expect_question_to_be_visible(false)
|
1338
1338
|
|
1339
|
-
check condition_question.
|
1339
|
+
check condition_question.response_options.first.body["en"]
|
1340
1340
|
|
1341
1341
|
expect_question_to_be_visible(true)
|
1342
1342
|
|
1343
|
-
uncheck condition_question.
|
1344
|
-
check condition_question.
|
1343
|
+
uncheck condition_question.response_options.first.body["en"]
|
1344
|
+
check condition_question.response_options.second.body["en"]
|
1345
1345
|
|
1346
1346
|
expect_question_to_be_visible(true)
|
1347
1347
|
|
1348
|
-
check condition_question.
|
1348
|
+
check condition_question.response_options.first.body["en"]
|
1349
1349
|
|
1350
1350
|
expect_question_to_be_visible(true)
|
1351
1351
|
end
|
1352
1352
|
end
|
1353
1353
|
|
1354
1354
|
context "when a mandatory question has conditions that have not been fulfilled" do
|
1355
|
-
let!(:condition_question_type) { "
|
1355
|
+
let!(:condition_question_type) { "short_response" }
|
1356
1356
|
let!(:question) { create(:questionnaire_question, questionnaire:, position: 2, mandatory: true) }
|
1357
1357
|
let!(:display_conditions) do
|
1358
1358
|
[
|
@@ -1369,7 +1369,7 @@ shared_examples_for "has questionnaire" do
|
|
1369
1369
|
visit questionnaire_public_path
|
1370
1370
|
see_questionnaire_questions
|
1371
1371
|
|
1372
|
-
fill_in condition_question.body["en"], with: "My first
|
1372
|
+
fill_in condition_question.body["en"], with: "My first response"
|
1373
1373
|
|
1374
1374
|
check "questionnaire_tos_agreement"
|
1375
1375
|
|