decidim-forms 0.28.5 → 0.29.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 (75) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/forms/question_readonly_cell.rb +0 -2
  3. data/app/cells/decidim/forms/step_navigation/show.erb +3 -3
  4. data/app/cells/decidim/forms/step_navigation_cell.rb +2 -3
  5. data/app/commands/decidim/forms/answer_questionnaire.rb +4 -4
  6. data/app/controllers/decidim/forms/concerns/has_questionnaire.rb +1 -1
  7. data/app/forms/decidim/forms/admin/questionnaire_form.rb +2 -2
  8. data/app/forms/decidim/forms/answer_form.rb +2 -2
  9. data/app/forms/decidim/forms/questionnaire_form.rb +1 -1
  10. data/app/helpers/decidim/forms/application_helper.rb +2 -2
  11. data/app/models/decidim/forms/answer_choice.rb +0 -2
  12. data/app/models/decidim/forms/answer_option.rb +1 -1
  13. data/app/models/decidim/forms/display_condition.rb +11 -3
  14. data/app/models/decidim/forms/question_matrix_row.rb +1 -1
  15. data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +7 -7
  16. data/app/views/decidim/forms/admin/questionnaires/_answer_option.html.erb +1 -1
  17. data/app/views/decidim/forms/admin/questionnaires/_display_condition.html.erb +2 -2
  18. data/app/views/decidim/forms/admin/questionnaires/_matrix_row.html.erb +1 -1
  19. data/app/views/decidim/forms/admin/questionnaires/_question.html.erb +4 -4
  20. data/app/views/decidim/forms/admin/questionnaires/_separator.html.erb +4 -4
  21. data/app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb +4 -4
  22. data/app/views/decidim/forms/questionnaires/_answer.html.erb +1 -11
  23. data/config/initializers/wicked_pdf.rb +6 -4
  24. data/config/locales/ar.yml +2 -4
  25. data/config/locales/bg.yml +6 -2
  26. data/config/locales/ca.yml +4 -4
  27. data/config/locales/cs.yml +0 -1
  28. data/config/locales/de.yml +5 -5
  29. data/config/locales/el.yml +5 -2
  30. data/config/locales/en.yml +2 -2
  31. data/config/locales/es-MX.yml +5 -5
  32. data/config/locales/es-PY.yml +5 -5
  33. data/config/locales/es.yml +5 -5
  34. data/config/locales/eu.yml +8 -8
  35. data/config/locales/fi-plain.yml +4 -4
  36. data/config/locales/fi.yml +5 -5
  37. data/config/locales/fr-CA.yml +3 -3
  38. data/config/locales/fr.yml +3 -3
  39. data/config/locales/gl.yml +3 -1
  40. data/config/locales/hu.yml +6 -4
  41. data/config/locales/id-ID.yml +2 -1
  42. data/config/locales/it.yml +4 -1
  43. data/config/locales/ja.yml +6 -1
  44. data/config/locales/lb.yml +4 -1
  45. data/config/locales/lt.yml +5 -2
  46. data/config/locales/lv.yml +3 -1
  47. data/config/locales/nl.yml +5 -1
  48. data/config/locales/no.yml +5 -1
  49. data/config/locales/pl.yml +6 -1
  50. data/config/locales/pt-BR.yml +5 -1
  51. data/config/locales/pt.yml +4 -1
  52. data/config/locales/ro-RO.yml +5 -3
  53. data/config/locales/sk.yml +2 -1
  54. data/config/locales/sv.yml +31 -44
  55. data/config/locales/tr-TR.yml +4 -1
  56. data/config/locales/val-ES.yml +2 -0
  57. data/config/locales/zh-CN.yml +4 -1
  58. data/config/locales/zh-TW.yml +5 -2
  59. data/db/migrate/20240402092039_add_answer_options_counter_cache_to_questions.rb +16 -0
  60. data/db/migrate/20240402095253_add_matrix_row_counter_cache_to_questions.rb +16 -0
  61. data/db/migrate/20240416111953_add_display_conditions_counter_cache_to_questions.rb +16 -0
  62. data/db/migrate/20240416113926_add_display_conditions_for_other_questions_counter_cache_to_questions.rb +16 -0
  63. data/decidim-forms.gemspec +3 -2
  64. data/lib/decidim/forms/test/shared_examples/has_questionnaire.rb +44 -70
  65. data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +12 -12
  66. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_display_conditions.rb +10 -10
  67. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +85 -85
  68. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb +8 -8
  69. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +82 -82
  70. data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +9 -9
  71. data/lib/decidim/forms/user_answers_serializer.rb +1 -1
  72. data/lib/decidim/forms/version.rb +1 -1
  73. metadata +31 -15
  74. data/config/locales/bn-BD.yml +0 -1
  75. data/config/locales/bs-BA.yml +0 -1
@@ -10,7 +10,7 @@ shared_examples_for "has questionnaire" do
10
10
  expect(page).to have_i18n_content(questionnaire.title)
11
11
  expect(page).to have_i18n_content(questionnaire.description, strip_tags: true)
12
12
 
13
- expect(page).not_to have_css(".form.answer-questionnaire")
13
+ expect(page).to have_no_css(".form.answer-questionnaire")
14
14
 
15
15
  within "[data-question-readonly]" do
16
16
  expect(page).to have_i18n_content(question.body)
@@ -46,7 +46,7 @@ shared_examples_for "has questionnaire" do
46
46
  check "questionnaire_tos_agreement"
47
47
 
48
48
  accept_confirm do
49
- click_button "Submit"
49
+ click_on "Submit"
50
50
  end
51
51
 
52
52
  expect(page).to have_admin_callout(callout_success)
@@ -57,32 +57,6 @@ shared_examples_for "has questionnaire" do
57
57
  expect(page).to have_no_i18n_content(question.body)
58
58
  end
59
59
 
60
- context "and there is a mandatory question" do
61
- let!(:question) do
62
- create(
63
- :questionnaire_question,
64
- questionnaire:,
65
- question_type: "short_answer",
66
- position: 0,
67
- mandatory: true
68
- )
69
- end
70
-
71
- before do
72
- visit questionnaire_public_path
73
- end
74
-
75
- it "it renders the asterisk as a separated element" do
76
- within "label.answer-questionnaire__question-label" do
77
- expect(page).to have_content(translated_attribute(question.body).to_s)
78
- within "span.label-required.has-tip" do
79
- expect(page).to have_content("*")
80
- expect(page).to have_content("Required field")
81
- end
82
- end
83
- end
84
- end
85
-
86
60
  context "with multiple steps" do
87
61
  let!(:separator) { create(:questionnaire_question, questionnaire:, position: 1, question_type: :separator) }
88
62
  let!(:question2) { create(:questionnaire_question, questionnaire:, position: 2) }
@@ -95,18 +69,18 @@ shared_examples_for "has questionnaire" do
95
69
  expect(page).to have_content("Step 1 of 2")
96
70
 
97
71
  within ".answer-questionnaire__submit", match: :first do
98
- expect(page).not_to have_content("Back")
72
+ expect(page).to have_no_content("Back")
99
73
  end
100
74
 
101
75
  answer_first_questionnaire
102
76
 
103
- expect(page).not_to have_selector(".success.flash")
77
+ expect(page).to have_no_css(".success.flash")
104
78
  end
105
79
 
106
80
  it "allows revisiting previously-answered questionnaires with my answers" do
107
81
  answer_first_questionnaire
108
82
 
109
- click_button "Back"
83
+ click_on "Back"
110
84
 
111
85
  expect(page).to have_content("Step 1 of 2")
112
86
  expect(page).to have_field("questionnaire_responses_0", with: "My first answer")
@@ -116,7 +90,7 @@ shared_examples_for "has questionnaire" do
116
90
  answer_first_questionnaire
117
91
 
118
92
  check "questionnaire_tos_agreement"
119
- accept_confirm { click_button "Submit" }
93
+ accept_confirm { click_on "Submit" }
120
94
 
121
95
  expect(page).to have_admin_callout(callout_success)
122
96
 
@@ -127,10 +101,10 @@ shared_examples_for "has questionnaire" do
127
101
 
128
102
  def answer_first_questionnaire
129
103
  within "#step-0" do
130
- expect(page).not_to have_selector("#questionnaire_tos_agreement")
104
+ expect(page).to have_no_css("#questionnaire_tos_agreement")
131
105
 
132
106
  fill_in question.body["en"], with: "My first answer"
133
- click_button "Continue"
107
+ click_on "Continue"
134
108
  end
135
109
  expect(page).to have_content("Step 2 of 2")
136
110
  end
@@ -174,7 +148,7 @@ shared_examples_for "has questionnaire" do
174
148
  it "does not leak defaults from other answers" do
175
149
  visit questionnaire_public_path
176
150
 
177
- expect(page).not_to have_field(type: "radio", checked: true)
151
+ expect(page).to have_no_field(type: "radio", checked: true)
178
152
  end
179
153
  end
180
154
 
@@ -205,7 +179,7 @@ shared_examples_for "has questionnaire" do
205
179
 
206
180
  before do
207
181
  visit questionnaire_public_path
208
- accept_confirm { click_button "Submit" }
182
+ accept_confirm { click_on "Submit" }
209
183
  end
210
184
 
211
185
  it_behaves_like "a correctly ordered questionnaire"
@@ -246,7 +220,7 @@ shared_examples_for "has questionnaire" do
246
220
  it "does not show message indicating number of characters left" do
247
221
  visit questionnaire_public_path
248
222
 
249
- expect(page).not_to have_content("characters left")
223
+ expect(page).to have_no_content("characters left")
250
224
  end
251
225
  end
252
226
  end
@@ -255,7 +229,7 @@ shared_examples_for "has questionnaire" do
255
229
  include_context "when a non multiple choice question is mandatory"
256
230
 
257
231
  before do
258
- click_button "Submit"
232
+ click_on "Submit"
259
233
  end
260
234
 
261
235
  it "submits the form and shows errors" do
@@ -268,14 +242,14 @@ shared_examples_for "has questionnaire" do
268
242
  include_context "when a non multiple choice question is mandatory"
269
243
 
270
244
  before do
271
- accept_confirm { click_button "Submit" }
245
+ accept_confirm { click_on "Submit" }
272
246
  end
273
247
 
274
248
  it "shows errors without submitting the form" do
275
- expect(page).not_to have_selector ".alert.flash"
249
+ expect(page).to have_no_css ".alert.flash"
276
250
  different_error = I18n.t("decidim.forms.questionnaires.answer.max_choices_alert")
277
251
  expect(different_error).to eq("There are too many choices selected")
278
- expect(page).not_to have_content(different_error)
252
+ expect(page).to have_no_content(different_error)
279
253
 
280
254
  expect(page).to have_content("cannot be blank")
281
255
  end
@@ -301,7 +275,7 @@ shared_examples_for "has questionnaire" do
301
275
 
302
276
  check "questionnaire_tos_agreement"
303
277
 
304
- accept_confirm { click_button "Submit" }
278
+ accept_confirm { click_on "Submit" }
305
279
  end
306
280
 
307
281
  it "submits the form and shows errors" do
@@ -316,7 +290,7 @@ shared_examples_for "has questionnaire" do
316
290
  it "properly interprets HTML descriptions" do
317
291
  visit questionnaire_public_path
318
292
 
319
- expect(page).to have_selector("b", text: "This question is important")
293
+ expect(page).to have_css("b", text: "This question is important")
320
294
  end
321
295
  end
322
296
 
@@ -361,7 +335,7 @@ shared_examples_for "has questionnaire" do
361
335
  let(:question_type) { "single_option" }
362
336
 
363
337
  it "renders them as radio buttons with attached text fields disabled by default" do
364
- expect(page).to have_selector(".js-radio-button-collection input[type=radio]", count: 3)
338
+ expect(page).to have_css(".js-radio-button-collection input[type=radio]", count: 3)
365
339
 
366
340
  expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", disabled: true, count: 1)
367
341
 
@@ -375,7 +349,7 @@ shared_examples_for "has questionnaire" do
375
349
  fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
376
350
 
377
351
  check "questionnaire_tos_agreement"
378
- accept_confirm { click_button "Submit" }
352
+ accept_confirm { click_on "Submit" }
379
353
 
380
354
  expect(page).to have_admin_callout(callout_success)
381
355
  expect(Decidim::Forms::Answer.first.choices.first.custom_body).to eq("Cacatua")
@@ -390,7 +364,7 @@ shared_examples_for "has questionnaire" do
390
364
  fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
391
365
 
392
366
  check "questionnaire_tos_agreement"
393
- accept_confirm { click_button "Submit" }
367
+ accept_confirm { click_on "Submit" }
394
368
 
395
369
  expect(page).to have_admin_callout("There was a problem answering")
396
370
  expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", with: "Cacatua")
@@ -417,7 +391,7 @@ shared_examples_for "has questionnaire" do
417
391
  fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
418
392
 
419
393
  check "questionnaire_tos_agreement"
420
- accept_confirm { click_button "Submit" }
394
+ accept_confirm { click_on "Submit" }
421
395
 
422
396
  expect(page).to have_admin_callout(callout_success)
423
397
  expect(Decidim::Forms::Answer.first.choices.first.custom_body).to eq("Cacatua")
@@ -432,7 +406,7 @@ shared_examples_for "has questionnaire" do
432
406
  fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
433
407
 
434
408
  check "questionnaire_tos_agreement"
435
- accept_confirm { click_button "Submit" }
409
+ accept_confirm { click_on "Submit" }
436
410
 
437
411
  expect(page).to have_admin_callout("There was a problem answering")
438
412
  expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", with: "Cacatua")
@@ -449,7 +423,7 @@ shared_examples_for "has questionnaire" do
449
423
  it "renders the answer as a textarea" do
450
424
  visit questionnaire_public_path
451
425
 
452
- expect(page).to have_selector("textarea#questionnaire_responses_0")
426
+ expect(page).to have_css("textarea#questionnaire_responses_0")
453
427
  end
454
428
 
455
429
  it_behaves_like "question has a character limit"
@@ -475,13 +449,13 @@ shared_examples_for "has questionnaire" do
475
449
  it "renders answers as a collection of radio buttons" do
476
450
  visit questionnaire_public_path
477
451
 
478
- expect(page).to have_selector(".js-radio-button-collection input[type=radio]", count: 2)
452
+ expect(page).to have_css(".js-radio-button-collection input[type=radio]", count: 2)
479
453
 
480
454
  choose answer_options[0]["body"][:en]
481
455
 
482
456
  check "questionnaire_tos_agreement"
483
457
 
484
- accept_confirm { click_button "Submit" }
458
+ accept_confirm { click_on "Submit" }
485
459
 
486
460
  expect(page).to have_admin_callout(callout_success)
487
461
 
@@ -499,16 +473,16 @@ shared_examples_for "has questionnaire" do
499
473
  it "renders answers as a collection of radio buttons" do
500
474
  visit questionnaire_public_path
501
475
 
502
- expect(page).to have_selector(".js-check-box-collection input[type=checkbox]", count: 3)
476
+ expect(page).to have_css(".js-check-box-collection input[type=checkbox]", count: 3)
503
477
 
504
- expect(page).not_to have_content("Max choices:")
478
+ expect(page).to have_no_content("Max choices:")
505
479
 
506
480
  check answer_options[0]["body"][:en]
507
481
  check answer_options[1]["body"][:en]
508
482
 
509
483
  check "questionnaire_tos_agreement"
510
484
 
511
- accept_confirm { click_button "Submit" }
485
+ accept_confirm { click_on "Submit" }
512
486
 
513
487
  expect(page).to have_admin_callout(callout_success)
514
488
 
@@ -533,14 +507,14 @@ shared_examples_for "has questionnaire" do
533
507
 
534
508
  check "questionnaire_tos_agreement"
535
509
 
536
- accept_confirm { click_button "Submit" }
510
+ accept_confirm { click_on "Submit" }
537
511
 
538
512
  expect(page).to have_admin_callout("There was a problem answering")
539
513
  expect(page).to have_content("are too many")
540
514
 
541
515
  uncheck answer_options[2]["body"][:en]
542
516
 
543
- accept_confirm { click_button "Submit" }
517
+ accept_confirm { click_on "Submit" }
544
518
 
545
519
  expect(page).to have_admin_callout(callout_success)
546
520
  end
@@ -565,7 +539,7 @@ shared_examples_for "has questionnaire" do
565
539
  it "renders the question answers as a collection of divs sortable on drag and drop" do
566
540
  visit questionnaire_public_path
567
541
 
568
- expect(page).to have_selector("div.answer-questionnaire__sorting.js-collection-input", count: 5)
542
+ expect(page).to have_css("div.answer-questionnaire__sorting.js-collection-input", count: 5)
569
543
 
570
544
  %w(We all like dark chocolate).each do |term|
571
545
  expect(page).to have_content(term)
@@ -581,7 +555,7 @@ shared_examples_for "has questionnaire" do
581
555
 
582
556
  check "questionnaire_tos_agreement"
583
557
 
584
- accept_confirm { click_button "Submit" }
558
+ accept_confirm { click_on "Submit" }
585
559
 
586
560
  expect(page).to have_admin_callout(callout_success)
587
561
  expect(Decidim::Forms::Answer.first.choices.pluck(:position, :body)).to eq(
@@ -609,7 +583,7 @@ shared_examples_for "has questionnaire" do
609
583
  it "renders the question answers as a collection of radio buttons" do
610
584
  visit questionnaire_public_path
611
585
 
612
- expect(page).to have_selector(".js-radio-button-collection input[type=radio]", count: 4)
586
+ expect(page).to have_css(".js-radio-button-collection input[type=radio]", count: 4)
613
587
 
614
588
  expect(page).to have_content(matrix_rows.map { |row| row["body"]["en"] }.join("\n"))
615
589
  expect(page).to have_content(answer_options.map { |option| option["body"]["en"] }.join(" "))
@@ -621,7 +595,7 @@ shared_examples_for "has questionnaire" do
621
595
 
622
596
  check "questionnaire_tos_agreement"
623
597
 
624
- accept_confirm { click_button "Submit" }
598
+ accept_confirm { click_on "Submit" }
625
599
 
626
600
  expect(page).to have_admin_callout(callout_success)
627
601
 
@@ -642,7 +616,7 @@ shared_examples_for "has questionnaire" do
642
616
  radio_buttons = page.all(".js-radio-button-collection input[type=radio]")
643
617
  choose radio_buttons[1][:id]
644
618
 
645
- accept_confirm { click_button "Submit" }
619
+ accept_confirm { click_on "Submit" }
646
620
 
647
621
  expect(page).to have_admin_callout("There was a problem answering")
648
622
 
@@ -660,7 +634,7 @@ shared_examples_for "has questionnaire" do
660
634
  choose radio_buttons[0][:id]
661
635
 
662
636
  check "questionnaire_tos_agreement"
663
- accept_confirm { click_button "Submit" }
637
+ accept_confirm { click_on "Submit" }
664
638
 
665
639
  expect(page).to have_admin_callout("There was a problem answering")
666
640
  expect(page).to have_content("Choices are not complete")
@@ -689,7 +663,7 @@ shared_examples_for "has questionnaire" do
689
663
  it "renders the question answers as a collection of check boxes" do
690
664
  visit questionnaire_public_path
691
665
 
692
- expect(page).to have_selector(".js-check-box-collection input[type=checkbox]", count: 6)
666
+ expect(page).to have_css(".js-check-box-collection input[type=checkbox]", count: 6)
693
667
 
694
668
  expect(page).to have_content(matrix_rows.map { |row| row["body"]["en"] }.join("\n"))
695
669
  expect(page).to have_content(answer_options.map { |option| option["body"]["en"] }.join(" "))
@@ -702,7 +676,7 @@ shared_examples_for "has questionnaire" do
702
676
 
703
677
  check "questionnaire_tos_agreement"
704
678
 
705
- accept_confirm { click_button "Submit" }
679
+ accept_confirm { click_on "Submit" }
706
680
 
707
681
  expect(page).to have_admin_callout(callout_success)
708
682
 
@@ -718,7 +692,7 @@ shared_examples_for "has questionnaire" do
718
692
  expect(third_choice).to eq([question.answer_options.first.id, question.matrix_rows.last.id])
719
693
  end
720
694
 
721
- context "when the question hax max_choices defined" do
695
+ context "when the question has max_choices defined" do
722
696
  let!(:max_choices) { 2 }
723
697
 
724
698
  it "respects the max number of choices" do
@@ -747,7 +721,7 @@ shared_examples_for "has questionnaire" do
747
721
 
748
722
  check "questionnaire_tos_agreement"
749
723
 
750
- accept_confirm { click_button "Submit" }
724
+ accept_confirm { click_on "Submit" }
751
725
 
752
726
  expect(page).to have_admin_callout("There was a problem answering")
753
727
  expect(page).to have_content("are too many")
@@ -756,7 +730,7 @@ shared_examples_for "has questionnaire" do
756
730
 
757
731
  uncheck checkboxes[5][:id]
758
732
 
759
- accept_confirm { click_button "Submit" }
733
+ accept_confirm { click_on "Submit" }
760
734
 
761
735
  expect(page).to have_admin_callout(callout_success)
762
736
  end
@@ -772,7 +746,7 @@ shared_examples_for "has questionnaire" do
772
746
  check checkboxes[0][:id]
773
747
 
774
748
  check "questionnaire_tos_agreement"
775
- accept_confirm { click_button "Submit" }
749
+ accept_confirm { click_on "Submit" }
776
750
 
777
751
  expect(page).to have_admin_callout("There was a problem answering")
778
752
  expect(page).to have_content("Choices are not complete")
@@ -792,7 +766,7 @@ shared_examples_for "has questionnaire" do
792
766
  check checkboxes[5][:id]
793
767
 
794
768
  check "questionnaire_tos_agreement"
795
- accept_confirm { click_button "Submit" }
769
+ accept_confirm { click_on "Submit" }
796
770
 
797
771
  expect(page).to have_admin_callout("There was a problem answering")
798
772
 
@@ -1332,7 +1306,7 @@ shared_examples_for "has questionnaire" do
1332
1306
 
1333
1307
  check "questionnaire_tos_agreement"
1334
1308
 
1335
- accept_confirm { click_button "Submit" }
1309
+ accept_confirm { click_on "Submit" }
1336
1310
 
1337
1311
  expect(page).to have_admin_callout(callout_success)
1338
1312
  end
@@ -38,10 +38,10 @@ shared_examples_for "manage questionnaire answers" do
38
38
  context "and managing answers page" do
39
39
  before do
40
40
  visit questionnaire_edit_path
41
- click_link "Show responses"
41
+ click_on "Show responses"
42
42
  end
43
43
 
44
- it "shows the anwers page" do
44
+ it "shows the answers page" do
45
45
  expect(page).to have_content(answer1.body)
46
46
  expect(page).to have_content(answer1.question.body["en"])
47
47
  expect(page).to have_content(answer2.body)
@@ -66,7 +66,7 @@ shared_examples_for "manage questionnaire answers" do
66
66
  let(:first_type) { "long_answer" }
67
67
 
68
68
  it "shows session token" do
69
- expect(page).not_to have_content(answer1.body)
69
+ expect(page).to have_no_content(answer1.body)
70
70
  expect(page).to have_content(answer1.session_token)
71
71
  expect(page).to have_content(answer2.session_token)
72
72
  expect(page).to have_content(answer3.session_token)
@@ -98,36 +98,36 @@ shared_examples_for "manage questionnaire answers" do
98
98
 
99
99
  before do
100
100
  visit questionnaire_edit_path
101
- click_link "Show responses"
101
+ click_on "Show responses"
102
102
  end
103
103
 
104
104
  it "shows all the questions and responses" do
105
- click_link answer1.body, match: :first
105
+ click_on answer1.body, match: :first
106
106
  expect(page).to have_content(first.body["en"])
107
107
  expect(page).to have_content(second.body["en"])
108
108
  expect(page).to have_content(answer1.body)
109
109
  end
110
110
 
111
111
  it "first answer has a next link" do
112
- click_link answer1.body, match: :first
112
+ click_on answer1.body, match: :first
113
113
  expect(page).to have_link("Next ›")
114
- expect(page).not_to have_link("‹ Prev")
114
+ expect(page).to have_no_link("‹ Prev")
115
115
  end
116
116
 
117
117
  it "second answer has prev/next links" do
118
- click_link answer2.body, match: :first
118
+ click_on answer2.body, match: :first
119
119
  expect(page).to have_link("Next ›")
120
120
  expect(page).to have_link("‹ Prev")
121
121
  end
122
122
 
123
123
  it "third answer has prev link" do
124
- click_link answer3.session_token, match: :first
125
- expect(page).not_to have_link("Next ›")
124
+ click_on answer3.session_token, match: :first
125
+ expect(page).to have_no_link("Next ›")
126
126
  expect(page).to have_link("‹ Prev")
127
127
  end
128
128
 
129
129
  it "third answer has download link for the attachments" do
130
- click_link answer3.session_token, match: :first
130
+ click_on answer3.session_token, match: :first
131
131
  expect(page).to have_content(translated(file_answer.attachments.first.title))
132
132
  expect(page).to have_content(translated(file_answer.attachments.second.title))
133
133
  end
@@ -140,7 +140,7 @@ shared_examples_for "manage questionnaire answers" do
140
140
  end
141
141
 
142
142
  it "third answer has download link for the attachments" do
143
- click_link answer3.session_token, match: :first
143
+ click_on answer3.session_token, match: :first
144
144
  expect(page).to have_content("Download attachment")
145
145
  end
146
146
  end
@@ -21,13 +21,13 @@ shared_examples_for "add display conditions" do
21
21
  end
22
22
 
23
23
  it "does not display an add display condition button" do
24
- expect(page).not_to have_button("Add display condition")
24
+ expect(page).to have_no_button("Add display condition")
25
25
  end
26
26
 
27
27
  context "when creating a new question" do
28
28
  it "disables the add display condition button if the question has not been saved" do
29
29
  within "form.edit_questionnaire" do
30
- click_button "Add question"
30
+ click_on "Add question"
31
31
  expand_all_questions
32
32
 
33
33
  expect(page).to have_button("Add display condition", disabled: true)
@@ -80,19 +80,19 @@ shared_examples_for "add display conditions" do
80
80
  within_add_display_condition do
81
81
  expect(page).to have_select("Question")
82
82
  expect(page).to have_select("Condition")
83
- expect(page).to have_selector("[id$=mandatory]")
83
+ expect(page).to have_css("[id$=mandatory]")
84
84
 
85
85
  select question_single_option.body["en"], from: "Question"
86
86
  select "Answered", from: "Condition"
87
87
 
88
- expect(page).not_to have_select("Answer option")
89
- expect(page).not_to have_css("[id$=condition_value_en]", visible: :visible)
88
+ expect(page).to have_no_select("Answer option")
89
+ expect(page).to have_no_css("[id$=condition_value_en]", visible: :visible)
90
90
 
91
91
  select question_single_option.body["en"], from: "Question"
92
92
  select "Equal", from: "Condition"
93
93
 
94
94
  expect(page).to have_select("Answer option")
95
- expect(page).not_to have_css("[id$=condition_value_en]", visible: :visible)
95
+ expect(page).to have_no_css("[id$=condition_value_en]", visible: :visible)
96
96
  end
97
97
  end
98
98
  end
@@ -163,17 +163,17 @@ shared_examples_for "add display conditions" do
163
163
 
164
164
  it "loads a mandatory field with false value" do
165
165
  within_add_display_condition do
166
- expect(page).to have_selector("[id$=mandatory]")
167
- expect(page).not_to have_selector("[id$=mandatory][checked]")
166
+ expect(page).to have_css("[id$=mandatory]")
167
+ expect(page).to have_no_css("[id$=mandatory][checked]")
168
168
  end
169
169
  end
170
170
 
171
171
  it "can be removed" do
172
172
  within_add_display_condition do
173
- click_button "Remove"
173
+ click_on "Remove"
174
174
  end
175
175
 
176
- click_button "Save"
176
+ click_on "Save"
177
177
 
178
178
  expect(page).to have_admin_callout("successfully")
179
179
  end