decidim-forms 0.29.5 → 0.30.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.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/forms/step_navigation_cell.rb +18 -5
  3. data/app/commands/decidim/forms/admin/update_questionnaire.rb +1 -82
  4. data/app/commands/decidim/forms/admin/update_questions.rb +109 -0
  5. data/app/commands/decidim/forms/answer_questionnaire.rb +10 -3
  6. data/app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb +39 -3
  7. data/app/controllers/decidim/forms/admin/concerns/has_questionnaire_answers.rb +2 -2
  8. data/app/controllers/decidim/forms/concerns/has_questionnaire.rb +12 -4
  9. data/app/forms/decidim/forms/admin/display_condition_form.rb +1 -1
  10. data/app/forms/decidim/forms/admin/questionnaire_form.rb +0 -9
  11. data/app/forms/decidim/forms/admin/questions_form.rb +18 -0
  12. data/app/forms/decidim/forms/answer_choice_form.rb +5 -0
  13. data/app/forms/decidim/forms/answer_form.rb +1 -0
  14. data/app/forms/decidim/forms/questionnaire_form.rb +7 -0
  15. data/app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_pagination_helper.rb +1 -1
  16. data/app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_url_helper.rb +5 -5
  17. data/app/jobs/decidim/forms/export_questionnaire_answers_job.rb +5 -1
  18. data/app/models/decidim/forms/answer_choice.rb +0 -2
  19. data/app/models/decidim/forms/answer_option.rb +1 -1
  20. data/app/models/decidim/forms/question.rb +10 -0
  21. data/app/packs/entrypoints/decidim_forms.js +0 -1
  22. data/app/packs/entrypoints/decidim_forms_admin.js +6 -0
  23. data/app/packs/src/decidim/forms/admin/publish_answers_buttons.js +72 -0
  24. data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +1 -1
  25. data/app/presenters/decidim/forms/admin_log/question_presenter.rb +31 -0
  26. data/app/queries/decidim/forms/questionnaire_user_answers.rb +1 -1
  27. data/app/views/decidim/forms/admin/questionnaires/_answer_option_template.html.erb +1 -1
  28. data/app/views/decidim/forms/admin/questionnaires/_display_condition_template.html.erb +1 -1
  29. data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +0 -89
  30. data/app/views/decidim/forms/admin/questionnaires/_matrix_row_template.html.erb +1 -1
  31. data/app/views/decidim/forms/admin/questionnaires/_question.html.erb +3 -3
  32. data/app/views/decidim/forms/admin/questionnaires/_questions_form.html.erb +80 -0
  33. data/app/views/decidim/forms/admin/questionnaires/edit.html.erb +0 -20
  34. data/app/views/decidim/forms/admin/questionnaires/edit_questions.html.erb +47 -0
  35. data/app/views/decidim/forms/questionnaires/_answer.html.erb +1 -1
  36. data/app/views/decidim/forms/questionnaires/_questionnaire.html.erb +8 -1
  37. data/app/views/decidim/forms/questionnaires/answers/_files.html.erb +1 -1
  38. data/app/views/decidim/forms/questionnaires/answers/_long_answer.html.erb +1 -1
  39. data/app/views/decidim/forms/questionnaires/answers/_short_answer.html.erb +1 -1
  40. data/app/views/decidim/forms/questionnaires/answers/_sorting.html.erb +12 -6
  41. data/app/views/decidim/forms/questionnaires/edit.html.erb +47 -0
  42. data/app/views/decidim/forms/questionnaires/show.html.erb +13 -2
  43. data/config/assets.rb +1 -2
  44. data/config/locales/ar.yml +16 -1
  45. data/config/locales/bg.yml +36 -2
  46. data/config/locales/ca.yml +53 -13
  47. data/config/locales/cs.yml +48 -8
  48. data/config/locales/de.yml +52 -12
  49. data/config/locales/el.yml +35 -2
  50. data/config/locales/en.yml +45 -5
  51. data/config/locales/es-MX.yml +55 -15
  52. data/config/locales/es-PY.yml +55 -15
  53. data/config/locales/es.yml +54 -14
  54. data/config/locales/eu.yml +52 -12
  55. data/config/locales/fi-plain.yml +50 -10
  56. data/config/locales/fi.yml +50 -10
  57. data/config/locales/fr-CA.yml +45 -13
  58. data/config/locales/fr.yml +45 -13
  59. data/config/locales/ga-IE.yml +5 -0
  60. data/config/locales/gl.yml +7 -1
  61. data/config/locales/hu.yml +10 -1
  62. data/config/locales/id-ID.yml +7 -1
  63. data/config/locales/it.yml +27 -3
  64. data/config/locales/ja.yml +7 -12
  65. data/config/locales/lb.yml +28 -1
  66. data/config/locales/lt.yml +35 -2
  67. data/config/locales/lv.yml +11 -1
  68. data/config/locales/nl.yml +23 -0
  69. data/config/locales/no.yml +27 -0
  70. data/config/locales/pl.yml +37 -2
  71. data/config/locales/pt-BR.yml +29 -0
  72. data/config/locales/pt.yml +27 -0
  73. data/config/locales/ro-RO.yml +44 -17
  74. data/config/locales/ru.yml +1 -2
  75. data/config/locales/sk.yml +10 -1
  76. data/config/locales/sl.yml +7 -0
  77. data/config/locales/sv.yml +12 -16
  78. data/config/locales/tr-TR.yml +23 -0
  79. data/config/locales/zh-CN.yml +23 -0
  80. data/config/locales/zh-TW.yml +35 -2
  81. data/db/migrate/20190315203056_add_session_token_to_decidim_forms_answers.rb +1 -1
  82. data/db/migrate/20241122142230_add_survey_answers_published_at_to_questions.rb +7 -0
  83. data/decidim-forms.gemspec +1 -2
  84. data/lib/decidim/api/answer_option_type.rb +1 -1
  85. data/lib/decidim/api/question_type.rb +4 -4
  86. data/lib/decidim/api/questionnaire_type.rb +4 -4
  87. data/lib/decidim/exporters/form_pdf.rb +114 -11
  88. data/lib/decidim/forms/download_your_data_user_answers_serializer.rb +0 -4
  89. data/lib/decidim/forms/test/factories.rb +2 -2
  90. data/lib/decidim/forms/test/shared_examples/has_questionnaire.rb +46 -7
  91. data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +17 -17
  92. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_display_conditions.rb +19 -21
  93. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +70 -94
  94. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb +15 -18
  95. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +90 -125
  96. data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +4 -25
  97. data/lib/decidim/forms/version.rb +1 -1
  98. data/lib/decidim/forms.rb +0 -1
  99. metadata +18 -33
  100. data/app/packs/entrypoints/decidim_questionnaire_answers_pdf.js +0 -1
  101. data/app/packs/entrypoints/decidim_questionnaire_answers_pdf.scss +0 -1
  102. data/app/packs/stylesheets/decidim/forms/questionnaire-answers-pdf.scss +0 -69
  103. data/app/views/decidim/forms/admin/questionnaires/answers/export/_answer.html.erb +0 -31
  104. data/app/views/decidim/forms/admin/questionnaires/answers/export/pdf.html.erb +0 -13
  105. data/app/views/layouts/decidim/forms/admin/questionnaires/questionnaire_answers.html.erb +0 -12
  106. data/config/initializers/wicked_pdf.rb +0 -26
  107. data/config/locales/ca-IT.yml +0 -198
  108. 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
- dismiss_page_unload do
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 questionnaire_public_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
@@ -271,9 +283,8 @@ shared_examples_for "has questionnaire" do
271
283
  accept_confirm { click_on "Submit" }
272
284
  end
273
285
 
274
- it "submits the form and shows errors" do
275
- expect(page).to have_css ".alert.flash"
276
- expect(page).to have_admin_callout(callout_failure)
286
+ it "shows errors without submitting the form" do
287
+ expect(page).to have_no_css ".alert.flash"
277
288
  different_error = I18n.t("decidim.forms.questionnaires.answer.max_choices_alert")
278
289
  expect(different_error).to eq("There are too many choices selected")
279
290
  expect(page).to have_no_content(different_error)
@@ -299,6 +310,7 @@ shared_examples_for "has questionnaire" do
299
310
 
300
311
  before do
301
312
  visit questionnaire_public_path
313
+ see_questionnaire_questions
302
314
 
303
315
  check "questionnaire_tos_agreement"
304
316
 
@@ -316,6 +328,7 @@ shared_examples_for "has questionnaire" do
316
328
 
317
329
  it "properly interprets HTML descriptions" do
318
330
  visit questionnaire_public_path
331
+ see_questionnaire_questions
319
332
 
320
333
  expect(page).to have_css("b", text: "This question is important")
321
334
  end
@@ -356,6 +369,7 @@ shared_examples_for "has questionnaire" do
356
369
 
357
370
  before do
358
371
  visit questionnaire_public_path
372
+ see_questionnaire_questions
359
373
  end
360
374
 
361
375
  context "when question is single_option type" do
@@ -449,6 +463,7 @@ shared_examples_for "has questionnaire" do
449
463
 
450
464
  it "renders the answer as a textarea" do
451
465
  visit questionnaire_public_path
466
+ see_questionnaire_questions
452
467
 
453
468
  expect(page).to have_css("textarea#questionnaire_responses_0")
454
469
  end
@@ -462,6 +477,7 @@ shared_examples_for "has questionnaire" do
462
477
 
463
478
  it "renders the answer as a text field" do
464
479
  visit questionnaire_public_path
480
+ see_questionnaire_questions
465
481
 
466
482
  expect(page).to have_field(id: "questionnaire_responses_0")
467
483
  end
@@ -475,6 +491,7 @@ shared_examples_for "has questionnaire" do
475
491
 
476
492
  it "renders answers as a collection of radio buttons" do
477
493
  visit questionnaire_public_path
494
+ see_questionnaire_questions
478
495
 
479
496
  expect(page).to have_css(".js-radio-button-collection input[type=radio]", count: 2)
480
497
 
@@ -487,6 +504,7 @@ shared_examples_for "has questionnaire" do
487
504
  expect(page).to have_admin_callout(callout_success)
488
505
 
489
506
  visit questionnaire_public_path
507
+ see_questionnaire_questions
490
508
 
491
509
  expect(page).to have_content("You have already answered this form.")
492
510
  expect(page).to have_no_i18n_content(question.body)
@@ -499,6 +517,7 @@ shared_examples_for "has questionnaire" do
499
517
 
500
518
  it "renders answers as a collection of radio buttons" do
501
519
  visit questionnaire_public_path
520
+ see_questionnaire_questions
502
521
 
503
522
  expect(page).to have_css(".js-check-box-collection input[type=checkbox]", count: 3)
504
523
 
@@ -514,6 +533,7 @@ shared_examples_for "has questionnaire" do
514
533
  expect(page).to have_admin_callout(callout_success)
515
534
 
516
535
  visit questionnaire_public_path
536
+ see_questionnaire_questions
517
537
 
518
538
  expect(page).to have_content("You have already answered this form.")
519
539
  expect(page).to have_no_i18n_content(question.body)
@@ -523,6 +543,7 @@ shared_examples_for "has questionnaire" do
523
543
  question.update!(max_choices: 2)
524
544
 
525
545
  visit questionnaire_public_path
546
+ see_questionnaire_questions
526
547
 
527
548
  expect(page).to have_content("Max choices: 2")
528
549
 
@@ -565,6 +586,7 @@ shared_examples_for "has questionnaire" do
565
586
 
566
587
  it "renders the question answers as a collection of divs sortable on drag and drop" do
567
588
  visit questionnaire_public_path
589
+ see_questionnaire_questions
568
590
 
569
591
  expect(page).to have_css("div.answer-questionnaire__sorting.js-collection-input", count: 5)
570
592
 
@@ -575,6 +597,7 @@ shared_examples_for "has questionnaire" do
575
597
 
576
598
  it "properly saves valid sortings" do
577
599
  visit questionnaire_public_path
600
+ see_questionnaire_questions
578
601
 
579
602
  %w(We all like dark chocolate).reverse.each do |text|
580
603
  find("div.answer-questionnaire__sorting", text:).drag_to(find("div.answer-questionnaire__sorting", match: :first))
@@ -609,6 +632,7 @@ shared_examples_for "has questionnaire" do
609
632
 
610
633
  it "renders the question answers as a collection of radio buttons" do
611
634
  visit questionnaire_public_path
635
+ see_questionnaire_questions
612
636
 
613
637
  expect(page).to have_css(".js-radio-button-collection input[type=radio]", count: 4)
614
638
 
@@ -627,6 +651,7 @@ shared_examples_for "has questionnaire" do
627
651
  expect(page).to have_admin_callout(callout_success)
628
652
 
629
653
  visit questionnaire_public_path
654
+ see_questionnaire_questions
630
655
 
631
656
  expect(page).to have_content("You have already answered this form.")
632
657
  expect(page).to have_no_i18n_content(question.body)
@@ -639,6 +664,7 @@ shared_examples_for "has questionnaire" do
639
664
 
640
665
  it "preserves the chosen answers if submission not correct" do
641
666
  visit questionnaire_public_path
667
+ see_questionnaire_questions
642
668
 
643
669
  radio_buttons = page.all(".js-radio-button-collection input[type=radio]")
644
670
  choose radio_buttons[1][:id]
@@ -656,6 +682,7 @@ shared_examples_for "has questionnaire" do
656
682
 
657
683
  it "shows an error if the question is mandatory and the answer is not complete" do
658
684
  visit questionnaire_public_path
685
+ see_questionnaire_questions
659
686
 
660
687
  radio_buttons = page.all(".js-radio-button-collection input[type=radio]")
661
688
  choose radio_buttons[0][:id]
@@ -689,6 +716,7 @@ shared_examples_for "has questionnaire" do
689
716
 
690
717
  it "renders the question answers as a collection of check boxes" do
691
718
  visit questionnaire_public_path
719
+ see_questionnaire_questions
692
720
 
693
721
  expect(page).to have_css(".js-check-box-collection input[type=checkbox]", count: 6)
694
722
 
@@ -708,6 +736,7 @@ shared_examples_for "has questionnaire" do
708
736
  expect(page).to have_admin_callout(callout_success)
709
737
 
710
738
  visit questionnaire_public_path
739
+ see_questionnaire_questions
711
740
 
712
741
  expect(page).to have_content("You have already answered this form.")
713
742
  expect(page).to have_no_i18n_content(question.body)
@@ -724,6 +753,7 @@ shared_examples_for "has questionnaire" do
724
753
 
725
754
  it "respects the max number of choices" do
726
755
  visit questionnaire_public_path
756
+ see_questionnaire_questions
727
757
 
728
758
  expect(page).to have_content("Max choices: 2")
729
759
 
@@ -768,6 +798,7 @@ shared_examples_for "has questionnaire" do
768
798
 
769
799
  it "shows an error" do
770
800
  visit questionnaire_public_path
801
+ see_questionnaire_questions
771
802
 
772
803
  checkboxes = page.all(".js-check-box-collection input[type=checkbox]")
773
804
  check checkboxes[0][:id]
@@ -785,6 +816,7 @@ shared_examples_for "has questionnaire" do
785
816
 
786
817
  it "preserves the chosen answers" do
787
818
  visit questionnaire_public_path
819
+ see_questionnaire_questions
788
820
 
789
821
  checkboxes = page.all(".js-check-box-collection input[type=checkbox]")
790
822
  check checkboxes[0][:id]
@@ -834,6 +866,7 @@ shared_examples_for "has questionnaire" do
834
866
 
835
867
  before do
836
868
  visit questionnaire_public_path
869
+ see_questionnaire_questions
837
870
  end
838
871
 
839
872
  context "when the condition_question type is short answer" do
@@ -926,6 +959,7 @@ shared_examples_for "has questionnaire" do
926
959
 
927
960
  before do
928
961
  visit questionnaire_public_path
962
+ see_questionnaire_questions
929
963
  end
930
964
 
931
965
  context "when the condition_question type is short answer" do
@@ -1007,6 +1041,7 @@ shared_examples_for "has questionnaire" do
1007
1041
 
1008
1042
  before do
1009
1043
  visit questionnaire_public_path
1044
+ see_questionnaire_questions
1010
1045
  end
1011
1046
 
1012
1047
  context "when the condition_question type is single option" do
@@ -1063,6 +1098,7 @@ shared_examples_for "has questionnaire" do
1063
1098
 
1064
1099
  before do
1065
1100
  visit questionnaire_public_path
1101
+ see_questionnaire_questions
1066
1102
  end
1067
1103
 
1068
1104
  context "when the condition_question type is single option" do
@@ -1120,6 +1156,7 @@ shared_examples_for "has questionnaire" do
1120
1156
 
1121
1157
  before do
1122
1158
  visit questionnaire_public_path
1159
+ see_questionnaire_questions
1123
1160
  end
1124
1161
 
1125
1162
  context "when the condition_question type is short answer" do
@@ -1240,6 +1277,7 @@ shared_examples_for "has questionnaire" do
1240
1277
  context "when a question has multiple display conditions" do
1241
1278
  before do
1242
1279
  visit questionnaire_public_path
1280
+ see_questionnaire_questions
1243
1281
  end
1244
1282
 
1245
1283
  context "when all conditions are mandatory" do
@@ -1328,6 +1366,7 @@ shared_examples_for "has questionnaire" do
1328
1366
 
1329
1367
  it "does not throw error" do
1330
1368
  visit questionnaire_public_path
1369
+ see_questionnaire_questions
1331
1370
 
1332
1371
  fill_in condition_question.body["en"], with: "My first answer"
1333
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 :questionnaire_question, questionnaire:, position: 1, question_type: first_type
8
+ create(:questionnaire_question, questionnaire:, position: 1, question_type: first_type)
9
9
  end
10
10
  let!(:second) do
11
- create :questionnaire_question, questionnaire:, position: 2, question_type: "single_option"
11
+ create(:questionnaire_question, questionnaire:, position: 2, question_type: "single_option")
12
12
  end
13
13
  let!(:third) do
14
- create :questionnaire_question, questionnaire:, position: 3, question_type: "files"
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
- visit questionnaire_edit_path
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 :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 }
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
- visit questionnaire_edit_path
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
- visit questionnaire_edit_path
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 :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) }
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 :answer, questionnaire:, body: "", user: answer1.user, question: second }
97
+ let!(:answer11) { create(:answer, questionnaire:, body: "", user: answer1.user, question: second) }
98
98
 
99
99
  before do
100
- visit questionnaire_edit_path
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 :answer, questionnaire:, question: third, body: nil, user: answer3.user, session_token: answer3.session_token }
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 :attachment, :with_image, attached_to: file_answer, title: {}, description: {}
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
- visit_questionnaire_edit_path_and_expand_all
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
- within "form.edit_questionnaire" do
30
- click_on "Add question"
31
- expand_all_questions
30
+ click_on "Add question"
31
+ expand_all_questions
32
32
 
33
- expect(page).to have_button("Add display condition", disabled: true)
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
- visit_questionnaire_edit_path_and_expand_all
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
- within "form.edit_questionnaire" do
80
- within_add_display_condition do
81
- expect(page).to have_select("Question")
82
- expect(page).to have_select("Condition")
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
- select question_single_option.body["en"], from: "Question"
86
- select "Answered", from: "Condition"
84
+ select question_single_option.body["en"], from: "Question"
85
+ select "Answered", from: "Condition"
87
86
 
88
- expect(page).to have_no_select("Answer option")
89
- expect(page).to have_no_css("[id$=condition_value_en]", visible: :visible)
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
- select question_single_option.body["en"], from: "Question"
92
- select "Equal", from: "Condition"
90
+ select question_single_option.body["en"], from: "Question"
91
+ select "Equal", from: "Condition"
93
92
 
94
- expect(page).to have_select("Answer option")
95
- expect(page).to have_no_css("[id$=condition_value_en]", visible: :visible)
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