decidim-forms 0.30.9 → 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 +15 -15
- 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 +18 -16
- 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 -11
- 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 +47 -66
- 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 +8 -29
- 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_response_presenter.rb +89 -0
- 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 +25 -15
- data/app/views/decidim/forms/admin/questionnaires/_questions_form.html.erb +14 -21
- data/app/views/decidim/forms/admin/questionnaires/_response_option.html.erb +45 -0
- data/app/views/decidim/forms/admin/questionnaires/_response_option_template.html.erb +7 -0
- data/app/views/decidim/forms/admin/questionnaires/_separator.html.erb +15 -5
- data/app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb +15 -5
- 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 +24 -22
- 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 +2 -22
- data/config/locales/bg.yml +10 -36
- data/config/locales/ca-IT.yml +82 -76
- data/config/locales/ca.yml +82 -76
- data/config/locales/cs.yml +79 -76
- data/config/locales/de.yml +80 -74
- data/config/locales/el.yml +10 -36
- data/config/locales/en.yml +90 -84
- data/config/locales/es-MX.yml +82 -76
- data/config/locales/es-PY.yml +82 -76
- data/config/locales/es.yml +80 -74
- data/config/locales/eu.yml +83 -77
- data/config/locales/fi-plain.yml +78 -72
- data/config/locales/fi.yml +76 -70
- data/config/locales/fr-CA.yml +72 -70
- data/config/locales/fr.yml +72 -70
- data/config/locales/ga-IE.yml +4 -7
- data/config/locales/gl.yml +4 -22
- data/config/locales/hu.yml +4 -22
- data/config/locales/id-ID.yml +2 -22
- data/config/locales/it.yml +8 -40
- data/config/locales/ja.yml +87 -81
- data/config/locales/lb.yml +8 -36
- data/config/locales/lt.yml +10 -36
- data/config/locales/lv.yml +4 -22
- data/config/locales/nl.yml +10 -36
- data/config/locales/no.yml +10 -36
- data/config/locales/pl.yml +10 -36
- data/config/locales/pt-BR.yml +10 -120
- data/config/locales/pt.yml +8 -36
- data/config/locales/ro-RO.yml +30 -52
- data/config/locales/ru.yml +2 -9
- data/config/locales/sk.yml +3 -183
- data/config/locales/sl.yml +0 -5
- data/config/locales/sv.yml +77 -70
- data/config/locales/tr-TR.yml +8 -36
- data/config/locales/val-ES.yml +2 -0
- data/config/locales/zh-CN.yml +8 -36
- data/config/locales/zh-TW.yml +10 -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 +35 -43
- 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 +178 -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 -90
- 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 +43 -140
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +4 -6
- 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 -46
- 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/presenters/decidim/forms/admin/questionnaire_answer_presenter.rb +0 -112
- data/app/queries/decidim/forms/questionnaire_user_answers.rb +0 -32
- data/app/views/decidim/forms/admin/questionnaires/_answer_option.html.erb +0 -45
- 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 -60
- 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/test/shared_examples/manage_questionnaires/draggable_behavior.rb +0 -47
- 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,11 +188,13 @@ 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-response-idx='#{index + 1}']")
|
|
197
|
+
end
|
|
196
198
|
end
|
|
197
199
|
end
|
|
198
200
|
|
|
@@ -224,7 +226,7 @@ shared_examples_for "has questionnaire" do
|
|
|
224
226
|
create(
|
|
225
227
|
:questionnaire_question,
|
|
226
228
|
questionnaire:,
|
|
227
|
-
question_type: "
|
|
229
|
+
question_type: "short_response",
|
|
228
230
|
position: 0,
|
|
229
231
|
mandatory: true
|
|
230
232
|
)
|
|
@@ -284,7 +286,7 @@ shared_examples_for "has questionnaire" do
|
|
|
284
286
|
it "submits the form and shows errors" do
|
|
285
287
|
expect(page).to have_css ".alert.flash"
|
|
286
288
|
expect(page).to have_admin_callout(callout_failure)
|
|
287
|
-
different_error = I18n.t("decidim.forms.questionnaires.
|
|
289
|
+
different_error = I18n.t("decidim.forms.questionnaires.response.max_choices_alert")
|
|
288
290
|
expect(different_error).to eq("There are too many choices selected")
|
|
289
291
|
expect(page).to have_no_content(different_error)
|
|
290
292
|
|
|
@@ -334,7 +336,7 @@ shared_examples_for "has questionnaire" do
|
|
|
334
336
|
end
|
|
335
337
|
|
|
336
338
|
describe "free text options" do
|
|
337
|
-
let(:
|
|
339
|
+
let(:response_option_bodies) { Array.new(3) { Decidim::Faker::Localized.sentence } }
|
|
338
340
|
let(:max_characters) { 0 }
|
|
339
341
|
let!(:question) do
|
|
340
342
|
create(
|
|
@@ -344,9 +346,9 @@ shared_examples_for "has questionnaire" do
|
|
|
344
346
|
max_characters:,
|
|
345
347
|
position: 1,
|
|
346
348
|
options: [
|
|
347
|
-
{ "body" =>
|
|
348
|
-
{ "body" =>
|
|
349
|
-
{ "body" =>
|
|
349
|
+
{ "body" => response_option_bodies[0] },
|
|
350
|
+
{ "body" => response_option_bodies[1] },
|
|
351
|
+
{ "body" => response_option_bodies[2], "free_text" => true }
|
|
350
352
|
]
|
|
351
353
|
)
|
|
352
354
|
end
|
|
@@ -379,34 +381,34 @@ shared_examples_for "has questionnaire" do
|
|
|
379
381
|
|
|
380
382
|
expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", disabled: true, count: 1)
|
|
381
383
|
|
|
382
|
-
choose
|
|
384
|
+
choose response_option_bodies[2]["en"]
|
|
383
385
|
|
|
384
386
|
expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", disabled: false, count: 1)
|
|
385
387
|
end
|
|
386
388
|
|
|
387
389
|
it "saves the free text in a separate field if submission correct" do
|
|
388
|
-
choose
|
|
390
|
+
choose response_option_bodies[2]["en"]
|
|
389
391
|
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
|
|
390
392
|
|
|
391
393
|
check "questionnaire_tos_agreement"
|
|
392
394
|
accept_confirm { click_on "Submit" }
|
|
393
395
|
|
|
394
396
|
expect(page).to have_admin_callout(callout_success)
|
|
395
|
-
expect(Decidim::Forms::
|
|
397
|
+
expect(Decidim::Forms::Response.first.choices.first.custom_body).to eq("Cacatua")
|
|
396
398
|
end
|
|
397
399
|
|
|
398
400
|
it "preserves the previous custom body if submission not correct" do
|
|
399
|
-
check other_question.
|
|
400
|
-
check other_question.
|
|
401
|
-
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"]
|
|
402
404
|
|
|
403
|
-
choose
|
|
405
|
+
choose response_option_bodies[2]["en"]
|
|
404
406
|
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
|
|
405
407
|
|
|
406
408
|
check "questionnaire_tos_agreement"
|
|
407
409
|
accept_confirm { click_on "Submit" }
|
|
408
410
|
|
|
409
|
-
expect(page).to have_admin_callout("There was a problem
|
|
411
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
|
410
412
|
expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", with: "Cacatua")
|
|
411
413
|
end
|
|
412
414
|
|
|
@@ -421,20 +423,20 @@ shared_examples_for "has questionnaire" do
|
|
|
421
423
|
|
|
422
424
|
expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", disabled: true, count: 1)
|
|
423
425
|
|
|
424
|
-
check
|
|
426
|
+
check response_option_bodies[2]["en"]
|
|
425
427
|
|
|
426
428
|
expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", disabled: false, count: 1)
|
|
427
429
|
end
|
|
428
430
|
|
|
429
431
|
it "saves the free text in a separate field if submission correct" do
|
|
430
|
-
check
|
|
432
|
+
check response_option_bodies[2]["en"]
|
|
431
433
|
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
|
|
432
434
|
|
|
433
435
|
check "questionnaire_tos_agreement"
|
|
434
436
|
accept_confirm { click_on "Submit" }
|
|
435
437
|
|
|
436
438
|
expect(page).to have_admin_callout(callout_success)
|
|
437
|
-
expect(Decidim::Forms::
|
|
439
|
+
expect(Decidim::Forms::Response.first.choices.first.custom_body).to eq("Cacatua")
|
|
438
440
|
end
|
|
439
441
|
|
|
440
442
|
it "preserves the previous custom body if submission not correct" do
|
|
@@ -442,13 +444,13 @@ shared_examples_for "has questionnaire" do
|
|
|
442
444
|
check "questionnaire_responses_1_choices_1_body"
|
|
443
445
|
check "questionnaire_responses_1_choices_2_body"
|
|
444
446
|
|
|
445
|
-
check
|
|
447
|
+
check response_option_bodies[2]["en"]
|
|
446
448
|
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
|
|
447
449
|
|
|
448
450
|
check "questionnaire_tos_agreement"
|
|
449
451
|
accept_confirm { click_on "Submit" }
|
|
450
452
|
|
|
451
|
-
expect(page).to have_admin_callout("There was a problem
|
|
453
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
|
452
454
|
expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", with: "Cacatua")
|
|
453
455
|
end
|
|
454
456
|
|
|
@@ -456,11 +458,11 @@ shared_examples_for "has questionnaire" do
|
|
|
456
458
|
end
|
|
457
459
|
end
|
|
458
460
|
|
|
459
|
-
context "when question type is long
|
|
461
|
+
context "when question type is long response" do
|
|
460
462
|
let(:max_characters) { 0 }
|
|
461
|
-
let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "
|
|
463
|
+
let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "long_response", max_characters:) }
|
|
462
464
|
|
|
463
|
-
it "renders the
|
|
465
|
+
it "renders the response as a textarea" do
|
|
464
466
|
visit questionnaire_public_path
|
|
465
467
|
see_questionnaire_questions
|
|
466
468
|
|
|
@@ -470,11 +472,11 @@ shared_examples_for "has questionnaire" do
|
|
|
470
472
|
it_behaves_like "question has a character limit"
|
|
471
473
|
end
|
|
472
474
|
|
|
473
|
-
context "when question type is short
|
|
475
|
+
context "when question type is short response" do
|
|
474
476
|
let(:max_characters) { 0 }
|
|
475
|
-
let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "
|
|
477
|
+
let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "short_response", max_characters:) }
|
|
476
478
|
|
|
477
|
-
it "renders the
|
|
479
|
+
it "renders the response as a text field" do
|
|
478
480
|
visit questionnaire_public_path
|
|
479
481
|
see_questionnaire_questions
|
|
480
482
|
|
|
@@ -485,16 +487,16 @@ shared_examples_for "has questionnaire" do
|
|
|
485
487
|
end
|
|
486
488
|
|
|
487
489
|
context "when question type is single option" do
|
|
488
|
-
let(:
|
|
489
|
-
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) }
|
|
490
492
|
|
|
491
|
-
it "renders
|
|
493
|
+
it "renders responses as a collection of radio buttons" do
|
|
492
494
|
visit questionnaire_public_path
|
|
493
495
|
see_questionnaire_questions
|
|
494
496
|
|
|
495
497
|
expect(page).to have_css(".js-radio-button-collection input[type=radio]", count: 2)
|
|
496
498
|
|
|
497
|
-
choose
|
|
499
|
+
choose response_options[0]["body"][:en]
|
|
498
500
|
|
|
499
501
|
check "questionnaire_tos_agreement"
|
|
500
502
|
|
|
@@ -505,16 +507,16 @@ shared_examples_for "has questionnaire" do
|
|
|
505
507
|
visit questionnaire_public_path
|
|
506
508
|
see_questionnaire_questions
|
|
507
509
|
|
|
508
|
-
expect(page).to have_content("You have already
|
|
510
|
+
expect(page).to have_content("You have already responded this form.")
|
|
509
511
|
expect(page).to have_no_i18n_content(question.body)
|
|
510
512
|
end
|
|
511
513
|
end
|
|
512
514
|
|
|
513
515
|
context "when question type is multiple option" do
|
|
514
|
-
let(:
|
|
515
|
-
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) }
|
|
516
518
|
|
|
517
|
-
it "renders
|
|
519
|
+
it "renders responses as a collection of radio buttons" do
|
|
518
520
|
visit questionnaire_public_path
|
|
519
521
|
see_questionnaire_questions
|
|
520
522
|
|
|
@@ -522,8 +524,8 @@ shared_examples_for "has questionnaire" do
|
|
|
522
524
|
|
|
523
525
|
expect(page).to have_no_content("Max choices:")
|
|
524
526
|
|
|
525
|
-
check
|
|
526
|
-
check
|
|
527
|
+
check response_options[0]["body"][:en]
|
|
528
|
+
check response_options[1]["body"][:en]
|
|
527
529
|
|
|
528
530
|
check "questionnaire_tos_agreement"
|
|
529
531
|
|
|
@@ -534,7 +536,7 @@ shared_examples_for "has questionnaire" do
|
|
|
534
536
|
visit questionnaire_public_path
|
|
535
537
|
see_questionnaire_questions
|
|
536
538
|
|
|
537
|
-
expect(page).to have_content("You have already
|
|
539
|
+
expect(page).to have_content("You have already responded this form.")
|
|
538
540
|
expect(page).to have_no_i18n_content(question.body)
|
|
539
541
|
end
|
|
540
542
|
|
|
@@ -546,9 +548,9 @@ shared_examples_for "has questionnaire" do
|
|
|
546
548
|
|
|
547
549
|
expect(page).to have_content("Max choices: 2")
|
|
548
550
|
|
|
549
|
-
check
|
|
550
|
-
check
|
|
551
|
-
check
|
|
551
|
+
check response_options[0]["body"][:en]
|
|
552
|
+
check response_options[1]["body"][:en]
|
|
553
|
+
check response_options[2]["body"][:en]
|
|
552
554
|
|
|
553
555
|
expect(page).to have_content("too many choices")
|
|
554
556
|
|
|
@@ -556,10 +558,10 @@ shared_examples_for "has questionnaire" do
|
|
|
556
558
|
|
|
557
559
|
accept_confirm { click_on "Submit" }
|
|
558
560
|
|
|
559
|
-
expect(page).to have_admin_callout("There was a problem
|
|
561
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
|
560
562
|
expect(page).to have_content("are too many")
|
|
561
563
|
|
|
562
|
-
uncheck
|
|
564
|
+
uncheck response_options[2]["body"][:en]
|
|
563
565
|
|
|
564
566
|
accept_confirm { click_on "Submit" }
|
|
565
567
|
|
|
@@ -583,11 +585,11 @@ shared_examples_for "has questionnaire" do
|
|
|
583
585
|
)
|
|
584
586
|
end
|
|
585
587
|
|
|
586
|
-
it "renders the question
|
|
588
|
+
it "renders the question responses as a collection of divs sortable on drag and drop" do
|
|
587
589
|
visit questionnaire_public_path
|
|
588
590
|
see_questionnaire_questions
|
|
589
591
|
|
|
590
|
-
expect(page).to have_css("div.
|
|
592
|
+
expect(page).to have_css("div.response-questionnaire__sorting.js-collection-input", count: 5)
|
|
591
593
|
|
|
592
594
|
%w(We all like dark chocolate).each do |term|
|
|
593
595
|
expect(page).to have_content(term)
|
|
@@ -599,7 +601,7 @@ shared_examples_for "has questionnaire" do
|
|
|
599
601
|
see_questionnaire_questions
|
|
600
602
|
|
|
601
603
|
%w(We all like dark chocolate).reverse.each do |text|
|
|
602
|
-
find("div.
|
|
604
|
+
find("div.response-questionnaire__sorting", text:).drag_to(find("div.response-questionnaire__sorting", match: :first))
|
|
603
605
|
end
|
|
604
606
|
|
|
605
607
|
check "questionnaire_tos_agreement"
|
|
@@ -607,7 +609,7 @@ shared_examples_for "has questionnaire" do
|
|
|
607
609
|
accept_confirm { click_on "Submit" }
|
|
608
610
|
|
|
609
611
|
expect(page).to have_admin_callout(callout_success)
|
|
610
|
-
expect(Decidim::Forms::
|
|
612
|
+
expect(Decidim::Forms::Response.first.choices.pluck(:position, :body)).to eq(
|
|
611
613
|
[[0, "We"], [1, "all"], [2, "like"], [3, "dark"], [4, "chocolate"]]
|
|
612
614
|
)
|
|
613
615
|
end
|
|
@@ -615,7 +617,7 @@ shared_examples_for "has questionnaire" do
|
|
|
615
617
|
|
|
616
618
|
context "when question type is matrix_single" do
|
|
617
619
|
let(:matrix_rows) { Array.new(2) { { "body" => Decidim::Faker::Localized.sentence } } }
|
|
618
|
-
let(:
|
|
620
|
+
let(:response_options) { Array.new(2) { { "body" => Decidim::Faker::Localized.sentence } } }
|
|
619
621
|
let(:mandatory) { false }
|
|
620
622
|
|
|
621
623
|
let!(:question) do
|
|
@@ -624,19 +626,19 @@ shared_examples_for "has questionnaire" do
|
|
|
624
626
|
questionnaire:,
|
|
625
627
|
question_type: "matrix_single",
|
|
626
628
|
rows: matrix_rows,
|
|
627
|
-
options:
|
|
629
|
+
options: response_options,
|
|
628
630
|
mandatory:
|
|
629
631
|
)
|
|
630
632
|
end
|
|
631
633
|
|
|
632
|
-
it "renders the question
|
|
634
|
+
it "renders the question responses as a collection of radio buttons" do
|
|
633
635
|
visit questionnaire_public_path
|
|
634
636
|
see_questionnaire_questions
|
|
635
637
|
|
|
636
638
|
expect(page).to have_css(".js-radio-button-collection input[type=radio]", count: 4)
|
|
637
639
|
|
|
638
640
|
expect(page).to have_content(matrix_rows.map { |row| row["body"]["en"] }.join("\n"))
|
|
639
|
-
expect(page).to have_content(
|
|
641
|
+
expect(page).to have_content(response_options.map { |option| option["body"]["en"] }.join(" "))
|
|
640
642
|
|
|
641
643
|
radio_buttons = page.all(".js-radio-button-collection input[type=radio]")
|
|
642
644
|
|
|
@@ -652,16 +654,16 @@ shared_examples_for "has questionnaire" do
|
|
|
652
654
|
visit questionnaire_public_path
|
|
653
655
|
see_questionnaire_questions
|
|
654
656
|
|
|
655
|
-
expect(page).to have_content("You have already
|
|
657
|
+
expect(page).to have_content("You have already responded this form.")
|
|
656
658
|
expect(page).to have_no_i18n_content(question.body)
|
|
657
659
|
|
|
658
|
-
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)
|
|
659
661
|
|
|
660
|
-
expect(first_choice).to eq([question.
|
|
661
|
-
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])
|
|
662
664
|
end
|
|
663
665
|
|
|
664
|
-
it "preserves the chosen
|
|
666
|
+
it "preserves the chosen responses if submission not correct" do
|
|
665
667
|
visit questionnaire_public_path
|
|
666
668
|
see_questionnaire_questions
|
|
667
669
|
|
|
@@ -670,16 +672,16 @@ shared_examples_for "has questionnaire" do
|
|
|
670
672
|
|
|
671
673
|
accept_confirm { click_on "Submit" }
|
|
672
674
|
|
|
673
|
-
expect(page).to have_admin_callout("There was a problem
|
|
675
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
|
674
676
|
|
|
675
677
|
radio_buttons = page.all(".js-radio-button-collection input[type=radio]")
|
|
676
678
|
expect(radio_buttons.pluck(:checked)).to eq([nil, "true", nil, nil])
|
|
677
679
|
end
|
|
678
680
|
|
|
679
|
-
context "when the question is mandatory and the
|
|
681
|
+
context "when the question is mandatory and the response is not complete" do
|
|
680
682
|
let!(:mandatory) { true }
|
|
681
683
|
|
|
682
|
-
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
|
|
683
685
|
visit questionnaire_public_path
|
|
684
686
|
see_questionnaire_questions
|
|
685
687
|
|
|
@@ -689,7 +691,7 @@ shared_examples_for "has questionnaire" do
|
|
|
689
691
|
check "questionnaire_tos_agreement"
|
|
690
692
|
accept_confirm { click_on "Submit" }
|
|
691
693
|
|
|
692
|
-
expect(page).to have_admin_callout("There was a problem
|
|
694
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
|
693
695
|
expect(page).to have_content("Choices are not complete")
|
|
694
696
|
end
|
|
695
697
|
end
|
|
@@ -697,7 +699,7 @@ shared_examples_for "has questionnaire" do
|
|
|
697
699
|
|
|
698
700
|
context "when question type is matrix_multiple" do
|
|
699
701
|
let(:matrix_rows) { Array.new(2) { { "body" => Decidim::Faker::Localized.sentence } } }
|
|
700
|
-
let(:
|
|
702
|
+
let(:response_options) { Array.new(3) { { "body" => Decidim::Faker::Localized.sentence } } }
|
|
701
703
|
let(:max_choices) { nil }
|
|
702
704
|
let(:mandatory) { false }
|
|
703
705
|
|
|
@@ -707,20 +709,20 @@ shared_examples_for "has questionnaire" do
|
|
|
707
709
|
questionnaire:,
|
|
708
710
|
question_type: "matrix_multiple",
|
|
709
711
|
rows: matrix_rows,
|
|
710
|
-
options:
|
|
712
|
+
options: response_options,
|
|
711
713
|
max_choices:,
|
|
712
714
|
mandatory:
|
|
713
715
|
)
|
|
714
716
|
end
|
|
715
717
|
|
|
716
|
-
it "renders the question
|
|
718
|
+
it "renders the question responses as a collection of check boxes" do
|
|
717
719
|
visit questionnaire_public_path
|
|
718
720
|
see_questionnaire_questions
|
|
719
721
|
|
|
720
722
|
expect(page).to have_css(".js-check-box-collection input[type=checkbox]", count: 6)
|
|
721
723
|
|
|
722
724
|
expect(page).to have_content(matrix_rows.map { |row| row["body"]["en"] }.join("\n"))
|
|
723
|
-
expect(page).to have_content(
|
|
725
|
+
expect(page).to have_content(response_options.map { |option| option["body"]["en"] }.join(" "))
|
|
724
726
|
|
|
725
727
|
checkboxes = page.all(".js-check-box-collection input[type=checkbox]")
|
|
726
728
|
|
|
@@ -737,14 +739,14 @@ shared_examples_for "has questionnaire" do
|
|
|
737
739
|
visit questionnaire_public_path
|
|
738
740
|
see_questionnaire_questions
|
|
739
741
|
|
|
740
|
-
expect(page).to have_content("You have already
|
|
742
|
+
expect(page).to have_content("You have already responded this form.")
|
|
741
743
|
expect(page).to have_no_i18n_content(question.body)
|
|
742
744
|
|
|
743
|
-
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)
|
|
744
746
|
|
|
745
|
-
expect(first_choice).to eq([question.
|
|
746
|
-
expect(second_choice).to eq([question.
|
|
747
|
-
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])
|
|
748
750
|
end
|
|
749
751
|
|
|
750
752
|
context "when the question has max_choices defined" do
|
|
@@ -779,7 +781,7 @@ shared_examples_for "has questionnaire" do
|
|
|
779
781
|
|
|
780
782
|
accept_confirm { click_on "Submit" }
|
|
781
783
|
|
|
782
|
-
expect(page).to have_admin_callout("There was a problem
|
|
784
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
|
783
785
|
expect(page).to have_content("are too many")
|
|
784
786
|
|
|
785
787
|
checkboxes = page.all(".js-check-box-collection input[type=checkbox]")
|
|
@@ -792,7 +794,7 @@ shared_examples_for "has questionnaire" do
|
|
|
792
794
|
end
|
|
793
795
|
end
|
|
794
796
|
|
|
795
|
-
context "when the question is mandatory and the
|
|
797
|
+
context "when the question is mandatory and the response is not complete" do
|
|
796
798
|
let!(:mandatory) { true }
|
|
797
799
|
|
|
798
800
|
it "shows an error" do
|
|
@@ -805,7 +807,7 @@ shared_examples_for "has questionnaire" do
|
|
|
805
807
|
check "questionnaire_tos_agreement"
|
|
806
808
|
accept_confirm { click_on "Submit" }
|
|
807
809
|
|
|
808
|
-
expect(page).to have_admin_callout("There was a problem
|
|
810
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
|
809
811
|
expect(page).to have_content("Choices are not complete")
|
|
810
812
|
end
|
|
811
813
|
end
|
|
@@ -813,7 +815,7 @@ shared_examples_for "has questionnaire" do
|
|
|
813
815
|
context "when the submission is not correct" do
|
|
814
816
|
let!(:max_choices) { 2 }
|
|
815
817
|
|
|
816
|
-
it "preserves the chosen
|
|
818
|
+
it "preserves the chosen responses" do
|
|
817
819
|
visit questionnaire_public_path
|
|
818
820
|
see_questionnaire_questions
|
|
819
821
|
|
|
@@ -826,7 +828,7 @@ shared_examples_for "has questionnaire" do
|
|
|
826
828
|
check "questionnaire_tos_agreement"
|
|
827
829
|
accept_confirm { click_on "Submit" }
|
|
828
830
|
|
|
829
|
-
expect(page).to have_admin_callout("There was a problem
|
|
831
|
+
expect(page).to have_admin_callout("There was a problem responding")
|
|
830
832
|
|
|
831
833
|
checkboxes = page.all(".js-check-box-collection input[type=checkbox]")
|
|
832
834
|
expect(checkboxes.pluck(:checked)).to eq(["true", "true", "true", nil, nil, "true"])
|
|
@@ -835,7 +837,7 @@ shared_examples_for "has questionnaire" do
|
|
|
835
837
|
end
|
|
836
838
|
|
|
837
839
|
describe "display conditions" do
|
|
838
|
-
let(:
|
|
840
|
+
let(:response_options) do
|
|
839
841
|
3.times.to_a.map do |x|
|
|
840
842
|
{
|
|
841
843
|
"body" => Decidim::Faker::Localized.sentence,
|
|
@@ -855,10 +857,10 @@ shared_examples_for "has questionnaire" do
|
|
|
855
857
|
end
|
|
856
858
|
|
|
857
859
|
context "when a question has a display condition" do
|
|
858
|
-
context "when condition is of type '
|
|
860
|
+
context "when condition is of type 'responded'" do
|
|
859
861
|
let!(:display_condition) do
|
|
860
862
|
create(:display_condition,
|
|
861
|
-
condition_type: "
|
|
863
|
+
condition_type: "responded",
|
|
862
864
|
question:,
|
|
863
865
|
condition_question:)
|
|
864
866
|
end
|
|
@@ -868,8 +870,8 @@ shared_examples_for "has questionnaire" do
|
|
|
868
870
|
see_questionnaire_questions
|
|
869
871
|
end
|
|
870
872
|
|
|
871
|
-
context "when the condition_question type is short
|
|
872
|
-
let!(:condition_question_type) { "
|
|
873
|
+
context "when the condition_question type is short response" do
|
|
874
|
+
let!(:condition_question_type) { "short_response" }
|
|
873
875
|
|
|
874
876
|
it "shows the question only if the condition is fulfilled" do
|
|
875
877
|
expect_question_to_be_visible(false)
|
|
@@ -886,8 +888,8 @@ shared_examples_for "has questionnaire" do
|
|
|
886
888
|
end
|
|
887
889
|
end
|
|
888
890
|
|
|
889
|
-
context "when the condition_question type is long
|
|
890
|
-
let!(:condition_question_type) { "
|
|
891
|
+
context "when the condition_question type is long response" do
|
|
892
|
+
let!(:condition_question_type) { "long_response" }
|
|
891
893
|
let!(:conditioned_question_id) { "#questionnaire_responses_0" }
|
|
892
894
|
|
|
893
895
|
it "shows the question only if the condition is fulfilled" do
|
|
@@ -907,16 +909,16 @@ shared_examples_for "has questionnaire" do
|
|
|
907
909
|
|
|
908
910
|
context "when the condition_question type is single option" do
|
|
909
911
|
let!(:condition_question_type) { "single_option" }
|
|
910
|
-
let!(:condition_question_options) {
|
|
912
|
+
let!(:condition_question_options) { response_options }
|
|
911
913
|
|
|
912
914
|
it "shows the question only if the condition is fulfilled" do
|
|
913
915
|
expect_question_to_be_visible(false)
|
|
914
916
|
|
|
915
|
-
choose condition_question.
|
|
917
|
+
choose condition_question.response_options.first.body["en"]
|
|
916
918
|
|
|
917
919
|
expect_question_to_be_visible(true)
|
|
918
920
|
|
|
919
|
-
choose condition_question.
|
|
921
|
+
choose condition_question.response_options.second.body["en"]
|
|
920
922
|
|
|
921
923
|
expect_question_to_be_visible(false)
|
|
922
924
|
end
|
|
@@ -924,34 +926,34 @@ shared_examples_for "has questionnaire" do
|
|
|
924
926
|
|
|
925
927
|
context "when the condition_question type is multiple option" do
|
|
926
928
|
let!(:condition_question_type) { "multiple_option" }
|
|
927
|
-
let!(:condition_question_options) {
|
|
929
|
+
let!(:condition_question_options) { response_options }
|
|
928
930
|
|
|
929
931
|
it "shows the question only if the condition is fulfilled" do
|
|
930
932
|
expect_question_to_be_visible(false)
|
|
931
933
|
|
|
932
|
-
check condition_question.
|
|
934
|
+
check condition_question.response_options.first.body["en"]
|
|
933
935
|
|
|
934
936
|
expect_question_to_be_visible(true)
|
|
935
937
|
|
|
936
|
-
uncheck condition_question.
|
|
938
|
+
uncheck condition_question.response_options.first.body["en"]
|
|
937
939
|
|
|
938
940
|
expect_question_to_be_visible(false)
|
|
939
941
|
|
|
940
|
-
check condition_question.
|
|
942
|
+
check condition_question.response_options.second.body["en"]
|
|
941
943
|
|
|
942
944
|
expect_question_to_be_visible(false)
|
|
943
945
|
|
|
944
|
-
check condition_question.
|
|
946
|
+
check condition_question.response_options.first.body["en"]
|
|
945
947
|
|
|
946
948
|
expect_question_to_be_visible(true)
|
|
947
949
|
end
|
|
948
950
|
end
|
|
949
951
|
end
|
|
950
952
|
|
|
951
|
-
context "when a question has a display condition of type '
|
|
953
|
+
context "when a question has a display condition of type 'not_responded'" do
|
|
952
954
|
let!(:display_condition) do
|
|
953
955
|
create(:display_condition,
|
|
954
|
-
condition_type: "
|
|
956
|
+
condition_type: "not_responded",
|
|
955
957
|
question:,
|
|
956
958
|
condition_question:)
|
|
957
959
|
end
|
|
@@ -961,8 +963,8 @@ shared_examples_for "has questionnaire" do
|
|
|
961
963
|
see_questionnaire_questions
|
|
962
964
|
end
|
|
963
965
|
|
|
964
|
-
context "when the condition_question type is short
|
|
965
|
-
let!(:condition_question_type) { "
|
|
966
|
+
context "when the condition_question type is short response" do
|
|
967
|
+
let!(:condition_question_type) { "short_response" }
|
|
966
968
|
|
|
967
969
|
it "shows the question only if the condition is fulfilled" do
|
|
968
970
|
expect_question_to_be_visible(true)
|
|
@@ -979,8 +981,8 @@ shared_examples_for "has questionnaire" do
|
|
|
979
981
|
end
|
|
980
982
|
end
|
|
981
983
|
|
|
982
|
-
context "when the condition_question type is long
|
|
983
|
-
let!(:condition_question_type) { "
|
|
984
|
+
context "when the condition_question type is long response" do
|
|
985
|
+
let!(:condition_question_type) { "long_response" }
|
|
984
986
|
let!(:conditioned_question_id) { "#questionnaire_responses_0" }
|
|
985
987
|
|
|
986
988
|
it "shows the question only if the condition is fulfilled" do
|
|
@@ -1000,12 +1002,12 @@ shared_examples_for "has questionnaire" do
|
|
|
1000
1002
|
|
|
1001
1003
|
context "when the condition_question type is single option" do
|
|
1002
1004
|
let!(:condition_question_type) { "single_option" }
|
|
1003
|
-
let!(:condition_question_options) {
|
|
1005
|
+
let!(:condition_question_options) { response_options }
|
|
1004
1006
|
|
|
1005
1007
|
it "shows the question only if the condition is fulfilled" do
|
|
1006
1008
|
expect_question_to_be_visible(true)
|
|
1007
1009
|
|
|
1008
|
-
choose condition_question.
|
|
1010
|
+
choose condition_question.response_options.first.body["en"]
|
|
1009
1011
|
|
|
1010
1012
|
expect_question_to_be_visible(false)
|
|
1011
1013
|
end
|
|
@@ -1013,16 +1015,16 @@ shared_examples_for "has questionnaire" do
|
|
|
1013
1015
|
|
|
1014
1016
|
context "when the condition_question type is multiple option" do
|
|
1015
1017
|
let!(:condition_question_type) { "multiple_option" }
|
|
1016
|
-
let!(:condition_question_options) {
|
|
1018
|
+
let!(:condition_question_options) { response_options }
|
|
1017
1019
|
|
|
1018
1020
|
it "shows the question only if the condition is fulfilled" do
|
|
1019
1021
|
expect_question_to_be_visible(true)
|
|
1020
1022
|
|
|
1021
|
-
check condition_question.
|
|
1023
|
+
check condition_question.response_options.first.body["en"]
|
|
1022
1024
|
|
|
1023
1025
|
expect_question_to_be_visible(false)
|
|
1024
1026
|
|
|
1025
|
-
uncheck condition_question.
|
|
1027
|
+
uncheck condition_question.response_options.first.body["en"]
|
|
1026
1028
|
|
|
1027
1029
|
expect_question_to_be_visible(true)
|
|
1028
1030
|
end
|
|
@@ -1035,7 +1037,7 @@ shared_examples_for "has questionnaire" do
|
|
|
1035
1037
|
condition_type: "equal",
|
|
1036
1038
|
question:,
|
|
1037
1039
|
condition_question:,
|
|
1038
|
-
|
|
1040
|
+
response_option: condition_question.response_options.first)
|
|
1039
1041
|
end
|
|
1040
1042
|
|
|
1041
1043
|
before do
|
|
@@ -1045,16 +1047,16 @@ shared_examples_for "has questionnaire" do
|
|
|
1045
1047
|
|
|
1046
1048
|
context "when the condition_question type is single option" do
|
|
1047
1049
|
let!(:condition_question_type) { "single_option" }
|
|
1048
|
-
let!(:condition_question_options) {
|
|
1050
|
+
let!(:condition_question_options) { response_options }
|
|
1049
1051
|
|
|
1050
1052
|
it "shows the question only if the condition is fulfilled" do
|
|
1051
1053
|
expect_question_to_be_visible(false)
|
|
1052
1054
|
|
|
1053
|
-
choose condition_question.
|
|
1055
|
+
choose condition_question.response_options.first.body["en"]
|
|
1054
1056
|
|
|
1055
1057
|
expect_question_to_be_visible(true)
|
|
1056
1058
|
|
|
1057
|
-
choose condition_question.
|
|
1059
|
+
choose condition_question.response_options.second.body["en"]
|
|
1058
1060
|
|
|
1059
1061
|
expect_question_to_be_visible(false)
|
|
1060
1062
|
end
|
|
@@ -1062,24 +1064,24 @@ shared_examples_for "has questionnaire" do
|
|
|
1062
1064
|
|
|
1063
1065
|
context "when the condition_question type is multiple option" do
|
|
1064
1066
|
let!(:condition_question_type) { "multiple_option" }
|
|
1065
|
-
let!(:condition_question_options) {
|
|
1067
|
+
let!(:condition_question_options) { response_options }
|
|
1066
1068
|
|
|
1067
1069
|
it "shows the question only if the condition is fulfilled" do
|
|
1068
1070
|
expect_question_to_be_visible(false)
|
|
1069
1071
|
|
|
1070
|
-
check condition_question.
|
|
1072
|
+
check condition_question.response_options.first.body["en"]
|
|
1071
1073
|
|
|
1072
1074
|
expect_question_to_be_visible(true)
|
|
1073
1075
|
|
|
1074
|
-
uncheck condition_question.
|
|
1076
|
+
uncheck condition_question.response_options.first.body["en"]
|
|
1075
1077
|
|
|
1076
1078
|
expect_question_to_be_visible(false)
|
|
1077
1079
|
|
|
1078
|
-
check condition_question.
|
|
1080
|
+
check condition_question.response_options.second.body["en"]
|
|
1079
1081
|
|
|
1080
1082
|
expect_question_to_be_visible(false)
|
|
1081
1083
|
|
|
1082
|
-
check condition_question.
|
|
1084
|
+
check condition_question.response_options.first.body["en"]
|
|
1083
1085
|
|
|
1084
1086
|
expect_question_to_be_visible(true)
|
|
1085
1087
|
end
|
|
@@ -1092,7 +1094,7 @@ shared_examples_for "has questionnaire" do
|
|
|
1092
1094
|
condition_type: "not_equal",
|
|
1093
1095
|
question:,
|
|
1094
1096
|
condition_question:,
|
|
1095
|
-
|
|
1097
|
+
response_option: condition_question.response_options.first)
|
|
1096
1098
|
end
|
|
1097
1099
|
|
|
1098
1100
|
before do
|
|
@@ -1102,16 +1104,16 @@ shared_examples_for "has questionnaire" do
|
|
|
1102
1104
|
|
|
1103
1105
|
context "when the condition_question type is single option" do
|
|
1104
1106
|
let!(:condition_question_type) { "single_option" }
|
|
1105
|
-
let!(:condition_question_options) {
|
|
1107
|
+
let!(:condition_question_options) { response_options }
|
|
1106
1108
|
|
|
1107
1109
|
it "shows the question only if the condition is fulfilled" do
|
|
1108
1110
|
expect_question_to_be_visible(false)
|
|
1109
1111
|
|
|
1110
|
-
choose condition_question.
|
|
1112
|
+
choose condition_question.response_options.second.body["en"]
|
|
1111
1113
|
|
|
1112
1114
|
expect_question_to_be_visible(true)
|
|
1113
1115
|
|
|
1114
|
-
choose condition_question.
|
|
1116
|
+
choose condition_question.response_options.first.body["en"]
|
|
1115
1117
|
|
|
1116
1118
|
expect_question_to_be_visible(false)
|
|
1117
1119
|
end
|
|
@@ -1119,24 +1121,24 @@ shared_examples_for "has questionnaire" do
|
|
|
1119
1121
|
|
|
1120
1122
|
context "when the condition_question type is multiple option" do
|
|
1121
1123
|
let!(:condition_question_type) { "multiple_option" }
|
|
1122
|
-
let!(:condition_question_options) {
|
|
1124
|
+
let!(:condition_question_options) { response_options }
|
|
1123
1125
|
|
|
1124
1126
|
it "shows the question only if the condition is fulfilled" do
|
|
1125
1127
|
expect_question_to_be_visible(false)
|
|
1126
1128
|
|
|
1127
|
-
check condition_question.
|
|
1129
|
+
check condition_question.response_options.second.body["en"]
|
|
1128
1130
|
|
|
1129
1131
|
expect_question_to_be_visible(true)
|
|
1130
1132
|
|
|
1131
|
-
uncheck condition_question.
|
|
1133
|
+
uncheck condition_question.response_options.second.body["en"]
|
|
1132
1134
|
|
|
1133
1135
|
expect_question_to_be_visible(false)
|
|
1134
1136
|
|
|
1135
|
-
check condition_question.
|
|
1137
|
+
check condition_question.response_options.first.body["en"]
|
|
1136
1138
|
|
|
1137
1139
|
expect_question_to_be_visible(false)
|
|
1138
1140
|
|
|
1139
|
-
check condition_question.
|
|
1141
|
+
check condition_question.response_options.second.body["en"]
|
|
1140
1142
|
|
|
1141
1143
|
expect_question_to_be_visible(true)
|
|
1142
1144
|
end
|
|
@@ -1158,8 +1160,8 @@ shared_examples_for "has questionnaire" do
|
|
|
1158
1160
|
see_questionnaire_questions
|
|
1159
1161
|
end
|
|
1160
1162
|
|
|
1161
|
-
context "when the condition_question type is short
|
|
1162
|
-
let!(:condition_question_type) { "
|
|
1163
|
+
context "when the condition_question type is short response" do
|
|
1164
|
+
let!(:condition_question_type) { "short_response" }
|
|
1163
1165
|
|
|
1164
1166
|
it "shows the question only if the condition is fulfilled" do
|
|
1165
1167
|
expect_question_to_be_visible(false)
|
|
@@ -1181,8 +1183,8 @@ shared_examples_for "has questionnaire" do
|
|
|
1181
1183
|
end
|
|
1182
1184
|
end
|
|
1183
1185
|
|
|
1184
|
-
context "when the condition_question type is long
|
|
1185
|
-
let!(:condition_question_type) { "
|
|
1186
|
+
context "when the condition_question type is long response" do
|
|
1187
|
+
let!(:condition_question_type) { "long_response" }
|
|
1186
1188
|
|
|
1187
1189
|
it "shows the question only if the condition is fulfilled" do
|
|
1188
1190
|
expect_question_to_be_visible(false)
|
|
@@ -1206,13 +1208,13 @@ shared_examples_for "has questionnaire" do
|
|
|
1206
1208
|
|
|
1207
1209
|
context "when the condition_question type is single option" do
|
|
1208
1210
|
let!(:condition_question_type) { "single_option" }
|
|
1209
|
-
let!(:condition_question_options) {
|
|
1210
|
-
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 } }
|
|
1211
1213
|
|
|
1212
1214
|
it "shows the question only if the condition is fulfilled" do
|
|
1213
1215
|
expect_question_to_be_visible(false)
|
|
1214
1216
|
|
|
1215
|
-
choose condition_question.
|
|
1217
|
+
choose condition_question.response_options.first.body["en"]
|
|
1216
1218
|
|
|
1217
1219
|
expect_question_to_be_visible(true)
|
|
1218
1220
|
end
|
|
@@ -1220,22 +1222,22 @@ shared_examples_for "has questionnaire" do
|
|
|
1220
1222
|
|
|
1221
1223
|
context "when the condition_question type is single option with free text" do
|
|
1222
1224
|
let!(:condition_question_type) { "single_option" }
|
|
1223
|
-
let!(:condition_question_options) {
|
|
1225
|
+
let!(:condition_question_options) { response_options }
|
|
1224
1226
|
let!(:condition_value) { { en: "forty two" } }
|
|
1225
1227
|
|
|
1226
1228
|
it "shows the question only if the condition is fulfilled" do
|
|
1227
1229
|
expect_question_to_be_visible(false)
|
|
1228
1230
|
|
|
1229
|
-
choose condition_question.
|
|
1230
|
-
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]}"
|
|
1231
1233
|
change_focus
|
|
1232
1234
|
|
|
1233
1235
|
expect_question_to_be_visible(true)
|
|
1234
1236
|
|
|
1235
|
-
choose condition_question.
|
|
1237
|
+
choose condition_question.response_options.first.body["en"]
|
|
1236
1238
|
expect_question_to_be_visible(false)
|
|
1237
1239
|
|
|
1238
|
-
choose condition_question.
|
|
1240
|
+
choose condition_question.response_options.third.body["en"]
|
|
1239
1241
|
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "oh no not 42 again"
|
|
1240
1242
|
change_focus
|
|
1241
1243
|
|
|
@@ -1245,25 +1247,25 @@ shared_examples_for "has questionnaire" do
|
|
|
1245
1247
|
|
|
1246
1248
|
context "when the condition_question type is multiple option" do
|
|
1247
1249
|
let!(:condition_question_type) { "multiple_option" }
|
|
1248
|
-
let!(:condition_question_options) {
|
|
1250
|
+
let!(:condition_question_options) { response_options }
|
|
1249
1251
|
let!(:condition_value) { { en: "forty two" } }
|
|
1250
1252
|
|
|
1251
1253
|
it "shows the question only if the condition is fulfilled" do
|
|
1252
1254
|
expect_question_to_be_visible(false)
|
|
1253
1255
|
|
|
1254
|
-
check condition_question.
|
|
1255
|
-
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]}"
|
|
1256
1258
|
change_focus
|
|
1257
1259
|
|
|
1258
1260
|
expect_question_to_be_visible(true)
|
|
1259
1261
|
|
|
1260
|
-
check condition_question.
|
|
1262
|
+
check condition_question.response_options.first.body["en"]
|
|
1261
1263
|
expect_question_to_be_visible(true)
|
|
1262
1264
|
|
|
1263
|
-
uncheck condition_question.
|
|
1265
|
+
uncheck condition_question.response_options.third.body["en"]
|
|
1264
1266
|
expect_question_to_be_visible(false)
|
|
1265
1267
|
|
|
1266
|
-
check condition_question.
|
|
1268
|
+
check condition_question.response_options.third.body["en"]
|
|
1267
1269
|
fill_in "questionnaire_responses_0_choices_2_custom_body", with: "oh no not 42 again"
|
|
1268
1270
|
change_focus
|
|
1269
1271
|
|
|
@@ -1281,11 +1283,11 @@ shared_examples_for "has questionnaire" do
|
|
|
1281
1283
|
|
|
1282
1284
|
context "when all conditions are mandatory" do
|
|
1283
1285
|
let!(:condition_question_type) { "single_option" }
|
|
1284
|
-
let!(:condition_question_options) {
|
|
1286
|
+
let!(:condition_question_options) { response_options }
|
|
1285
1287
|
let!(:display_conditions) do
|
|
1286
1288
|
[
|
|
1287
1289
|
create(:display_condition,
|
|
1288
|
-
condition_type: "
|
|
1290
|
+
condition_type: "responded",
|
|
1289
1291
|
question:,
|
|
1290
1292
|
condition_question:,
|
|
1291
1293
|
mandatory: true),
|
|
@@ -1294,18 +1296,18 @@ shared_examples_for "has questionnaire" do
|
|
|
1294
1296
|
question:,
|
|
1295
1297
|
condition_question:,
|
|
1296
1298
|
mandatory: true,
|
|
1297
|
-
|
|
1299
|
+
response_option: condition_question.response_options.second)
|
|
1298
1300
|
]
|
|
1299
1301
|
end
|
|
1300
1302
|
|
|
1301
1303
|
it "is displayed only if all conditions are fulfilled" do
|
|
1302
1304
|
expect_question_to_be_visible(false)
|
|
1303
1305
|
|
|
1304
|
-
choose condition_question.
|
|
1306
|
+
choose condition_question.response_options.second.body["en"]
|
|
1305
1307
|
|
|
1306
1308
|
expect_question_to_be_visible(false)
|
|
1307
1309
|
|
|
1308
|
-
choose condition_question.
|
|
1310
|
+
choose condition_question.response_options.first.body["en"]
|
|
1309
1311
|
|
|
1310
1312
|
expect_question_to_be_visible(true)
|
|
1311
1313
|
end
|
|
@@ -1313,7 +1315,7 @@ shared_examples_for "has questionnaire" do
|
|
|
1313
1315
|
|
|
1314
1316
|
context "when all conditions are non-mandatory" do
|
|
1315
1317
|
let!(:condition_question_type) { "multiple_option" }
|
|
1316
|
-
let!(:condition_question_options) {
|
|
1318
|
+
let!(:condition_question_options) { response_options }
|
|
1317
1319
|
let!(:display_conditions) do
|
|
1318
1320
|
[
|
|
1319
1321
|
create(:display_condition,
|
|
@@ -1321,36 +1323,36 @@ shared_examples_for "has questionnaire" do
|
|
|
1321
1323
|
question:,
|
|
1322
1324
|
condition_question:,
|
|
1323
1325
|
mandatory: false,
|
|
1324
|
-
|
|
1326
|
+
response_option: condition_question.response_options.first),
|
|
1325
1327
|
create(:display_condition,
|
|
1326
1328
|
condition_type: "not_equal",
|
|
1327
1329
|
question:,
|
|
1328
1330
|
condition_question:,
|
|
1329
1331
|
mandatory: false,
|
|
1330
|
-
|
|
1332
|
+
response_option: condition_question.response_options.third)
|
|
1331
1333
|
]
|
|
1332
1334
|
end
|
|
1333
1335
|
|
|
1334
1336
|
it "is displayed if any of the conditions is fulfilled" do
|
|
1335
1337
|
expect_question_to_be_visible(false)
|
|
1336
1338
|
|
|
1337
|
-
check condition_question.
|
|
1339
|
+
check condition_question.response_options.first.body["en"]
|
|
1338
1340
|
|
|
1339
1341
|
expect_question_to_be_visible(true)
|
|
1340
1342
|
|
|
1341
|
-
uncheck condition_question.
|
|
1342
|
-
check condition_question.
|
|
1343
|
+
uncheck condition_question.response_options.first.body["en"]
|
|
1344
|
+
check condition_question.response_options.second.body["en"]
|
|
1343
1345
|
|
|
1344
1346
|
expect_question_to_be_visible(true)
|
|
1345
1347
|
|
|
1346
|
-
check condition_question.
|
|
1348
|
+
check condition_question.response_options.first.body["en"]
|
|
1347
1349
|
|
|
1348
1350
|
expect_question_to_be_visible(true)
|
|
1349
1351
|
end
|
|
1350
1352
|
end
|
|
1351
1353
|
|
|
1352
1354
|
context "when a mandatory question has conditions that have not been fulfilled" do
|
|
1353
|
-
let!(:condition_question_type) { "
|
|
1355
|
+
let!(:condition_question_type) { "short_response" }
|
|
1354
1356
|
let!(:question) { create(:questionnaire_question, questionnaire:, position: 2, mandatory: true) }
|
|
1355
1357
|
let!(:display_conditions) do
|
|
1356
1358
|
[
|
|
@@ -1367,7 +1369,7 @@ shared_examples_for "has questionnaire" do
|
|
|
1367
1369
|
visit questionnaire_public_path
|
|
1368
1370
|
see_questionnaire_questions
|
|
1369
1371
|
|
|
1370
|
-
fill_in condition_question.body["en"], with: "My first
|
|
1372
|
+
fill_in condition_question.body["en"], with: "My first response"
|
|
1371
1373
|
|
|
1372
1374
|
check "questionnaire_tos_agreement"
|
|
1373
1375
|
|