decidim-forms 0.29.2 → 0.30.0.rc2
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/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 +0 -9
- 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_choice.rb +0 -2
- 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/_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/bg.yml +0 -2
- data/config/locales/ca.yml +46 -6
- data/config/locales/cs.yml +45 -5
- data/config/locales/de.yml +45 -5
- data/config/locales/el.yml +0 -2
- 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 +45 -5
- 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/ja.yml +46 -1
- data/config/locales/lt.yml +0 -2
- data/config/locales/pl.yml +0 -2
- data/config/locales/ro-RO.yml +22 -17
- data/config/locales/zh-TW.yml +0 -2
- 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 +1 -2
- 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 +44 -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/version.rb +1 -1
- data/lib/decidim/forms.rb +0 -1
- metadata +18 -32
- 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 -26
- 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,6 +56,7 @@ 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)
|
@@ -73,6 +78,7 @@ shared_examples_for "has questionnaire" do
|
|
73
78
|
end
|
74
79
|
|
75
80
|
it "it renders the asterisk as a separated element" do
|
81
|
+
see_questionnaire_questions
|
76
82
|
within "label.answer-questionnaire__question-label" do
|
77
83
|
expect(page).to have_content(translated_attribute(question.body).to_s)
|
78
84
|
within "span.label-required.has-tip" do
|
@@ -89,6 +95,7 @@ shared_examples_for "has questionnaire" do
|
|
89
95
|
|
90
96
|
before do
|
91
97
|
visit questionnaire_public_path
|
98
|
+
see_questionnaire_questions
|
92
99
|
end
|
93
100
|
|
94
101
|
it "allows answering the first questionnaire" do
|
@@ -121,6 +128,7 @@ shared_examples_for "has questionnaire" do
|
|
121
128
|
expect(page).to have_admin_callout(callout_success)
|
122
129
|
|
123
130
|
visit questionnaire_public_path
|
131
|
+
see_questionnaire_questions
|
124
132
|
|
125
133
|
expect(page).to have_content("You have already answered this form.")
|
126
134
|
end
|
@@ -138,14 +146,13 @@ shared_examples_for "has questionnaire" do
|
|
138
146
|
|
139
147
|
it "requires confirmation when exiting mid-answering" do
|
140
148
|
visit questionnaire_public_path
|
149
|
+
see_questionnaire_questions
|
141
150
|
|
142
151
|
fill_in question.body["en"], with: "My first answer"
|
143
152
|
|
144
|
-
|
145
|
-
page.find(".main-bar__logo a").click
|
146
|
-
end
|
153
|
+
click_on translated_attribute(component.name)
|
147
154
|
|
148
|
-
expect(page).to have_current_path
|
155
|
+
expect(page).to have_current_path(questionnaire_public_path)
|
149
156
|
end
|
150
157
|
|
151
158
|
context "when the questionnaire has already been answered by someone else" do
|
@@ -173,6 +180,7 @@ shared_examples_for "has questionnaire" do
|
|
173
180
|
|
174
181
|
it "does not leak defaults from other answers" do
|
175
182
|
visit questionnaire_public_path
|
183
|
+
see_questionnaire_questions
|
176
184
|
|
177
185
|
expect(page).to have_no_field(type: "radio", checked: true)
|
178
186
|
end
|
@@ -195,6 +203,7 @@ shared_examples_for "has questionnaire" do
|
|
195
203
|
|
196
204
|
before do
|
197
205
|
visit questionnaire_public_path
|
206
|
+
see_questionnaire_questions
|
198
207
|
end
|
199
208
|
|
200
209
|
it_behaves_like "a correctly ordered questionnaire"
|
@@ -205,6 +214,7 @@ shared_examples_for "has questionnaire" do
|
|
205
214
|
|
206
215
|
before do
|
207
216
|
visit questionnaire_public_path
|
217
|
+
see_questionnaire_questions
|
208
218
|
accept_confirm { click_on "Submit" }
|
209
219
|
end
|
210
220
|
|
@@ -224,6 +234,7 @@ shared_examples_for "has questionnaire" do
|
|
224
234
|
|
225
235
|
before do
|
226
236
|
visit questionnaire_public_path
|
237
|
+
see_questionnaire_questions
|
227
238
|
|
228
239
|
check "questionnaire_tos_agreement"
|
229
240
|
end
|
@@ -235,6 +246,7 @@ shared_examples_for "has questionnaire" do
|
|
235
246
|
|
236
247
|
it "shows a message indicating number of characters left" do
|
237
248
|
visit questionnaire_public_path
|
249
|
+
see_questionnaire_questions
|
238
250
|
|
239
251
|
expect(page).to have_content("30 characters left")
|
240
252
|
end
|
@@ -298,6 +310,7 @@ shared_examples_for "has questionnaire" do
|
|
298
310
|
|
299
311
|
before do
|
300
312
|
visit questionnaire_public_path
|
313
|
+
see_questionnaire_questions
|
301
314
|
|
302
315
|
check "questionnaire_tos_agreement"
|
303
316
|
|
@@ -315,6 +328,7 @@ shared_examples_for "has questionnaire" do
|
|
315
328
|
|
316
329
|
it "properly interprets HTML descriptions" do
|
317
330
|
visit questionnaire_public_path
|
331
|
+
see_questionnaire_questions
|
318
332
|
|
319
333
|
expect(page).to have_css("b", text: "This question is important")
|
320
334
|
end
|
@@ -355,6 +369,7 @@ shared_examples_for "has questionnaire" do
|
|
355
369
|
|
356
370
|
before do
|
357
371
|
visit questionnaire_public_path
|
372
|
+
see_questionnaire_questions
|
358
373
|
end
|
359
374
|
|
360
375
|
context "when question is single_option type" do
|
@@ -448,6 +463,7 @@ shared_examples_for "has questionnaire" do
|
|
448
463
|
|
449
464
|
it "renders the answer as a textarea" do
|
450
465
|
visit questionnaire_public_path
|
466
|
+
see_questionnaire_questions
|
451
467
|
|
452
468
|
expect(page).to have_css("textarea#questionnaire_responses_0")
|
453
469
|
end
|
@@ -461,6 +477,7 @@ shared_examples_for "has questionnaire" do
|
|
461
477
|
|
462
478
|
it "renders the answer as a text field" do
|
463
479
|
visit questionnaire_public_path
|
480
|
+
see_questionnaire_questions
|
464
481
|
|
465
482
|
expect(page).to have_field(id: "questionnaire_responses_0")
|
466
483
|
end
|
@@ -474,6 +491,7 @@ shared_examples_for "has questionnaire" do
|
|
474
491
|
|
475
492
|
it "renders answers as a collection of radio buttons" do
|
476
493
|
visit questionnaire_public_path
|
494
|
+
see_questionnaire_questions
|
477
495
|
|
478
496
|
expect(page).to have_css(".js-radio-button-collection input[type=radio]", count: 2)
|
479
497
|
|
@@ -486,6 +504,7 @@ shared_examples_for "has questionnaire" do
|
|
486
504
|
expect(page).to have_admin_callout(callout_success)
|
487
505
|
|
488
506
|
visit questionnaire_public_path
|
507
|
+
see_questionnaire_questions
|
489
508
|
|
490
509
|
expect(page).to have_content("You have already answered this form.")
|
491
510
|
expect(page).to have_no_i18n_content(question.body)
|
@@ -498,6 +517,7 @@ shared_examples_for "has questionnaire" do
|
|
498
517
|
|
499
518
|
it "renders answers as a collection of radio buttons" do
|
500
519
|
visit questionnaire_public_path
|
520
|
+
see_questionnaire_questions
|
501
521
|
|
502
522
|
expect(page).to have_css(".js-check-box-collection input[type=checkbox]", count: 3)
|
503
523
|
|
@@ -513,6 +533,7 @@ shared_examples_for "has questionnaire" do
|
|
513
533
|
expect(page).to have_admin_callout(callout_success)
|
514
534
|
|
515
535
|
visit questionnaire_public_path
|
536
|
+
see_questionnaire_questions
|
516
537
|
|
517
538
|
expect(page).to have_content("You have already answered this form.")
|
518
539
|
expect(page).to have_no_i18n_content(question.body)
|
@@ -522,6 +543,7 @@ shared_examples_for "has questionnaire" do
|
|
522
543
|
question.update!(max_choices: 2)
|
523
544
|
|
524
545
|
visit questionnaire_public_path
|
546
|
+
see_questionnaire_questions
|
525
547
|
|
526
548
|
expect(page).to have_content("Max choices: 2")
|
527
549
|
|
@@ -564,6 +586,7 @@ shared_examples_for "has questionnaire" do
|
|
564
586
|
|
565
587
|
it "renders the question answers as a collection of divs sortable on drag and drop" do
|
566
588
|
visit questionnaire_public_path
|
589
|
+
see_questionnaire_questions
|
567
590
|
|
568
591
|
expect(page).to have_css("div.answer-questionnaire__sorting.js-collection-input", count: 5)
|
569
592
|
|
@@ -574,6 +597,7 @@ shared_examples_for "has questionnaire" do
|
|
574
597
|
|
575
598
|
it "properly saves valid sortings" do
|
576
599
|
visit questionnaire_public_path
|
600
|
+
see_questionnaire_questions
|
577
601
|
|
578
602
|
%w(We all like dark chocolate).reverse.each do |text|
|
579
603
|
find("div.answer-questionnaire__sorting", text:).drag_to(find("div.answer-questionnaire__sorting", match: :first))
|
@@ -608,6 +632,7 @@ shared_examples_for "has questionnaire" do
|
|
608
632
|
|
609
633
|
it "renders the question answers as a collection of radio buttons" do
|
610
634
|
visit questionnaire_public_path
|
635
|
+
see_questionnaire_questions
|
611
636
|
|
612
637
|
expect(page).to have_css(".js-radio-button-collection input[type=radio]", count: 4)
|
613
638
|
|
@@ -626,6 +651,7 @@ shared_examples_for "has questionnaire" do
|
|
626
651
|
expect(page).to have_admin_callout(callout_success)
|
627
652
|
|
628
653
|
visit questionnaire_public_path
|
654
|
+
see_questionnaire_questions
|
629
655
|
|
630
656
|
expect(page).to have_content("You have already answered this form.")
|
631
657
|
expect(page).to have_no_i18n_content(question.body)
|
@@ -638,6 +664,7 @@ shared_examples_for "has questionnaire" do
|
|
638
664
|
|
639
665
|
it "preserves the chosen answers if submission not correct" do
|
640
666
|
visit questionnaire_public_path
|
667
|
+
see_questionnaire_questions
|
641
668
|
|
642
669
|
radio_buttons = page.all(".js-radio-button-collection input[type=radio]")
|
643
670
|
choose radio_buttons[1][:id]
|
@@ -655,6 +682,7 @@ shared_examples_for "has questionnaire" do
|
|
655
682
|
|
656
683
|
it "shows an error if the question is mandatory and the answer is not complete" do
|
657
684
|
visit questionnaire_public_path
|
685
|
+
see_questionnaire_questions
|
658
686
|
|
659
687
|
radio_buttons = page.all(".js-radio-button-collection input[type=radio]")
|
660
688
|
choose radio_buttons[0][:id]
|
@@ -688,6 +716,7 @@ shared_examples_for "has questionnaire" do
|
|
688
716
|
|
689
717
|
it "renders the question answers as a collection of check boxes" do
|
690
718
|
visit questionnaire_public_path
|
719
|
+
see_questionnaire_questions
|
691
720
|
|
692
721
|
expect(page).to have_css(".js-check-box-collection input[type=checkbox]", count: 6)
|
693
722
|
|
@@ -707,6 +736,7 @@ shared_examples_for "has questionnaire" do
|
|
707
736
|
expect(page).to have_admin_callout(callout_success)
|
708
737
|
|
709
738
|
visit questionnaire_public_path
|
739
|
+
see_questionnaire_questions
|
710
740
|
|
711
741
|
expect(page).to have_content("You have already answered this form.")
|
712
742
|
expect(page).to have_no_i18n_content(question.body)
|
@@ -723,6 +753,7 @@ shared_examples_for "has questionnaire" do
|
|
723
753
|
|
724
754
|
it "respects the max number of choices" do
|
725
755
|
visit questionnaire_public_path
|
756
|
+
see_questionnaire_questions
|
726
757
|
|
727
758
|
expect(page).to have_content("Max choices: 2")
|
728
759
|
|
@@ -767,6 +798,7 @@ shared_examples_for "has questionnaire" do
|
|
767
798
|
|
768
799
|
it "shows an error" do
|
769
800
|
visit questionnaire_public_path
|
801
|
+
see_questionnaire_questions
|
770
802
|
|
771
803
|
checkboxes = page.all(".js-check-box-collection input[type=checkbox]")
|
772
804
|
check checkboxes[0][:id]
|
@@ -784,6 +816,7 @@ shared_examples_for "has questionnaire" do
|
|
784
816
|
|
785
817
|
it "preserves the chosen answers" do
|
786
818
|
visit questionnaire_public_path
|
819
|
+
see_questionnaire_questions
|
787
820
|
|
788
821
|
checkboxes = page.all(".js-check-box-collection input[type=checkbox]")
|
789
822
|
check checkboxes[0][:id]
|
@@ -833,6 +866,7 @@ shared_examples_for "has questionnaire" do
|
|
833
866
|
|
834
867
|
before do
|
835
868
|
visit questionnaire_public_path
|
869
|
+
see_questionnaire_questions
|
836
870
|
end
|
837
871
|
|
838
872
|
context "when the condition_question type is short answer" do
|
@@ -925,6 +959,7 @@ shared_examples_for "has questionnaire" do
|
|
925
959
|
|
926
960
|
before do
|
927
961
|
visit questionnaire_public_path
|
962
|
+
see_questionnaire_questions
|
928
963
|
end
|
929
964
|
|
930
965
|
context "when the condition_question type is short answer" do
|
@@ -1006,6 +1041,7 @@ shared_examples_for "has questionnaire" do
|
|
1006
1041
|
|
1007
1042
|
before do
|
1008
1043
|
visit questionnaire_public_path
|
1044
|
+
see_questionnaire_questions
|
1009
1045
|
end
|
1010
1046
|
|
1011
1047
|
context "when the condition_question type is single option" do
|
@@ -1062,6 +1098,7 @@ shared_examples_for "has questionnaire" do
|
|
1062
1098
|
|
1063
1099
|
before do
|
1064
1100
|
visit questionnaire_public_path
|
1101
|
+
see_questionnaire_questions
|
1065
1102
|
end
|
1066
1103
|
|
1067
1104
|
context "when the condition_question type is single option" do
|
@@ -1119,6 +1156,7 @@ shared_examples_for "has questionnaire" do
|
|
1119
1156
|
|
1120
1157
|
before do
|
1121
1158
|
visit questionnaire_public_path
|
1159
|
+
see_questionnaire_questions
|
1122
1160
|
end
|
1123
1161
|
|
1124
1162
|
context "when the condition_question type is short answer" do
|
@@ -1239,6 +1277,7 @@ shared_examples_for "has questionnaire" do
|
|
1239
1277
|
context "when a question has multiple display conditions" do
|
1240
1278
|
before do
|
1241
1279
|
visit questionnaire_public_path
|
1280
|
+
see_questionnaire_questions
|
1242
1281
|
end
|
1243
1282
|
|
1244
1283
|
context "when all conditions are mandatory" do
|
@@ -1327,6 +1366,7 @@ shared_examples_for "has questionnaire" do
|
|
1327
1366
|
|
1328
1367
|
it "does not throw error" do
|
1329
1368
|
visit questionnaire_public_path
|
1369
|
+
see_questionnaire_questions
|
1330
1370
|
|
1331
1371
|
fill_in condition_question.body["en"], with: "My first answer"
|
1332
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
|
|