decidim-forms 0.22.0 → 0.23.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/admin/decidim_forms_manifest.css +3 -0
  3. data/app/assets/config/decidim_forms_manifest.css +1 -0
  4. data/app/assets/javascripts/decidim/forms/admin/auto_select_options_from_url.component.js.es6 +40 -0
  5. data/app/assets/javascripts/decidim/forms/admin/forms.js.es6 +181 -25
  6. data/app/assets/javascripts/decidim/forms/autosortable_checkboxes.component.js.es6 +54 -34
  7. data/app/assets/javascripts/decidim/forms/display_conditions.component.js.es6 +203 -0
  8. data/app/assets/javascripts/decidim/forms/forms.js.es6 +8 -1
  9. data/app/assets/stylesheets/decidim/forms/questionnaire-answers-pdf.scss +69 -0
  10. data/app/commands/decidim/forms/admin/update_questionnaire.rb +25 -1
  11. data/app/commands/decidim/forms/answer_questionnaire.rb +1 -1
  12. data/app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb +47 -1
  13. data/app/controllers/decidim/forms/admin/concerns/has_questionnaire_answers.rb +97 -0
  14. data/app/controllers/decidim/forms/concerns/has_questionnaire.rb +3 -2
  15. data/app/forms/decidim/forms/admin/display_condition_form.rb +100 -0
  16. data/app/forms/decidim/forms/admin/question_form.rb +1 -0
  17. data/app/forms/decidim/forms/answer_form.rb +15 -0
  18. data/app/forms/decidim/forms/questionnaire_form.rb +5 -0
  19. data/app/helpers/decidim/forms/admin/application_helper.rb +21 -0
  20. data/app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_pagination_helper.rb +49 -0
  21. data/app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_url_helper.rb +40 -0
  22. data/app/helpers/decidim/forms/admin/questionnaire_answers_helper.rb +30 -0
  23. data/app/jobs/decidim/forms/export_questionnaire_answers_job.rb +19 -0
  24. data/app/models/decidim/forms/answer.rb +0 -3
  25. data/app/models/decidim/forms/answer_option.rb +14 -0
  26. data/app/models/decidim/forms/display_condition.rb +65 -0
  27. data/app/models/decidim/forms/question.rb +34 -0
  28. data/app/models/decidim/forms/question_matrix_row.rb +3 -0
  29. data/app/models/decidim/forms/questionnaire.rb +22 -1
  30. data/app/presenters/decidim/forms/admin/questionnaire_answer_presenter.rb +43 -0
  31. data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +60 -0
  32. data/app/presenters/decidim/forms/answer_option_presenter.rb +20 -0
  33. data/app/presenters/decidim/forms/question_presenter.rb +16 -0
  34. data/app/queries/decidim/forms/questionnaire_participant.rb +35 -0
  35. data/app/queries/decidim/forms/questionnaire_participants.rb +43 -0
  36. data/app/views/decidim/forms/admin/questionnaires/_display_condition.html.erb +88 -0
  37. data/app/views/decidim/forms/admin/questionnaires/_display_condition_template.html.erb +7 -0
  38. data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +30 -4
  39. data/app/views/decidim/forms/admin/questionnaires/_question.html.erb +19 -3
  40. data/app/views/decidim/forms/admin/questionnaires/answers/export/_answer.html.erb +31 -0
  41. data/app/views/decidim/forms/admin/questionnaires/answers/export/pdf.html.erb +13 -0
  42. data/app/views/decidim/forms/admin/questionnaires/answers/index.html.erb +53 -0
  43. data/app/views/decidim/forms/admin/questionnaires/answers/show.html.erb +48 -0
  44. data/app/views/decidim/forms/admin/questionnaires/edit.html.erb +9 -5
  45. data/app/views/decidim/forms/questionnaires/_answer.html.erb +1 -1
  46. data/app/views/decidim/forms/questionnaires/show.html.erb +22 -2
  47. data/app/views/layouts/decidim/forms/admin/questionnaires/questionnaire_answers.html.erb +12 -0
  48. data/config/initializers/wicked_pdf.rb +25 -0
  49. data/config/locales/am-ET.yml +1 -0
  50. data/config/locales/ar.yml +0 -1
  51. data/config/locales/bg-BG.yml +0 -2
  52. data/config/locales/bg.yml +14 -0
  53. data/config/locales/ca.yml +56 -4
  54. data/config/locales/cs.yml +56 -4
  55. data/config/locales/da.yml +1 -0
  56. data/config/locales/de.yml +53 -1
  57. data/config/locales/el.yml +0 -2
  58. data/config/locales/en.yml +54 -2
  59. data/config/locales/eo.yml +1 -0
  60. data/config/locales/es-MX.yml +53 -1
  61. data/config/locales/es-PY.yml +53 -1
  62. data/config/locales/es.yml +54 -2
  63. data/config/locales/et.yml +1 -0
  64. data/config/locales/eu.yml +0 -1
  65. data/config/locales/fi-plain.yml +53 -1
  66. data/config/locales/fi.yml +53 -1
  67. data/config/locales/fr-CA.yml +54 -2
  68. data/config/locales/fr.yml +55 -3
  69. data/config/locales/gl.yml +1 -1
  70. data/config/locales/hr.yml +1 -0
  71. data/config/locales/hu.yml +0 -2
  72. data/config/locales/id-ID.yml +0 -1
  73. data/config/locales/is.yml +1 -0
  74. data/config/locales/it.yml +53 -1
  75. data/config/locales/ja-JP.yml +51 -1
  76. data/config/locales/ja.yml +170 -0
  77. data/config/locales/ko-KR.yml +1 -0
  78. data/config/locales/ko.yml +1 -0
  79. data/config/locales/lt.yml +1 -0
  80. data/config/locales/{lv-LV.yml → lv.yml} +0 -1
  81. data/config/locales/mt.yml +1 -0
  82. data/config/locales/nl.yml +59 -7
  83. data/config/locales/no.yml +48 -2
  84. data/config/locales/om-ET.yml +1 -0
  85. data/config/locales/pl.yml +52 -3
  86. data/config/locales/pt-BR.yml +0 -1
  87. data/config/locales/pt.yml +51 -2
  88. data/config/locales/ro-RO.yml +51 -2
  89. data/config/locales/ru.yml +0 -1
  90. data/config/locales/si-LK.yml +1 -0
  91. data/config/locales/sk.yml +0 -2
  92. data/config/locales/sl.yml +7 -0
  93. data/config/locales/so-SO.yml +1 -0
  94. data/config/locales/sv.yml +51 -2
  95. data/config/locales/sw-KE.yml +1 -0
  96. data/config/locales/ti-ER.yml +1 -0
  97. data/config/locales/tr-TR.yml +88 -2
  98. data/config/locales/vi-VN.yml +1 -0
  99. data/config/locales/vi.yml +1 -0
  100. data/config/locales/zh-CN.yml +172 -0
  101. data/config/locales/zh-TW.yml +1 -0
  102. data/db/migrate/20200130194123_create_decidim_forms_display_conditions.rb +20 -0
  103. data/db/migrate/20201110152921_add_salt_to_decidim_forms_questionnaires.rb +16 -0
  104. data/lib/decidim/exporters/form_pdf.rb +33 -0
  105. data/lib/decidim/exporters/form_pdf_controller_helper.rb +11 -0
  106. data/lib/decidim/forms.rb +5 -0
  107. data/lib/decidim/forms/admin_engine.rb +1 -1
  108. data/lib/decidim/forms/test.rb +6 -0
  109. data/lib/decidim/forms/test/factories.rb +31 -0
  110. data/lib/decidim/forms/test/shared_examples/has_questionnaire.rb +619 -38
  111. data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +108 -0
  112. data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +21 -894
  113. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_display_conditions.rb +179 -0
  114. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +463 -0
  115. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb +93 -0
  116. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +461 -0
  117. data/lib/decidim/forms/user_answers_serializer.rb +1 -1
  118. data/lib/decidim/forms/version.rb +1 -1
  119. metadata +97 -14
@@ -0,0 +1 @@
1
+ vi:
@@ -0,0 +1 @@
1
+ vi:
@@ -0,0 +1,172 @@
1
+ zh-CN:
2
+ activemodel:
3
+ attributes:
4
+ answer:
5
+ body: 答案
6
+ choices: 选择
7
+ selected_choices: 选定的选择
8
+ question:
9
+ max_choices: 选择的最大数量
10
+ question_type: 类型
11
+ questionnaire_question:
12
+ mandatory: Mandatory
13
+ errors:
14
+ models:
15
+ answer:
16
+ attributes:
17
+ choices:
18
+ missing: 不完成
19
+ too_many: 太多了
20
+ questionnaire:
21
+ request_invalid: 处理请求时出错。请再试一次
22
+ decidim:
23
+ forms:
24
+ admin:
25
+ models:
26
+ components:
27
+ description: 描述
28
+ tos: 服务条款
29
+ questionnaires:
30
+ actions:
31
+ back: 返回问题
32
+ show: 显示回复
33
+ answer_option:
34
+ answer_option: 答案选项
35
+ free_text: 免费文本
36
+ remove: 删除
37
+ statement: 声明
38
+ answers:
39
+ actions:
40
+ back: 回到回应
41
+ export: 导出
42
+ show: 显示答案
43
+ empty: 尚无答案
44
+ export:
45
+ answer:
46
+ title: '回复 #%{number}'
47
+ export_response:
48
+ title: survey_user_answers_%{token}
49
+ index:
50
+ title: "%{total} 个回复总数"
51
+ show:
52
+ title: '答案 #%{number}'
53
+ display_condition:
54
+ answer_option: 答案选项
55
+ condition_question: 问
56
+ condition_type: 条件
57
+ condition_types:
58
+ answered: 已回答
59
+ equal: 等于
60
+ match: 包含文本
61
+ not_answered: 未回答
62
+ not_equal: 不等于
63
+ condition_value: 包含文本
64
+ display_condition: 显示条件
65
+ mandatory: 无论其他条件的状况如何,总是需要满足这个条件
66
+ remove: 删除
67
+ save_warning: 在配置显示条件之前记住保存表单
68
+ select_answer_option: 选择答案选项
69
+ select_condition_question: 选择一个问题
70
+ select_condition_type: 选择一个条件类型
71
+ edit:
72
+ save: 保存
73
+ title: 编辑问题单
74
+ form:
75
+ add_question: 添加问题
76
+ add_separator: 添加分隔符
77
+ already_answered_warning: 某些用户已经回答了表单,因此您不能修改其问题。
78
+ collapse: 收起所有问题
79
+ expand: 展开所有问题
80
+ preview: 预览
81
+ title: 编辑表单
82
+ unpublished_warning: 表单未发布。您可以修改它的问题,但这样做将删除当前答案。
83
+ matrix_row:
84
+ matrix_row: 行
85
+ remove: 删除
86
+ statement: 声明
87
+ question:
88
+ add_answer_option: 添加答案选项
89
+ add_display_condition: 添加显示条件
90
+ add_display_condition_info: 保存表单以配置显示条件
91
+ add_matrix_row: 添加行
92
+ any: 任何
93
+ collapse: 收起
94
+ description: 描述
95
+ down: 向下
96
+ expand: 扩展
97
+ question: 问
98
+ remove: 删除
99
+ statement: 声明
100
+ up: 上移
101
+ separator:
102
+ down: 向下
103
+ remove: 删除
104
+ separator: 分隔符
105
+ up: 上移
106
+ update:
107
+ invalid: 保存表单时出错。
108
+ success: 表单保存成功。
109
+ errors:
110
+ answer:
111
+ body: 主体不能为空
112
+ files:
113
+ extension_whitelist: '接受的格式:'
114
+ images:
115
+ dimensions: "%{width} x %{height} px"
116
+ dimensions_info: '这张图片将是:'
117
+ processors:
118
+ resize_and_pad: 缩放并填充到
119
+ resize_to_fit: 调整到适合的
120
+ question_types:
121
+ long_answer: 长答案
122
+ matrix_multiple: 矩阵(多选项)
123
+ matrix_single: 矩阵(单选项)
124
+ multiple_option: 多选项
125
+ short_answer: 简短答案
126
+ single_option: 单个选项
127
+ sorting: 排序中
128
+ questionnaires:
129
+ answer:
130
+ invalid: 回答表单时出现问题。
131
+ max_choices_alert: 选择了太多选项
132
+ success: 表单回答成功。
133
+ question:
134
+ max_choices: '最大选择数: %{n}'
135
+ show:
136
+ answer_questionnaire:
137
+ anonymous_user_message: <a href="%{sign_in_link}">使用您的帐户</a> 或 <a href="%{sign_up_link}">注册</a> 以回答表单。
138
+ title: 回答表单
139
+ current_step: 步骤 %{step}
140
+ of_total_steps: '%{total_steps}'
141
+ questionnaire_answered:
142
+ body: 您已经回答过这个表单。
143
+ title: 已经回答
144
+ questionnaire_closed:
145
+ body: 表格已关闭,无法解答。
146
+ title: 表单已关闭
147
+ questionnaire_for_private_users:
148
+ body: 表单仅供私人用户使用
149
+ title: 表单已关闭
150
+ questionnaire_js_disabled:
151
+ body: 此表单的一些功能将被禁用。为了改善您的体验,请在您的浏览器中启用 JavaScript。
152
+ title: JavaScript 已禁用
153
+ questionnaire_not_published:
154
+ body: 此表单尚未发布。
155
+ tos_agreement: 通过参与您接受其服务条款
156
+ step_navigation:
157
+ show:
158
+ are_you_sure: 此操作不能撤消,您将无法编辑您的答案。您确定吗?
159
+ back: 后退
160
+ continue: 继续
161
+ submit: 提交
162
+ user_answers_serializer:
163
+ body: 答案
164
+ completion: 完成
165
+ created_at: 回答于
166
+ id: 答案 ID
167
+ ip_hash: IP哈希
168
+ question: 问
169
+ registered: 已注册
170
+ session_token: 用户标识符
171
+ unregistered: 未注册
172
+ user_status: 用户状态
@@ -0,0 +1 @@
1
+ zh-TW:
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimFormsDisplayConditions < ActiveRecord::Migration[5.1]
4
+ def up
5
+ create_table :decidim_forms_display_conditions do |t|
6
+ t.bigint :decidim_question_id, index: { name: "decidim_forms_display_condition_question" }, null: false
7
+ t.bigint :decidim_condition_question_id, index: { name: "decidim_forms_display_condition_condition_question" }, null: false
8
+ t.bigint :decidim_answer_option_id, index: { name: "decidim_forms_display_condition_answer_option" }
9
+ t.integer :condition_type, default: 0, null: false
10
+ t.jsonb :condition_value
11
+ t.boolean :mandatory, default: false
12
+
13
+ t.timestamps
14
+ end
15
+ end
16
+
17
+ def down
18
+ drop_table :decidim_forms_display_conditions
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddSaltToDecidimFormsQuestionnaires < ActiveRecord::Migration[5.2]
4
+ class Questionnaire < ApplicationRecord
5
+ self.table_name = :decidim_forms_questionnaires
6
+ end
7
+
8
+ def change
9
+ add_column :decidim_forms_questionnaires, :salt, :string
10
+
11
+ Questionnaire.find_each do |questionnaire|
12
+ questionnaire.salt = Decidim::Tokenizer.random_salt
13
+ questionnaire.save!
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "wicked_pdf"
4
+
5
+ module Decidim
6
+ module Exporters
7
+ # Inherits from abstract PDF exporter. This class is used to set
8
+ # the parameters used to create a PDF when exporting Survey Answers.
9
+ #
10
+ class FormPDF < PDF
11
+ # i18n-tasks-use t('decidim.admin.exports.formats.FormPDF')
12
+
13
+ def controller
14
+ @controller ||= FormPDFControllerHelper.new
15
+ end
16
+
17
+ def template
18
+ "decidim/forms/admin/questionnaires/answers/export/pdf.html.erb"
19
+ end
20
+
21
+ def layout
22
+ "decidim/forms/admin/questionnaires/questionnaire_answers.html.erb"
23
+ end
24
+
25
+ def locals
26
+ {
27
+ questionnaire: collection.first.first.questionnaire,
28
+ collection: collection.map { |answer| Decidim::Forms::Admin::QuestionnaireParticipantPresenter.new(participant: answer.first) }
29
+ }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Exporters
5
+ # A dummy controller to render views while exporting questionnaires
6
+ class FormPDFControllerHelper < ActionController::Base
7
+ helper Decidim::TranslationsHelper
8
+ helper Decidim::Forms::Admin::QuestionnaireAnswersHelper
9
+ end
10
+ end
11
+ end
data/lib/decidim/forms.rb CHANGED
@@ -11,4 +11,9 @@ module Decidim
11
11
  autoload :UserAnswersSerializer, "decidim/forms/user_answers_serializer"
12
12
  autoload :DataPortabilityUserAnswersSerializer, "decidim/forms/data_portability_user_answers_serializer"
13
13
  end
14
+
15
+ module Exporters
16
+ autoload :FormPDF, "decidim/exporters/form_pdf"
17
+ autoload :FormPDFControllerHelper, "decidim/exporters/form_pdf_controller_helper"
18
+ end
14
19
  end
@@ -10,7 +10,7 @@ module Decidim
10
10
  paths["lib/tasks"] = nil
11
11
 
12
12
  initializer "decidim_forms.admin_assets" do |app|
13
- app.config.assets.precompile += %w(admin/decidim_forms_manifest.js)
13
+ app.config.assets.precompile += %w(admin/decidim_forms_manifest.js admin/decidim_forms_manifest.css)
14
14
  end
15
15
 
16
16
  def load_seed
@@ -2,3 +2,9 @@
2
2
 
3
3
  require "decidim/forms/test/shared_examples/has_questionnaire"
4
4
  require "decidim/forms/test/shared_examples/manage_questionnaires"
5
+ require "decidim/forms/test/shared_examples/manage_questionnaire_answers"
6
+
7
+ if defined? Decidim::Templates
8
+ require "decidim/templates/test/shared_examples/uses_questionnaire_templates"
9
+ require "decidim/templates/test/factories"
10
+ end
@@ -13,6 +13,7 @@ FactoryBot.define do
13
13
  end
14
14
  tos { generate_localized_title }
15
15
  questionnaire_for { build(:participatory_process) }
16
+ salt { SecureRandom.hex(32) }
16
17
 
17
18
  trait :with_questions do
18
19
  questions do
@@ -23,6 +24,12 @@ FactoryBot.define do
23
24
  qs
24
25
  end
25
26
  end
27
+
28
+ trait :empty do
29
+ title { {} }
30
+ description { {} }
31
+ tos { {} }
32
+ end
26
33
  end
27
34
 
28
35
  factory :questionnaire_question, class: "Decidim::Forms::Question" do
@@ -67,6 +74,12 @@ FactoryBot.define do
67
74
  end
68
75
  end
69
76
 
77
+ trait :conditioned do
78
+ display_conditions do
79
+ Array.new(3).collect { build(:display_condition) }
80
+ end
81
+ end
82
+
70
83
  trait :separator do
71
84
  question_type { :separator }
72
85
  end
@@ -77,6 +90,7 @@ FactoryBot.define do
77
90
  questionnaire
78
91
  question { create(:questionnaire_question, questionnaire: questionnaire) }
79
92
  user { create(:user, organization: questionnaire.questionnaire_for.organization) }
93
+ session_token { Digest::MD5.hexdigest(user.id.to_s) }
80
94
  end
81
95
 
82
96
  factory :answer_option, class: "Decidim::Forms::AnswerOption" do
@@ -96,4 +110,21 @@ FactoryBot.define do
96
110
  body { generate_localized_title }
97
111
  position { 0 }
98
112
  end
113
+
114
+ factory :display_condition, class: "Decidim::Forms::DisplayCondition" do
115
+ condition_question { create(:questionnaire_question) }
116
+ question { create(:questionnaire_question, position: 1) }
117
+ condition_type { :answered }
118
+ mandatory { true }
119
+
120
+ trait :equal do
121
+ condition_type { :equal }
122
+ answer_option { create(:answer_option, question: condition_question) }
123
+ end
124
+
125
+ trait :match do
126
+ condition_type { :match }
127
+ condition_value { generate_localized_title }
128
+ end
129
+ end
99
130
  end
@@ -75,7 +75,7 @@ shared_examples_for "has questionnaire" do
75
75
  click_link "Back"
76
76
 
77
77
  expect(page).to have_content("STEP 1 OF 2")
78
- expect(page).to have_field("questionnaire_answers_0", with: "My first answer")
78
+ expect(page).to have_field("questionnaire_responses_0", with: "My first answer")
79
79
  end
80
80
 
81
81
  it "finishes the submission when answering the last questionnaire" do
@@ -257,7 +257,7 @@ shared_examples_for "has questionnaire" do
257
257
  end
258
258
 
259
259
  context "when a question has a rich text description" do
260
- let!(:question) { create(:questionnaire_question, questionnaire: questionnaire, position: 0, description: "<b>This question is important</b>") }
260
+ let!(:question) { create(:questionnaire_question, questionnaire: questionnaire, position: 0, description: { en: "<b>This question is important</b>" }) }
261
261
 
262
262
  it "properly interprets HTML descriptions" do
263
263
  visit questionnaire_public_path
@@ -308,16 +308,16 @@ shared_examples_for "has questionnaire" do
308
308
  it "renders them as radio buttons with attached text fields disabled by default" do
309
309
  expect(page).to have_selector(".radio-button-collection input[type=radio]", count: 3)
310
310
 
311
- expect(page).to have_field("questionnaire_answers_0_choices_2_custom_body", disabled: true, count: 1)
311
+ expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", disabled: true, count: 1)
312
312
 
313
313
  choose answer_option_bodies[2]["en"]
314
314
 
315
- expect(page).to have_field("questionnaire_answers_0_choices_2_custom_body", disabled: false, count: 1)
315
+ expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", disabled: false, count: 1)
316
316
  end
317
317
 
318
318
  it "saves the free text in a separate field if submission correct" do
319
319
  choose answer_option_bodies[2]["en"]
320
- fill_in "questionnaire_answers_0_choices_2_custom_body", with: "Cacatua"
320
+ fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
321
321
 
322
322
  check "questionnaire_tos_agreement"
323
323
  accept_confirm { click_button "Submit" }
@@ -335,7 +335,7 @@ shared_examples_for "has questionnaire" do
335
335
  check other_question.answer_options.third.body["en"]
336
336
 
337
337
  choose answer_option_bodies[2]["en"]
338
- fill_in "questionnaire_answers_0_choices_2_custom_body", with: "Cacatua"
338
+ fill_in "questionnaire_responses_0_choices_2_custom_body", with: "Cacatua"
339
339
 
340
340
  check "questionnaire_tos_agreement"
341
341
  accept_confirm { click_button "Submit" }
@@ -344,7 +344,7 @@ shared_examples_for "has questionnaire" do
344
344
  expect(page).to have_content("There was a problem answering")
345
345
  end
346
346
 
347
- expect(page).to have_field("questionnaire_answers_0_choices_2_custom_body", with: "Cacatua")
347
+ expect(page).to have_field("questionnaire_responses_0_choices_2_custom_body", with: "Cacatua")
348
348
  end
349
349
  end
350
350
 
@@ -401,7 +401,7 @@ shared_examples_for "has questionnaire" do
401
401
  it "renders the answer as a textarea" do
402
402
  visit questionnaire_public_path
403
403
 
404
- expect(page).to have_selector("textarea#questionnaire_answers_0")
404
+ expect(page).to have_selector("textarea#questionnaire_responses_0")
405
405
  end
406
406
  end
407
407
 
@@ -411,7 +411,7 @@ shared_examples_for "has questionnaire" do
411
411
  it "renders the answer as a text field" do
412
412
  visit questionnaire_public_path
413
413
 
414
- expect(page).to have_selector("input[type=text]#questionnaire_answers_0")
414
+ expect(page).to have_selector("input[type=text]#questionnaire_responses_0")
415
415
  end
416
416
  end
417
417
 
@@ -509,11 +509,11 @@ shared_examples_for "has questionnaire" do
509
509
  questionnaire: questionnaire,
510
510
  question_type: "sorting",
511
511
  options: [
512
- { "body" => "idiotas" },
513
- { "body" => "trates" },
514
- { "body" => "No" },
515
- { "body" => "por" },
516
- { "body" => "nos" }
512
+ { "body" => { "en" => "chocolate" } },
513
+ { "body" => { "en" => "like" } },
514
+ { "body" => { "en" => "We" } },
515
+ { "body" => { "en" => "dark" } },
516
+ { "body" => { "en" => "all" } }
517
517
  ]
518
518
  )
519
519
  end
@@ -523,25 +523,25 @@ shared_examples_for "has questionnaire" do
523
523
 
524
524
  expect(page).to have_selector(".sortable-check-box-collection input[type=checkbox]", count: 5)
525
525
 
526
- expect(page).to have_content("idiotas\ntrates\nNo\npor\nnos")
526
+ expect(page).to have_content("chocolate\nlike\nWe\ndark\nall")
527
527
 
528
- check "No"
529
- check "nos"
530
- check "trates"
531
- check "por"
532
- check "idiotas"
528
+ check "We"
529
+ check "all"
530
+ check "like"
531
+ check "dark"
532
+ check "chocolate"
533
533
 
534
- expect(page).to have_content("1. No\n2. nos\n3. trates\n4. por\n5. idiotas")
534
+ expect(page).to have_content("1. We\n2. all\n3. like\n4. dark\n5. chocolate")
535
535
  end
536
536
 
537
537
  it "properly saves valid sortings" do
538
538
  visit questionnaire_public_path
539
539
 
540
- check "No"
541
- check "nos"
542
- check "trates"
543
- check "por"
544
- check "idiotas"
540
+ check "We"
541
+ check "all"
542
+ check "like"
543
+ check "dark"
544
+ check "chocolate"
545
545
 
546
546
  check "questionnaire_tos_agreement"
547
547
 
@@ -552,14 +552,46 @@ shared_examples_for "has questionnaire" do
552
552
  end
553
553
 
554
554
  expect(Decidim::Forms::Answer.first.choices.pluck(:position, :body)).to eq(
555
- [[0, "No"], [1, "nos"], [2, "trates"], [3, "por"], [4, "idiotas"]]
555
+ [[0, "We"], [1, "all"], [2, "like"], [3, "dark"], [4, "chocolate"]]
556
556
  )
557
557
  end
558
558
 
559
559
  it "displays errors on incomplete sortings" do
560
560
  visit questionnaire_public_path
561
561
 
562
- check "No"
562
+ check "We"
563
+
564
+ accept_confirm { click_button "Submit" }
565
+
566
+ within ".alert.flash" do
567
+ expect(page).to have_content("problem")
568
+ end
569
+
570
+ expect(page).to have_content("are not complete")
571
+ end
572
+
573
+ it "displays maintains sorting order if errors" do
574
+ visit questionnaire_public_path
575
+
576
+ check "We"
577
+ check "dark"
578
+ check "chocolate"
579
+
580
+ accept_confirm { click_button "Submit" }
581
+
582
+ within ".alert.flash" do
583
+ expect(page).to have_content("problem")
584
+ end
585
+
586
+ # Check the next round to ensure a re-submission conserves status
587
+ expect(page).to have_content("are not complete")
588
+ expect(page).to have_content("1. We\n2. dark\n3. chocolate\nlike\nall")
589
+
590
+ checkboxes = page.all("input[type=checkbox]")
591
+
592
+ checkboxes[0].uncheck
593
+ check "We"
594
+ check "all"
563
595
 
564
596
  accept_confirm { click_button "Submit" }
565
597
 
@@ -568,6 +600,7 @@ shared_examples_for "has questionnaire" do
568
600
  end
569
601
 
570
602
  expect(page).to have_content("are not complete")
603
+ expect(page).to have_content("1. dark\n2. chocolate\n3. We\n4. all\nlike")
571
604
  end
572
605
  end
573
606
 
@@ -757,6 +790,26 @@ shared_examples_for "has questionnaire" do
757
790
  end
758
791
  end
759
792
 
793
+ context "when the question is mandatory and the answer is not complete" do
794
+ let!(:mandatory) { true }
795
+
796
+ it "shows an error" do
797
+ visit questionnaire_public_path
798
+
799
+ checkboxes = page.all(".check-box-collection input[type=checkbox]")
800
+ check checkboxes[0][:id]
801
+
802
+ check "questionnaire_tos_agreement"
803
+ accept_confirm { click_button "Submit" }
804
+
805
+ within ".alert.flash" do
806
+ expect(page).to have_content("There was a problem answering")
807
+ end
808
+
809
+ expect(page).to have_content("Choices are not complete")
810
+ end
811
+ end
812
+
760
813
  context "when the submission is not correct" do
761
814
  let!(:max_choices) { 2 }
762
815
 
@@ -780,26 +833,554 @@ shared_examples_for "has questionnaire" do
780
833
  expect(checkboxes.map { |c| c[:checked] }).to eq(["true", "true", "true", nil, nil, "true"])
781
834
  end
782
835
  end
836
+ end
783
837
 
784
- context "when the question is mandatory and the answer is not complete" do
785
- let!(:mandatory) { true }
838
+ describe "display conditions" do
839
+ let(:answer_options) do
840
+ 3.times.to_a.map do |x|
841
+ {
842
+ "body" => Decidim::Faker::Localized.sentence,
843
+ "free_text" => x == 2
844
+ }
845
+ end
846
+ end
847
+ let(:condition_question_options) { [] }
848
+ let!(:question) { create(:questionnaire_question, questionnaire: questionnaire, position: 2) }
849
+ let!(:conditioned_question_id) { "#questionnaire_responses_1" }
850
+ let!(:condition_question) do
851
+ create(:questionnaire_question,
852
+ questionnaire: questionnaire,
853
+ question_type: condition_question_type,
854
+ position: 1,
855
+ options: condition_question_options)
856
+ end
786
857
 
787
- it "shows an error" do
858
+ context "when a question has a display condition" do
859
+ context "when condition is of type 'answered'" do
860
+ let!(:display_condition) do
861
+ create(:display_condition,
862
+ condition_type: "answered",
863
+ question: question,
864
+ condition_question: condition_question)
865
+ end
866
+
867
+ before do
868
+ visit questionnaire_public_path
869
+ end
870
+
871
+ context "when the condition_question type is short answer" do
872
+ let!(:condition_question_type) { "short_answer" }
873
+
874
+ it "shows the question only if the condition is fulfilled" do
875
+ expect_question_to_be_visible(false)
876
+
877
+ fill_in "questionnaire_responses_0", with: "Cacatua"
878
+ change_focus
879
+
880
+ expect_question_to_be_visible(true)
881
+
882
+ fill_in "questionnaire_responses_0", with: ""
883
+ change_focus
884
+
885
+ expect_question_to_be_visible(false)
886
+ end
887
+ end
888
+
889
+ context "when the condition_question type is long answer" do
890
+ let!(:condition_question_type) { "long_answer" }
891
+
892
+ it "shows the question only if the condition is fulfilled" do
893
+ expect_question_to_be_visible(false)
894
+
895
+ fill_in "questionnaire_responses_0", with: "Cacatua"
896
+ change_focus
897
+
898
+ expect_question_to_be_visible(true)
899
+
900
+ fill_in "questionnaire_responses_0", with: ""
901
+ change_focus
902
+
903
+ expect_question_to_be_visible(false)
904
+ end
905
+ end
906
+
907
+ context "when the condition_question type is single option" do
908
+ let!(:condition_question_type) { "single_option" }
909
+ let!(:condition_question_options) { answer_options }
910
+
911
+ it "shows the question only if the condition is fulfilled" do
912
+ expect_question_to_be_visible(false)
913
+
914
+ choose condition_question.answer_options.first.body["en"]
915
+
916
+ expect_question_to_be_visible(true)
917
+
918
+ choose condition_question.answer_options.second.body["en"]
919
+
920
+ expect_question_to_be_visible(false)
921
+ end
922
+ end
923
+
924
+ context "when the condition_question type is multiple option" do
925
+ let!(:condition_question_type) { "multiple_option" }
926
+ let!(:condition_question_options) { answer_options }
927
+
928
+ it "shows the question only if the condition is fulfilled" do
929
+ expect_question_to_be_visible(false)
930
+
931
+ check condition_question.answer_options.first.body["en"]
932
+
933
+ expect_question_to_be_visible(true)
934
+
935
+ uncheck condition_question.answer_options.first.body["en"]
936
+
937
+ expect_question_to_be_visible(false)
938
+
939
+ check condition_question.answer_options.second.body["en"]
940
+
941
+ expect_question_to_be_visible(false)
942
+
943
+ check condition_question.answer_options.first.body["en"]
944
+
945
+ expect_question_to_be_visible(true)
946
+ end
947
+ end
948
+ end
949
+
950
+ context "when a question has a display condition of type 'not_answered'" do
951
+ let!(:display_condition) do
952
+ create(:display_condition,
953
+ condition_type: "not_answered",
954
+ question: question,
955
+ condition_question: condition_question)
956
+ end
957
+
958
+ before do
959
+ visit questionnaire_public_path
960
+ end
961
+
962
+ context "when the condition_question type is short answer" do
963
+ let!(:condition_question_type) { "short_answer" }
964
+
965
+ it "shows the question only if the condition is fulfilled" do
966
+ expect_question_to_be_visible(true)
967
+
968
+ fill_in "questionnaire_responses_0", with: "Cacatua"
969
+ change_focus
970
+
971
+ expect_question_to_be_visible(false)
972
+
973
+ fill_in "questionnaire_responses_0", with: ""
974
+ change_focus
975
+
976
+ expect_question_to_be_visible(true)
977
+ end
978
+ end
979
+
980
+ context "when the condition_question type is long answer" do
981
+ let!(:condition_question_type) { "long_answer" }
982
+
983
+ it "shows the question only if the condition is fulfilled" do
984
+ expect_question_to_be_visible(true)
985
+
986
+ fill_in "questionnaire_responses_0", with: "Cacatua"
987
+ change_focus
988
+
989
+ expect_question_to_be_visible(false)
990
+
991
+ fill_in "questionnaire_responses_0", with: ""
992
+ change_focus
993
+
994
+ expect_question_to_be_visible(true)
995
+ end
996
+ end
997
+
998
+ context "when the condition_question type is single option" do
999
+ let!(:condition_question_type) { "single_option" }
1000
+ let!(:condition_question_options) { answer_options }
1001
+
1002
+ it "shows the question only if the condition is fulfilled" do
1003
+ expect_question_to_be_visible(true)
1004
+
1005
+ choose condition_question.answer_options.first.body["en"]
1006
+
1007
+ expect_question_to_be_visible(false)
1008
+ end
1009
+ end
1010
+
1011
+ context "when the condition_question type is multiple option" do
1012
+ let!(:condition_question_type) { "multiple_option" }
1013
+ let!(:condition_question_options) { answer_options }
1014
+
1015
+ it "shows the question only if the condition is fulfilled" do
1016
+ expect_question_to_be_visible(true)
1017
+
1018
+ check condition_question.answer_options.first.body["en"]
1019
+
1020
+ expect_question_to_be_visible(false)
1021
+
1022
+ uncheck condition_question.answer_options.first.body["en"]
1023
+
1024
+ expect_question_to_be_visible(true)
1025
+ end
1026
+ end
1027
+ end
1028
+
1029
+ context "when a question has a display condition of type 'equal'" do
1030
+ let!(:display_condition) do
1031
+ create(:display_condition,
1032
+ condition_type: "equal",
1033
+ question: question,
1034
+ condition_question: condition_question,
1035
+ answer_option: condition_question.answer_options.first)
1036
+ end
1037
+
1038
+ before do
1039
+ visit questionnaire_public_path
1040
+ end
1041
+
1042
+ context "when the condition_question type is single option" do
1043
+ let!(:condition_question_type) { "single_option" }
1044
+ let!(:condition_question_options) { answer_options }
1045
+
1046
+ it "shows the question only if the condition is fulfilled" do
1047
+ expect_question_to_be_visible(false)
1048
+
1049
+ choose condition_question.answer_options.first.body["en"]
1050
+
1051
+ expect_question_to_be_visible(true)
1052
+
1053
+ choose condition_question.answer_options.second.body["en"]
1054
+
1055
+ expect_question_to_be_visible(false)
1056
+ end
1057
+ end
1058
+
1059
+ context "when the condition_question type is multiple option" do
1060
+ let!(:condition_question_type) { "multiple_option" }
1061
+ let!(:condition_question_options) { answer_options }
1062
+
1063
+ it "shows the question only if the condition is fulfilled" do
1064
+ expect_question_to_be_visible(false)
1065
+
1066
+ check condition_question.answer_options.first.body["en"]
1067
+
1068
+ expect_question_to_be_visible(true)
1069
+
1070
+ uncheck condition_question.answer_options.first.body["en"]
1071
+
1072
+ expect_question_to_be_visible(false)
1073
+
1074
+ check condition_question.answer_options.second.body["en"]
1075
+
1076
+ expect_question_to_be_visible(false)
1077
+
1078
+ check condition_question.answer_options.first.body["en"]
1079
+
1080
+ expect_question_to_be_visible(true)
1081
+ end
1082
+ end
1083
+ end
1084
+
1085
+ context "when a question has a display condition of type 'not_equal'" do
1086
+ let!(:display_condition) do
1087
+ create(:display_condition,
1088
+ condition_type: "not_equal",
1089
+ question: question,
1090
+ condition_question: condition_question,
1091
+ answer_option: condition_question.answer_options.first)
1092
+ end
1093
+
1094
+ before do
1095
+ visit questionnaire_public_path
1096
+ end
1097
+
1098
+ context "when the condition_question type is single option" do
1099
+ let!(:condition_question_type) { "single_option" }
1100
+ let!(:condition_question_options) { answer_options }
1101
+
1102
+ it "shows the question only if the condition is fulfilled" do
1103
+ expect_question_to_be_visible(false)
1104
+
1105
+ choose condition_question.answer_options.second.body["en"]
1106
+
1107
+ expect_question_to_be_visible(true)
1108
+
1109
+ choose condition_question.answer_options.first.body["en"]
1110
+
1111
+ expect_question_to_be_visible(false)
1112
+ end
1113
+ end
1114
+
1115
+ context "when the condition_question type is multiple option" do
1116
+ let!(:condition_question_type) { "multiple_option" }
1117
+ let!(:condition_question_options) { answer_options }
1118
+
1119
+ it "shows the question only if the condition is fulfilled" do
1120
+ expect_question_to_be_visible(false)
1121
+
1122
+ check condition_question.answer_options.second.body["en"]
1123
+
1124
+ expect_question_to_be_visible(true)
1125
+
1126
+ uncheck condition_question.answer_options.second.body["en"]
1127
+
1128
+ expect_question_to_be_visible(false)
1129
+
1130
+ check condition_question.answer_options.first.body["en"]
1131
+
1132
+ expect_question_to_be_visible(false)
1133
+
1134
+ check condition_question.answer_options.second.body["en"]
1135
+
1136
+ expect_question_to_be_visible(true)
1137
+ end
1138
+ end
1139
+ end
1140
+
1141
+ context "when a question has a display condition of type 'match'" do
1142
+ let!(:condition_value) { { en: "something" } }
1143
+ let!(:display_condition) do
1144
+ create(:display_condition,
1145
+ condition_type: "match",
1146
+ question: question,
1147
+ condition_question: condition_question,
1148
+ condition_value: condition_value)
1149
+ end
1150
+
1151
+ before do
1152
+ visit questionnaire_public_path
1153
+ end
1154
+
1155
+ context "when the condition_question type is short answer" do
1156
+ let!(:condition_question_type) { "short_answer" }
1157
+
1158
+ it "shows the question only if the condition is fulfilled" do
1159
+ expect_question_to_be_visible(false)
1160
+
1161
+ fill_in "questionnaire_responses_0", with: "Aren't we all expecting #{condition_value[:en]}?"
1162
+ change_focus
1163
+
1164
+ expect_question_to_be_visible(true)
1165
+
1166
+ fill_in "questionnaire_responses_0", with: "Now upcase #{condition_value[:en].upcase}!"
1167
+ change_focus
1168
+
1169
+ expect_question_to_be_visible(true)
1170
+
1171
+ fill_in "questionnaire_responses_0", with: "Cacatua"
1172
+ change_focus
1173
+
1174
+ expect_question_to_be_visible(false)
1175
+ end
1176
+ end
1177
+
1178
+ context "when the condition_question type is long answer" do
1179
+ let!(:condition_question_type) { "long_answer" }
1180
+
1181
+ it "shows the question only if the condition is fulfilled" do
1182
+ expect_question_to_be_visible(false)
1183
+
1184
+ fill_in "questionnaire_responses_0", with: "Aren't we all expecting #{condition_value[:en]}?"
1185
+ change_focus
1186
+
1187
+ expect_question_to_be_visible(true)
1188
+
1189
+ fill_in "questionnaire_responses_0", with: "Now upcase #{condition_value[:en].upcase}!"
1190
+ change_focus
1191
+
1192
+ expect_question_to_be_visible(true)
1193
+
1194
+ fill_in "questionnaire_responses_0", with: "Cacatua"
1195
+ change_focus
1196
+
1197
+ expect_question_to_be_visible(false)
1198
+ end
1199
+ end
1200
+
1201
+ context "when the condition_question type is single option" do
1202
+ let!(:condition_question_type) { "single_option" }
1203
+ let!(:condition_question_options) { answer_options }
1204
+ let!(:condition_value) { { en: condition_question.answer_options.first.body["en"].split.second.upcase } }
1205
+
1206
+ it "shows the question only if the condition is fulfilled" do
1207
+ expect_question_to_be_visible(false)
1208
+
1209
+ choose condition_question.answer_options.first.body["en"]
1210
+
1211
+ expect_question_to_be_visible(true)
1212
+ end
1213
+ end
1214
+
1215
+ context "when the condition_question type is single option with free text" do
1216
+ let!(:condition_question_type) { "single_option" }
1217
+ let!(:condition_question_options) { answer_options }
1218
+ let!(:condition_value) { { en: "forty two" } }
1219
+
1220
+ it "shows the question only if the condition is fulfilled" do
1221
+ expect_question_to_be_visible(false)
1222
+
1223
+ choose condition_question.answer_options.third.body["en"]
1224
+ fill_in "questionnaire_responses_0_choices_2_custom_body", with: "The answer is #{condition_value[:en]}"
1225
+ change_focus
1226
+
1227
+ expect_question_to_be_visible(true)
1228
+
1229
+ choose condition_question.answer_options.first.body["en"]
1230
+ expect_question_to_be_visible(false)
1231
+
1232
+ choose condition_question.answer_options.third.body["en"]
1233
+ fill_in "questionnaire_responses_0_choices_2_custom_body", with: "oh no not 42 again"
1234
+ change_focus
1235
+
1236
+ expect_question_to_be_visible(false)
1237
+ end
1238
+ end
1239
+
1240
+ context "when the condition_question type is multiple option" do
1241
+ let!(:condition_question_type) { "multiple_option" }
1242
+ let!(:condition_question_options) { answer_options }
1243
+ let!(:condition_value) { { en: "forty two" } }
1244
+
1245
+ it "shows the question only if the condition is fulfilled" do
1246
+ expect_question_to_be_visible(false)
1247
+
1248
+ check condition_question.answer_options.third.body["en"]
1249
+ fill_in "questionnaire_responses_0_choices_2_custom_body", with: "The answer is #{condition_value[:en]}"
1250
+ change_focus
1251
+
1252
+ expect_question_to_be_visible(true)
1253
+
1254
+ check condition_question.answer_options.first.body["en"]
1255
+ expect_question_to_be_visible(true)
1256
+
1257
+ uncheck condition_question.answer_options.third.body["en"]
1258
+ expect_question_to_be_visible(false)
1259
+
1260
+ check condition_question.answer_options.third.body["en"]
1261
+ fill_in "questionnaire_responses_0_choices_2_custom_body", with: "oh no not 42 again"
1262
+ change_focus
1263
+
1264
+ expect_question_to_be_visible(false)
1265
+ end
1266
+ end
1267
+ end
1268
+ end
1269
+
1270
+ context "when a question has multiple display conditions" do
1271
+ before do
788
1272
  visit questionnaire_public_path
1273
+ end
789
1274
 
790
- checkboxes = page.all(".check-box-collection input[type=checkbox]")
791
- check checkboxes[0][:id]
1275
+ context "when all conditions are mandatory" do
1276
+ let!(:condition_question_type) { "single_option" }
1277
+ let!(:condition_question_options) { answer_options }
1278
+ let!(:display_conditions) do
1279
+ [
1280
+ create(:display_condition,
1281
+ condition_type: "answered",
1282
+ question: question,
1283
+ condition_question: condition_question,
1284
+ mandatory: true),
1285
+ create(:display_condition,
1286
+ condition_type: "not_equal",
1287
+ question: question,
1288
+ condition_question: condition_question,
1289
+ mandatory: true,
1290
+ answer_option: condition_question.answer_options.second)
1291
+ ]
1292
+ end
792
1293
 
793
- check "questionnaire_tos_agreement"
794
- accept_confirm { click_button "Submit" }
1294
+ it "is displayed only if all conditions are fulfilled" do
1295
+ expect_question_to_be_visible(false)
795
1296
 
796
- within ".alert.flash" do
797
- expect(page).to have_content("There was a problem answering")
1297
+ choose condition_question.answer_options.second.body["en"]
1298
+
1299
+ expect_question_to_be_visible(false)
1300
+
1301
+ choose condition_question.answer_options.first.body["en"]
1302
+
1303
+ expect_question_to_be_visible(true)
798
1304
  end
1305
+ end
799
1306
 
800
- expect(page).to have_content("Choices are not complete")
1307
+ context "when all conditions are non-mandatory" do
1308
+ let!(:condition_question_type) { "multiple_option" }
1309
+ let!(:condition_question_options) { answer_options }
1310
+ let!(:display_conditions) do
1311
+ [
1312
+ create(:display_condition,
1313
+ condition_type: "equal",
1314
+ question: question,
1315
+ condition_question: condition_question,
1316
+ mandatory: false,
1317
+ answer_option: condition_question.answer_options.first),
1318
+ create(:display_condition,
1319
+ condition_type: "not_equal",
1320
+ question: question,
1321
+ condition_question: condition_question,
1322
+ mandatory: false,
1323
+ answer_option: condition_question.answer_options.third)
1324
+ ]
1325
+ end
1326
+
1327
+ it "is displayed if any of the conditions is fulfilled" do
1328
+ expect_question_to_be_visible(false)
1329
+
1330
+ check condition_question.answer_options.first.body["en"]
1331
+
1332
+ expect_question_to_be_visible(true)
1333
+
1334
+ uncheck condition_question.answer_options.first.body["en"]
1335
+ check condition_question.answer_options.second.body["en"]
1336
+
1337
+ expect_question_to_be_visible(true)
1338
+
1339
+ check condition_question.answer_options.first.body["en"]
1340
+
1341
+ expect_question_to_be_visible(true)
1342
+ end
1343
+ end
1344
+
1345
+ context "when a mandatory question has conditions that have not been fulfilled" do
1346
+ let!(:condition_question_type) { "short_answer" }
1347
+ let!(:question) { create(:questionnaire_question, questionnaire: questionnaire, position: 2, mandatory: true) }
1348
+ let!(:display_conditions) do
1349
+ [
1350
+ create(:display_condition,
1351
+ condition_type: "match",
1352
+ question: question,
1353
+ condition_question: condition_question,
1354
+ condition_value: { en: "hey", es: "ey", ca: "ei" },
1355
+ mandatory: true)
1356
+ ]
1357
+ end
1358
+
1359
+ it "doesn't throw error" do
1360
+ visit questionnaire_public_path
1361
+
1362
+ fill_in condition_question.body["en"], with: "My first answer"
1363
+
1364
+ check "questionnaire_tos_agreement"
1365
+
1366
+ accept_confirm { click_button "Submit" }
1367
+
1368
+ within ".success.flash" do
1369
+ expect(page).to have_content("successfully")
1370
+ end
1371
+ end
801
1372
  end
802
1373
  end
803
1374
  end
1375
+
1376
+ private
1377
+
1378
+ def expect_question_to_be_visible(visible)
1379
+ expect(page).to have_css(conditioned_question_id, visible: visible)
1380
+ end
1381
+
1382
+ def change_focus
1383
+ check "questionnaire_tos_agreement"
1384
+ end
804
1385
  end
805
1386
  end