decidim-forms 0.29.1 → 0.30.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/forms/step_navigation_cell.rb +18 -5
- data/app/commands/decidim/forms/admin/update_questionnaire.rb +1 -82
- data/app/commands/decidim/forms/admin/update_questions.rb +109 -0
- data/app/commands/decidim/forms/answer_questionnaire.rb +10 -3
- data/app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb +39 -3
- data/app/controllers/decidim/forms/admin/concerns/has_questionnaire_answers.rb +2 -2
- data/app/controllers/decidim/forms/concerns/has_questionnaire.rb +12 -4
- data/app/forms/decidim/forms/admin/display_condition_form.rb +1 -1
- data/app/forms/decidim/forms/admin/questionnaire_form.rb +2 -11
- data/app/forms/decidim/forms/admin/questions_form.rb +18 -0
- data/app/forms/decidim/forms/answer_choice_form.rb +5 -0
- data/app/forms/decidim/forms/answer_form.rb +1 -0
- data/app/forms/decidim/forms/questionnaire_form.rb +7 -0
- data/app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_pagination_helper.rb +1 -1
- data/app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_url_helper.rb +5 -5
- data/app/jobs/decidim/forms/export_questionnaire_answers_job.rb +5 -1
- data/app/models/decidim/forms/answer_option.rb +1 -1
- data/app/models/decidim/forms/question.rb +10 -0
- data/app/packs/entrypoints/decidim_forms.js +0 -1
- data/app/packs/entrypoints/decidim_forms_admin.js +6 -0
- data/app/packs/src/decidim/forms/admin/publish_answers_buttons.js +72 -0
- data/app/packs/src/decidim/forms/forms.js +22 -18
- data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +1 -1
- data/app/presenters/decidim/forms/admin_log/question_presenter.rb +31 -0
- data/app/queries/decidim/forms/questionnaire_user_answers.rb +1 -1
- data/app/views/decidim/forms/admin/questionnaires/_answer_option_template.html.erb +1 -1
- data/app/views/decidim/forms/admin/questionnaires/_display_condition_template.html.erb +1 -1
- data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +0 -89
- data/app/views/decidim/forms/admin/questionnaires/_matrix_row_template.html.erb +1 -1
- data/app/views/decidim/forms/admin/questionnaires/_question.html.erb +3 -3
- data/app/views/decidim/forms/admin/questionnaires/_questions_form.html.erb +80 -0
- data/app/views/decidim/forms/admin/questionnaires/edit.html.erb +0 -20
- data/app/views/decidim/forms/admin/questionnaires/edit_questions.html.erb +47 -0
- data/app/views/decidim/forms/questionnaires/_answer.html.erb +11 -1
- data/app/views/decidim/forms/questionnaires/_questionnaire.html.erb +8 -1
- data/app/views/decidim/forms/questionnaires/answers/_files.html.erb +1 -1
- data/app/views/decidim/forms/questionnaires/answers/_sorting.html.erb +12 -6
- data/app/views/decidim/forms/questionnaires/edit.html.erb +47 -0
- data/app/views/decidim/forms/questionnaires/show.html.erb +13 -2
- data/config/assets.rb +1 -2
- data/config/locales/ar.yml +3 -2
- data/config/locales/bg.yml +0 -7
- data/config/locales/bn-BD.yml +1 -0
- data/config/locales/bs-BA.yml +1 -0
- data/config/locales/ca.yml +46 -6
- data/config/locales/cs.yml +45 -5
- data/config/locales/de.yml +47 -7
- data/config/locales/el.yml +0 -7
- data/config/locales/en.yml +45 -5
- data/config/locales/es-MX.yml +45 -5
- data/config/locales/es-PY.yml +45 -5
- data/config/locales/es.yml +45 -5
- data/config/locales/eu.yml +50 -10
- data/config/locales/fi-plain.yml +45 -5
- data/config/locales/fi.yml +45 -5
- data/config/locales/fr-CA.yml +37 -5
- data/config/locales/fr.yml +37 -5
- data/config/locales/gl.yml +0 -3
- data/config/locales/hu.yml +0 -3
- data/config/locales/id-ID.yml +0 -2
- data/config/locales/it.yml +0 -4
- data/config/locales/ja.yml +1 -6
- data/config/locales/lb.yml +0 -4
- data/config/locales/lt.yml +0 -7
- data/config/locales/lv.yml +0 -3
- data/config/locales/nl.yml +0 -5
- data/config/locales/no.yml +0 -5
- data/config/locales/pl.yml +0 -7
- data/config/locales/pt-BR.yml +0 -5
- data/config/locales/pt.yml +0 -4
- data/config/locales/ro-RO.yml +8 -7
- data/config/locales/sk.yml +0 -2
- data/config/locales/sv.yml +0 -5
- data/config/locales/tr-TR.yml +0 -4
- data/config/locales/val-ES.yml +0 -2
- data/config/locales/zh-CN.yml +0 -4
- data/config/locales/zh-TW.yml +0 -7
- data/db/migrate/20190315203056_add_session_token_to_decidim_forms_answers.rb +1 -1
- data/db/migrate/20241122142230_add_survey_answers_published_at_to_questions.rb +7 -0
- data/decidim-forms.gemspec +2 -7
- data/lib/decidim/api/answer_option_type.rb +1 -1
- data/lib/decidim/api/question_type.rb +4 -4
- data/lib/decidim/api/questionnaire_type.rb +4 -4
- data/lib/decidim/exporters/form_pdf.rb +114 -11
- data/lib/decidim/forms/download_your_data_user_answers_serializer.rb +0 -4
- data/lib/decidim/forms/test/factories.rb +2 -2
- data/lib/decidim/forms/test/shared_examples/has_questionnaire.rb +70 -4
- data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +17 -17
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_display_conditions.rb +19 -21
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +70 -94
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb +15 -18
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +90 -125
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +4 -25
- data/lib/decidim/forms/user_answers_serializer.rb +1 -1
- data/lib/decidim/forms/version.rb +1 -1
- data/lib/decidim/forms.rb +0 -1
- metadata +21 -47
- data/app/packs/entrypoints/decidim_questionnaire_answers_pdf.js +0 -1
- data/app/packs/entrypoints/decidim_questionnaire_answers_pdf.scss +0 -1
- data/app/packs/stylesheets/decidim/forms/questionnaire-answers-pdf.scss +0 -69
- data/app/views/decidim/forms/admin/questionnaires/answers/export/_answer.html.erb +0 -31
- data/app/views/decidim/forms/admin/questionnaires/answers/export/pdf.html.erb +0 -13
- data/app/views/layouts/decidim/forms/admin/questionnaires/questionnaire_answers.html.erb +0 -12
- data/config/initializers/wicked_pdf.rb +0 -27
- data/lib/decidim/exporters/form_pdf_controller_helper.rb +0 -13
@@ -6,6 +6,7 @@ shared_examples_for "has questionnaire" do
|
|
6
6
|
context "when the user is not logged in" do
|
7
7
|
it "does not allow answering the questionnaire" do
|
8
8
|
visit questionnaire_public_path
|
9
|
+
see_questionnaire_questions
|
9
10
|
|
10
11
|
expect(page).to have_i18n_content(questionnaire.title)
|
11
12
|
expect(page).to have_i18n_content(questionnaire.description, strip_tags: true)
|
@@ -30,6 +31,7 @@ shared_examples_for "has questionnaire" do
|
|
30
31
|
|
31
32
|
it "shows an empty page with a message" do
|
32
33
|
visit questionnaire_public_path
|
34
|
+
see_questionnaire_questions
|
33
35
|
|
34
36
|
expect(page).to have_content("No questions configured for this form yet.")
|
35
37
|
end
|
@@ -41,6 +43,8 @@ shared_examples_for "has questionnaire" do
|
|
41
43
|
expect(page).to have_i18n_content(questionnaire.title)
|
42
44
|
expect(page).to have_i18n_content(questionnaire.description, strip_tags: true)
|
43
45
|
|
46
|
+
see_questionnaire_questions
|
47
|
+
|
44
48
|
fill_in question.body["en"], with: "My first answer"
|
45
49
|
|
46
50
|
check "questionnaire_tos_agreement"
|
@@ -52,17 +56,46 @@ shared_examples_for "has questionnaire" do
|
|
52
56
|
expect(page).to have_admin_callout(callout_success)
|
53
57
|
|
54
58
|
visit questionnaire_public_path
|
59
|
+
see_questionnaire_questions
|
55
60
|
|
56
61
|
expect(page).to have_content("You have already answered this form.")
|
57
62
|
expect(page).to have_no_i18n_content(question.body)
|
58
63
|
end
|
59
64
|
|
65
|
+
context "and there is a mandatory question" do
|
66
|
+
let!(:question) do
|
67
|
+
create(
|
68
|
+
:questionnaire_question,
|
69
|
+
questionnaire:,
|
70
|
+
question_type: "short_answer",
|
71
|
+
position: 0,
|
72
|
+
mandatory: true
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
before do
|
77
|
+
visit questionnaire_public_path
|
78
|
+
end
|
79
|
+
|
80
|
+
it "it renders the asterisk as a separated element" do
|
81
|
+
see_questionnaire_questions
|
82
|
+
within "label.answer-questionnaire__question-label" do
|
83
|
+
expect(page).to have_content(translated_attribute(question.body).to_s)
|
84
|
+
within "span.label-required.has-tip" do
|
85
|
+
expect(page).to have_content("*")
|
86
|
+
expect(page).to have_content("Required field")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
60
92
|
context "with multiple steps" do
|
61
93
|
let!(:separator) { create(:questionnaire_question, questionnaire:, position: 1, question_type: :separator) }
|
62
94
|
let!(:question2) { create(:questionnaire_question, questionnaire:, position: 2) }
|
63
95
|
|
64
96
|
before do
|
65
97
|
visit questionnaire_public_path
|
98
|
+
see_questionnaire_questions
|
66
99
|
end
|
67
100
|
|
68
101
|
it "allows answering the first questionnaire" do
|
@@ -95,6 +128,7 @@ shared_examples_for "has questionnaire" do
|
|
95
128
|
expect(page).to have_admin_callout(callout_success)
|
96
129
|
|
97
130
|
visit questionnaire_public_path
|
131
|
+
see_questionnaire_questions
|
98
132
|
|
99
133
|
expect(page).to have_content("You have already answered this form.")
|
100
134
|
end
|
@@ -112,14 +146,13 @@ shared_examples_for "has questionnaire" do
|
|
112
146
|
|
113
147
|
it "requires confirmation when exiting mid-answering" do
|
114
148
|
visit questionnaire_public_path
|
149
|
+
see_questionnaire_questions
|
115
150
|
|
116
151
|
fill_in question.body["en"], with: "My first answer"
|
117
152
|
|
118
|
-
|
119
|
-
page.find(".main-bar__logo a").click
|
120
|
-
end
|
153
|
+
click_on translated_attribute(component.name)
|
121
154
|
|
122
|
-
expect(page).to have_current_path
|
155
|
+
expect(page).to have_current_path(questionnaire_public_path)
|
123
156
|
end
|
124
157
|
|
125
158
|
context "when the questionnaire has already been answered by someone else" do
|
@@ -147,6 +180,7 @@ shared_examples_for "has questionnaire" do
|
|
147
180
|
|
148
181
|
it "does not leak defaults from other answers" do
|
149
182
|
visit questionnaire_public_path
|
183
|
+
see_questionnaire_questions
|
150
184
|
|
151
185
|
expect(page).to have_no_field(type: "radio", checked: true)
|
152
186
|
end
|
@@ -169,6 +203,7 @@ shared_examples_for "has questionnaire" do
|
|
169
203
|
|
170
204
|
before do
|
171
205
|
visit questionnaire_public_path
|
206
|
+
see_questionnaire_questions
|
172
207
|
end
|
173
208
|
|
174
209
|
it_behaves_like "a correctly ordered questionnaire"
|
@@ -179,6 +214,7 @@ shared_examples_for "has questionnaire" do
|
|
179
214
|
|
180
215
|
before do
|
181
216
|
visit questionnaire_public_path
|
217
|
+
see_questionnaire_questions
|
182
218
|
accept_confirm { click_on "Submit" }
|
183
219
|
end
|
184
220
|
|
@@ -198,6 +234,7 @@ shared_examples_for "has questionnaire" do
|
|
198
234
|
|
199
235
|
before do
|
200
236
|
visit questionnaire_public_path
|
237
|
+
see_questionnaire_questions
|
201
238
|
|
202
239
|
check "questionnaire_tos_agreement"
|
203
240
|
end
|
@@ -209,6 +246,7 @@ shared_examples_for "has questionnaire" do
|
|
209
246
|
|
210
247
|
it "shows a message indicating number of characters left" do
|
211
248
|
visit questionnaire_public_path
|
249
|
+
see_questionnaire_questions
|
212
250
|
|
213
251
|
expect(page).to have_content("30 characters left")
|
214
252
|
end
|
@@ -272,6 +310,7 @@ shared_examples_for "has questionnaire" do
|
|
272
310
|
|
273
311
|
before do
|
274
312
|
visit questionnaire_public_path
|
313
|
+
see_questionnaire_questions
|
275
314
|
|
276
315
|
check "questionnaire_tos_agreement"
|
277
316
|
|
@@ -289,6 +328,7 @@ shared_examples_for "has questionnaire" do
|
|
289
328
|
|
290
329
|
it "properly interprets HTML descriptions" do
|
291
330
|
visit questionnaire_public_path
|
331
|
+
see_questionnaire_questions
|
292
332
|
|
293
333
|
expect(page).to have_css("b", text: "This question is important")
|
294
334
|
end
|
@@ -329,6 +369,7 @@ shared_examples_for "has questionnaire" do
|
|
329
369
|
|
330
370
|
before do
|
331
371
|
visit questionnaire_public_path
|
372
|
+
see_questionnaire_questions
|
332
373
|
end
|
333
374
|
|
334
375
|
context "when question is single_option type" do
|
@@ -422,6 +463,7 @@ shared_examples_for "has questionnaire" do
|
|
422
463
|
|
423
464
|
it "renders the answer as a textarea" do
|
424
465
|
visit questionnaire_public_path
|
466
|
+
see_questionnaire_questions
|
425
467
|
|
426
468
|
expect(page).to have_css("textarea#questionnaire_responses_0")
|
427
469
|
end
|
@@ -435,6 +477,7 @@ shared_examples_for "has questionnaire" do
|
|
435
477
|
|
436
478
|
it "renders the answer as a text field" do
|
437
479
|
visit questionnaire_public_path
|
480
|
+
see_questionnaire_questions
|
438
481
|
|
439
482
|
expect(page).to have_field(id: "questionnaire_responses_0")
|
440
483
|
end
|
@@ -448,6 +491,7 @@ shared_examples_for "has questionnaire" do
|
|
448
491
|
|
449
492
|
it "renders answers as a collection of radio buttons" do
|
450
493
|
visit questionnaire_public_path
|
494
|
+
see_questionnaire_questions
|
451
495
|
|
452
496
|
expect(page).to have_css(".js-radio-button-collection input[type=radio]", count: 2)
|
453
497
|
|
@@ -460,6 +504,7 @@ shared_examples_for "has questionnaire" do
|
|
460
504
|
expect(page).to have_admin_callout(callout_success)
|
461
505
|
|
462
506
|
visit questionnaire_public_path
|
507
|
+
see_questionnaire_questions
|
463
508
|
|
464
509
|
expect(page).to have_content("You have already answered this form.")
|
465
510
|
expect(page).to have_no_i18n_content(question.body)
|
@@ -472,6 +517,7 @@ shared_examples_for "has questionnaire" do
|
|
472
517
|
|
473
518
|
it "renders answers as a collection of radio buttons" do
|
474
519
|
visit questionnaire_public_path
|
520
|
+
see_questionnaire_questions
|
475
521
|
|
476
522
|
expect(page).to have_css(".js-check-box-collection input[type=checkbox]", count: 3)
|
477
523
|
|
@@ -487,6 +533,7 @@ shared_examples_for "has questionnaire" do
|
|
487
533
|
expect(page).to have_admin_callout(callout_success)
|
488
534
|
|
489
535
|
visit questionnaire_public_path
|
536
|
+
see_questionnaire_questions
|
490
537
|
|
491
538
|
expect(page).to have_content("You have already answered this form.")
|
492
539
|
expect(page).to have_no_i18n_content(question.body)
|
@@ -496,6 +543,7 @@ shared_examples_for "has questionnaire" do
|
|
496
543
|
question.update!(max_choices: 2)
|
497
544
|
|
498
545
|
visit questionnaire_public_path
|
546
|
+
see_questionnaire_questions
|
499
547
|
|
500
548
|
expect(page).to have_content("Max choices: 2")
|
501
549
|
|
@@ -538,6 +586,7 @@ shared_examples_for "has questionnaire" do
|
|
538
586
|
|
539
587
|
it "renders the question answers as a collection of divs sortable on drag and drop" do
|
540
588
|
visit questionnaire_public_path
|
589
|
+
see_questionnaire_questions
|
541
590
|
|
542
591
|
expect(page).to have_css("div.answer-questionnaire__sorting.js-collection-input", count: 5)
|
543
592
|
|
@@ -548,6 +597,7 @@ shared_examples_for "has questionnaire" do
|
|
548
597
|
|
549
598
|
it "properly saves valid sortings" do
|
550
599
|
visit questionnaire_public_path
|
600
|
+
see_questionnaire_questions
|
551
601
|
|
552
602
|
%w(We all like dark chocolate).reverse.each do |text|
|
553
603
|
find("div.answer-questionnaire__sorting", text:).drag_to(find("div.answer-questionnaire__sorting", match: :first))
|
@@ -582,6 +632,7 @@ shared_examples_for "has questionnaire" do
|
|
582
632
|
|
583
633
|
it "renders the question answers as a collection of radio buttons" do
|
584
634
|
visit questionnaire_public_path
|
635
|
+
see_questionnaire_questions
|
585
636
|
|
586
637
|
expect(page).to have_css(".js-radio-button-collection input[type=radio]", count: 4)
|
587
638
|
|
@@ -600,6 +651,7 @@ shared_examples_for "has questionnaire" do
|
|
600
651
|
expect(page).to have_admin_callout(callout_success)
|
601
652
|
|
602
653
|
visit questionnaire_public_path
|
654
|
+
see_questionnaire_questions
|
603
655
|
|
604
656
|
expect(page).to have_content("You have already answered this form.")
|
605
657
|
expect(page).to have_no_i18n_content(question.body)
|
@@ -612,6 +664,7 @@ shared_examples_for "has questionnaire" do
|
|
612
664
|
|
613
665
|
it "preserves the chosen answers if submission not correct" do
|
614
666
|
visit questionnaire_public_path
|
667
|
+
see_questionnaire_questions
|
615
668
|
|
616
669
|
radio_buttons = page.all(".js-radio-button-collection input[type=radio]")
|
617
670
|
choose radio_buttons[1][:id]
|
@@ -629,6 +682,7 @@ shared_examples_for "has questionnaire" do
|
|
629
682
|
|
630
683
|
it "shows an error if the question is mandatory and the answer is not complete" do
|
631
684
|
visit questionnaire_public_path
|
685
|
+
see_questionnaire_questions
|
632
686
|
|
633
687
|
radio_buttons = page.all(".js-radio-button-collection input[type=radio]")
|
634
688
|
choose radio_buttons[0][:id]
|
@@ -662,6 +716,7 @@ shared_examples_for "has questionnaire" do
|
|
662
716
|
|
663
717
|
it "renders the question answers as a collection of check boxes" do
|
664
718
|
visit questionnaire_public_path
|
719
|
+
see_questionnaire_questions
|
665
720
|
|
666
721
|
expect(page).to have_css(".js-check-box-collection input[type=checkbox]", count: 6)
|
667
722
|
|
@@ -681,6 +736,7 @@ shared_examples_for "has questionnaire" do
|
|
681
736
|
expect(page).to have_admin_callout(callout_success)
|
682
737
|
|
683
738
|
visit questionnaire_public_path
|
739
|
+
see_questionnaire_questions
|
684
740
|
|
685
741
|
expect(page).to have_content("You have already answered this form.")
|
686
742
|
expect(page).to have_no_i18n_content(question.body)
|
@@ -697,6 +753,7 @@ shared_examples_for "has questionnaire" do
|
|
697
753
|
|
698
754
|
it "respects the max number of choices" do
|
699
755
|
visit questionnaire_public_path
|
756
|
+
see_questionnaire_questions
|
700
757
|
|
701
758
|
expect(page).to have_content("Max choices: 2")
|
702
759
|
|
@@ -741,6 +798,7 @@ shared_examples_for "has questionnaire" do
|
|
741
798
|
|
742
799
|
it "shows an error" do
|
743
800
|
visit questionnaire_public_path
|
801
|
+
see_questionnaire_questions
|
744
802
|
|
745
803
|
checkboxes = page.all(".js-check-box-collection input[type=checkbox]")
|
746
804
|
check checkboxes[0][:id]
|
@@ -758,6 +816,7 @@ shared_examples_for "has questionnaire" do
|
|
758
816
|
|
759
817
|
it "preserves the chosen answers" do
|
760
818
|
visit questionnaire_public_path
|
819
|
+
see_questionnaire_questions
|
761
820
|
|
762
821
|
checkboxes = page.all(".js-check-box-collection input[type=checkbox]")
|
763
822
|
check checkboxes[0][:id]
|
@@ -807,6 +866,7 @@ shared_examples_for "has questionnaire" do
|
|
807
866
|
|
808
867
|
before do
|
809
868
|
visit questionnaire_public_path
|
869
|
+
see_questionnaire_questions
|
810
870
|
end
|
811
871
|
|
812
872
|
context "when the condition_question type is short answer" do
|
@@ -899,6 +959,7 @@ shared_examples_for "has questionnaire" do
|
|
899
959
|
|
900
960
|
before do
|
901
961
|
visit questionnaire_public_path
|
962
|
+
see_questionnaire_questions
|
902
963
|
end
|
903
964
|
|
904
965
|
context "when the condition_question type is short answer" do
|
@@ -980,6 +1041,7 @@ shared_examples_for "has questionnaire" do
|
|
980
1041
|
|
981
1042
|
before do
|
982
1043
|
visit questionnaire_public_path
|
1044
|
+
see_questionnaire_questions
|
983
1045
|
end
|
984
1046
|
|
985
1047
|
context "when the condition_question type is single option" do
|
@@ -1036,6 +1098,7 @@ shared_examples_for "has questionnaire" do
|
|
1036
1098
|
|
1037
1099
|
before do
|
1038
1100
|
visit questionnaire_public_path
|
1101
|
+
see_questionnaire_questions
|
1039
1102
|
end
|
1040
1103
|
|
1041
1104
|
context "when the condition_question type is single option" do
|
@@ -1093,6 +1156,7 @@ shared_examples_for "has questionnaire" do
|
|
1093
1156
|
|
1094
1157
|
before do
|
1095
1158
|
visit questionnaire_public_path
|
1159
|
+
see_questionnaire_questions
|
1096
1160
|
end
|
1097
1161
|
|
1098
1162
|
context "when the condition_question type is short answer" do
|
@@ -1213,6 +1277,7 @@ shared_examples_for "has questionnaire" do
|
|
1213
1277
|
context "when a question has multiple display conditions" do
|
1214
1278
|
before do
|
1215
1279
|
visit questionnaire_public_path
|
1280
|
+
see_questionnaire_questions
|
1216
1281
|
end
|
1217
1282
|
|
1218
1283
|
context "when all conditions are mandatory" do
|
@@ -1301,6 +1366,7 @@ shared_examples_for "has questionnaire" do
|
|
1301
1366
|
|
1302
1367
|
it "does not throw error" do
|
1303
1368
|
visit questionnaire_public_path
|
1369
|
+
see_questionnaire_questions
|
1304
1370
|
|
1305
1371
|
fill_in condition_question.body["en"], with: "My first answer"
|
1306
1372
|
|
@@ -5,13 +5,13 @@ require "spec_helper"
|
|
5
5
|
shared_examples_for "manage questionnaire answers" do
|
6
6
|
let(:first_type) { "short_answer" }
|
7
7
|
let!(:first) do
|
8
|
-
create
|
8
|
+
create(:questionnaire_question, questionnaire:, position: 1, question_type: first_type)
|
9
9
|
end
|
10
10
|
let!(:second) do
|
11
|
-
create
|
11
|
+
create(:questionnaire_question, questionnaire:, position: 2, question_type: "single_option")
|
12
12
|
end
|
13
13
|
let!(:third) do
|
14
|
-
create
|
14
|
+
create(:questionnaire_question, questionnaire:, position: 3, question_type: "files")
|
15
15
|
end
|
16
16
|
let(:questions) do
|
17
17
|
[first, second, third]
|
@@ -19,25 +19,25 @@ shared_examples_for "manage questionnaire answers" do
|
|
19
19
|
|
20
20
|
context "when there are no answers" do
|
21
21
|
it "do not answer admin link" do
|
22
|
-
|
22
|
+
click_on "Manage questions"
|
23
23
|
expect(page).to have_content("No answers yet")
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
context "when there are answers" do
|
28
|
-
let!(:answer1) { create
|
29
|
-
let!(:answer2) { create
|
30
|
-
let!(:answer3) { create
|
31
|
-
let!(:file_answer) { create
|
28
|
+
let!(:answer1) { create(:answer, questionnaire:, question: first) }
|
29
|
+
let!(:answer2) { create(:answer, body: "second answer", questionnaire:, question: first) }
|
30
|
+
let!(:answer3) { create(:answer, questionnaire:, question: second) }
|
31
|
+
let!(:file_answer) { create(:answer, :with_attachments, questionnaire:, question: third, body: nil, user: answer3.user, session_token: answer3.session_token) }
|
32
32
|
|
33
33
|
it "shows the answer admin link" do
|
34
|
-
|
34
|
+
click_on "Manage questions"
|
35
35
|
expect(page).to have_content("Show responses")
|
36
36
|
end
|
37
37
|
|
38
38
|
context "and managing answers page" do
|
39
39
|
before do
|
40
|
-
|
40
|
+
click_on "Manage questions"
|
41
41
|
click_on "Show responses"
|
42
42
|
end
|
43
43
|
|
@@ -76,9 +76,9 @@ shared_examples_for "manage questionnaire answers" do
|
|
76
76
|
|
77
77
|
context "when multiple answer choice" do
|
78
78
|
let(:first_type) { "multiple_option" }
|
79
|
-
let!(:answer1) { create
|
80
|
-
let!(:answer_option) { create
|
81
|
-
let!(:answer_choice) { create
|
79
|
+
let!(:answer1) { create(:answer, questionnaire:, question: first, body: nil) }
|
80
|
+
let!(:answer_option) { create(:answer_option, question: first) }
|
81
|
+
let!(:answer_choice) { create(:answer_choice, answer: answer1, answer_option:, body: translated(answer_option.body, locale: I18n.locale)) }
|
82
82
|
|
83
83
|
it "shows the answers page with custom body" do
|
84
84
|
new_window = window_opened_by { find_all("a.action-icon.action-icon--eye").first.click }
|
@@ -94,10 +94,10 @@ shared_examples_for "manage questionnaire answers" do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
context "and managing individual answer page" do
|
97
|
-
let!(:answer11) { create
|
97
|
+
let!(:answer11) { create(:answer, questionnaire:, body: "", user: answer1.user, question: second) }
|
98
98
|
|
99
99
|
before do
|
100
|
-
|
100
|
+
click_on "Manage questions"
|
101
101
|
click_on "Show responses"
|
102
102
|
end
|
103
103
|
|
@@ -133,10 +133,10 @@ shared_examples_for "manage questionnaire answers" do
|
|
133
133
|
end
|
134
134
|
|
135
135
|
context "when the file answer does not have a title for the attachment" do
|
136
|
-
let!(:file_answer) { create
|
136
|
+
let!(:file_answer) { create(:answer, questionnaire:, question: third, body: nil, user: answer3.user, session_token: answer3.session_token) }
|
137
137
|
|
138
138
|
before do
|
139
|
-
create
|
139
|
+
create(:attachment, :with_image, attached_to: file_answer, title: {}, description: {})
|
140
140
|
end
|
141
141
|
|
142
142
|
it "third answer has download link for the attachments" do
|
@@ -17,7 +17,8 @@ shared_examples_for "add display conditions" do
|
|
17
17
|
let!(:question) { create(:questionnaire_question, questionnaire:, body:, question_type: "short_answer") }
|
18
18
|
|
19
19
|
before do
|
20
|
-
|
20
|
+
click_on "Save"
|
21
|
+
visit_manage_questions_and_expand_all
|
21
22
|
end
|
22
23
|
|
23
24
|
it "does not display an add display condition button" do
|
@@ -26,12 +27,10 @@ shared_examples_for "add display conditions" do
|
|
26
27
|
|
27
28
|
context "when creating a new question" do
|
28
29
|
it "disables the add display condition button if the question has not been saved" do
|
29
|
-
|
30
|
-
|
31
|
-
expand_all_questions
|
30
|
+
click_on "Add question"
|
31
|
+
expand_all_questions
|
32
32
|
|
33
|
-
|
34
|
-
end
|
33
|
+
expect(page).to have_button("Add display condition", disabled: true)
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
@@ -71,29 +70,28 @@ shared_examples_for "add display conditions" do
|
|
71
70
|
let(:questions) { [question_short_answer, question_long_answer, question_single_option, question_multiple_option] }
|
72
71
|
|
73
72
|
before do
|
74
|
-
|
73
|
+
click_on "Save"
|
74
|
+
visit_manage_questions_and_expand_all
|
75
75
|
end
|
76
76
|
|
77
77
|
context "when clicking add display condition button" do
|
78
78
|
it "adds a new display condition form with all correct elements" do
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
expect(page).to have_css("[id$=mandatory]")
|
79
|
+
within_add_display_condition do
|
80
|
+
expect(page).to have_select("Question")
|
81
|
+
expect(page).to have_select("Condition")
|
82
|
+
expect(page).to have_css("[id$=mandatory]")
|
84
83
|
|
85
|
-
|
86
|
-
|
84
|
+
select question_single_option.body["en"], from: "Question"
|
85
|
+
select "Answered", from: "Condition"
|
87
86
|
|
88
|
-
|
89
|
-
|
87
|
+
expect(page).to have_no_select("Answer option")
|
88
|
+
expect(page).to have_no_css("[id$=condition_value_en]", visible: :visible)
|
90
89
|
|
91
|
-
|
92
|
-
|
90
|
+
select question_single_option.body["en"], from: "Question"
|
91
|
+
select "Equal", from: "Condition"
|
93
92
|
|
94
|
-
|
95
|
-
|
96
|
-
end
|
93
|
+
expect(page).to have_select("Answer option")
|
94
|
+
expect(page).to have_no_css("[id$=condition_value_en]", visible: :visible)
|
97
95
|
end
|
98
96
|
end
|
99
97
|
|