decidim-forms 0.30.2 → 0.31.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 (158) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -10
  3. data/app/cells/decidim/forms/matrix_readonly/show.erb +1 -1
  4. data/app/cells/decidim/forms/matrix_readonly_cell.rb +3 -3
  5. data/app/cells/decidim/forms/question_readonly/show.erb +5 -5
  6. data/app/cells/decidim/forms/question_readonly/title_and_description.erb +3 -3
  7. data/app/cells/decidim/forms/response_readonly_cell.rb +9 -0
  8. data/app/cells/decidim/forms/step_navigation/show.erb +3 -3
  9. data/app/cells/decidim/forms/step_navigation_cell.rb +3 -3
  10. data/app/commands/decidim/forms/admin/update_questions.rb +6 -6
  11. data/app/commands/decidim/forms/{answer_questionnaire.rb → response_questionnaire.rb} +35 -35
  12. data/app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb +12 -12
  13. data/app/controllers/decidim/forms/admin/concerns/{has_questionnaire_answers.rb → has_questionnaire_responses.rb} +23 -19
  14. data/app/controllers/decidim/forms/concerns/has_questionnaire.rb +38 -33
  15. data/app/forms/decidim/forms/admin/display_condition_form.rb +14 -14
  16. data/app/forms/decidim/forms/admin/question_form.rb +3 -3
  17. data/app/forms/decidim/forms/admin/{answer_option_form.rb → response_option_form.rb} +3 -3
  18. data/app/forms/decidim/forms/questionnaire_form.rb +8 -9
  19. data/app/forms/decidim/forms/{answer_choice_form.rb → response_choice_form.rb} +5 -5
  20. data/app/forms/decidim/forms/{answer_form.rb → response_form.rb} +9 -9
  21. data/app/helpers/decidim/forms/admin/application_helper.rb +2 -2
  22. data/app/helpers/decidim/forms/admin/concerns/{has_questionnaire_answers_pagination_helper.rb → has_questionnaire_responses_pagination_helper.rb} +4 -4
  23. data/app/helpers/decidim/forms/admin/concerns/{has_questionnaire_answers_url_helper.rb → has_questionnaire_responses_url_helper.rb} +5 -5
  24. data/app/helpers/decidim/forms/admin/questionnaire_responses_helper.rb +32 -0
  25. data/app/helpers/decidim/forms/application_helper.rb +1 -2
  26. data/app/jobs/decidim/forms/{export_questionnaire_answers_job.rb → export_questionnaire_responses_job.rb} +5 -5
  27. data/app/models/decidim/forms/display_condition.rb +20 -20
  28. data/app/models/decidim/forms/question.rb +14 -13
  29. data/app/models/decidim/forms/question_matrix_row.rb +1 -1
  30. data/app/models/decidim/forms/questionnaire.rb +11 -6
  31. data/app/models/decidim/forms/{answer.rb → response.rb} +9 -9
  32. data/app/models/decidim/forms/response_choice.rb +22 -0
  33. data/app/models/decidim/forms/{answer_option.rb → response_option.rb} +5 -5
  34. data/app/packs/entrypoints/decidim_forms_admin.js +3 -3
  35. data/app/packs/src/decidim/forms/admin/collapsible_questions.js +12 -10
  36. data/app/packs/src/decidim/forms/admin/forms.js +35 -35
  37. data/app/packs/src/decidim/forms/admin/{publish_answers_buttons.js → publish_responses_buttons.js} +12 -12
  38. data/app/packs/src/decidim/forms/display_conditions.component.js +12 -12
  39. data/app/packs/src/decidim/forms/forms.js +4 -4
  40. data/app/packs/stylesheets/decidim/forms/forms.scss +2 -2
  41. data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +13 -13
  42. data/app/presenters/decidim/forms/admin/{questionnaire_answer_presenter.rb → questionnaire_response_presenter.rb} +15 -15
  43. data/app/presenters/decidim/forms/admin_log/question_presenter.rb +3 -3
  44. data/app/presenters/decidim/forms/{answer_option_presenter.rb → response_option_presenter.rb} +2 -2
  45. data/app/queries/decidim/forms/questionnaire_participant.rb +5 -5
  46. data/app/queries/decidim/forms/questionnaire_participants.rb +6 -6
  47. data/app/queries/decidim/forms/questionnaire_user_responses.rb +32 -0
  48. data/app/views/decidim/forms/admin/questionnaires/_display_condition.html.erb +9 -9
  49. data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +2 -2
  50. data/app/views/decidim/forms/admin/questionnaires/_matrix_row.html.erb +3 -3
  51. data/app/views/decidim/forms/admin/questionnaires/_question.html.erb +16 -16
  52. data/app/views/decidim/forms/admin/questionnaires/_questions_form.html.erb +11 -10
  53. data/app/views/decidim/forms/admin/questionnaires/{_answer_option.html.erb → _response_option.html.erb} +7 -7
  54. data/app/views/decidim/forms/admin/questionnaires/_response_option_template.html.erb +7 -0
  55. data/app/views/decidim/forms/admin/questionnaires/_separator.html.erb +10 -7
  56. data/app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb +7 -7
  57. data/app/views/decidim/forms/admin/questionnaires/edit.html.erb +1 -1
  58. data/app/views/decidim/forms/admin/questionnaires/edit_questions.html.erb +8 -8
  59. data/app/views/decidim/forms/admin/questionnaires/responses/index.html.erb +80 -0
  60. data/app/views/decidim/forms/admin/questionnaires/responses/show.html.erb +43 -0
  61. data/app/views/decidim/forms/questionnaires/_questionnaire.html.erb +22 -26
  62. data/app/views/decidim/forms/questionnaires/_questionnaire_readonly.html.erb +8 -3
  63. data/app/views/decidim/forms/questionnaires/_response.html.erb +61 -0
  64. data/app/views/decidim/forms/questionnaires/edit.html.erb +2 -2
  65. data/app/views/decidim/forms/questionnaires/responses/_files.html.erb +1 -0
  66. data/app/views/decidim/forms/questionnaires/responses/_long_response.html.erb +3 -0
  67. data/app/views/decidim/forms/questionnaires/{answers → responses}/_matrix_multiple.html.erb +16 -15
  68. data/app/views/decidim/forms/questionnaires/{answers → responses}/_matrix_single.html.erb +17 -16
  69. data/app/views/decidim/forms/questionnaires/responses/_multiple_option.html.erb +26 -0
  70. data/app/views/decidim/forms/questionnaires/responses/_separator.html.erb +1 -0
  71. data/app/views/decidim/forms/questionnaires/responses/_short_response.html.erb +3 -0
  72. data/app/views/decidim/forms/questionnaires/responses/_single_option.html.erb +33 -0
  73. data/app/views/decidim/forms/questionnaires/responses/_sorting.html.erb +26 -0
  74. data/app/views/decidim/forms/questionnaires/responses/_title_and_description.html.erb +1 -0
  75. data/app/views/decidim/forms/questionnaires/show.html.erb +10 -10
  76. data/config/assets.rb +2 -2
  77. data/config/locales/ar.yml +0 -22
  78. data/config/locales/bg.yml +3 -36
  79. data/config/locales/ca-IT.yml +73 -73
  80. data/config/locales/ca.yml +73 -73
  81. data/config/locales/cs.yml +72 -75
  82. data/config/locales/de.yml +72 -72
  83. data/config/locales/el.yml +3 -36
  84. data/config/locales/en.yml +83 -83
  85. data/config/locales/es-MX.yml +75 -75
  86. data/config/locales/es-PY.yml +75 -75
  87. data/config/locales/es.yml +73 -73
  88. data/config/locales/eu.yml +71 -71
  89. data/config/locales/fi-plain.yml +71 -71
  90. data/config/locales/fi.yml +69 -69
  91. data/config/locales/fr-CA.yml +70 -67
  92. data/config/locales/fr.yml +70 -67
  93. data/config/locales/ga-IE.yml +0 -7
  94. data/config/locales/gl.yml +0 -22
  95. data/config/locales/hu.yml +0 -22
  96. data/config/locales/id-ID.yml +0 -22
  97. data/config/locales/it.yml +3 -40
  98. data/config/locales/ja.yml +80 -80
  99. data/config/locales/lb.yml +3 -36
  100. data/config/locales/lt.yml +3 -36
  101. data/config/locales/lv.yml +0 -22
  102. data/config/locales/nl.yml +3 -36
  103. data/config/locales/no.yml +3 -36
  104. data/config/locales/pl.yml +3 -36
  105. data/config/locales/pt-BR.yml +3 -36
  106. data/config/locales/pt.yml +3 -36
  107. data/config/locales/ro-RO.yml +22 -51
  108. data/config/locales/ru.yml +0 -9
  109. data/config/locales/sk.yml +0 -22
  110. data/config/locales/sl.yml +0 -5
  111. data/config/locales/sv.yml +82 -54
  112. data/config/locales/tr-TR.yml +3 -36
  113. data/config/locales/zh-CN.yml +3 -36
  114. data/config/locales/zh-TW.yml +3 -36
  115. data/db/migrate/20190315203056_add_session_token_to_decidim_forms_answers.rb +1 -1
  116. data/db/migrate/20250314150250_rename_answer_to_response_in_decidim_forms.rb +30 -0
  117. data/db/migrate/20250319130003_change_question_types_in_questions.rb +14 -0
  118. data/lib/decidim/api/question_matrix_row_type.rb +13 -0
  119. data/lib/decidim/api/question_type.rb +4 -3
  120. data/lib/decidim/api/questionnaire_type.rb +1 -0
  121. data/lib/decidim/api/response_option_type.rb +13 -0
  122. data/lib/decidim/exporters/form_pdf.rb +33 -33
  123. data/lib/decidim/forms/api.rb +2 -1
  124. data/lib/decidim/forms/{download_your_data_user_answers_serializer.rb → download_your_data_user_responses_serializer.rb} +3 -3
  125. data/lib/decidim/forms/engine.rb +2 -2
  126. data/lib/decidim/forms/test/factories.rb +24 -24
  127. data/lib/decidim/forms/test/shared_examples/has_questionnaire.rb +176 -176
  128. data/lib/decidim/forms/test/shared_examples/manage_questionnaire_responses.rb +159 -0
  129. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_display_conditions.rb +19 -19
  130. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +44 -44
  131. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb +10 -10
  132. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +18 -18
  133. data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +4 -4
  134. data/lib/decidim/forms/test.rb +1 -1
  135. data/lib/decidim/forms/user_responses_serializer.rb +110 -0
  136. data/lib/decidim/forms/version.rb +1 -1
  137. data/lib/decidim/forms.rb +2 -2
  138. metadata +48 -45
  139. data/app/cells/decidim/forms/answer_readonly_cell.rb +0 -9
  140. data/app/helpers/decidim/forms/admin/questionnaire_answers_helper.rb +0 -30
  141. data/app/models/decidim/forms/answer_choice.rb +0 -22
  142. data/app/queries/decidim/forms/questionnaire_user_answers.rb +0 -32
  143. data/app/views/decidim/forms/admin/questionnaires/_answer_option_template.html.erb +0 -7
  144. data/app/views/decidim/forms/admin/questionnaires/answers/index.html.erb +0 -49
  145. data/app/views/decidim/forms/admin/questionnaires/answers/show.html.erb +0 -43
  146. data/app/views/decidim/forms/questionnaires/_answer.html.erb +0 -61
  147. data/app/views/decidim/forms/questionnaires/answers/_files.html.erb +0 -1
  148. data/app/views/decidim/forms/questionnaires/answers/_long_answer.html.erb +0 -3
  149. data/app/views/decidim/forms/questionnaires/answers/_multiple_option.html.erb +0 -25
  150. data/app/views/decidim/forms/questionnaires/answers/_separator.html.erb +0 -1
  151. data/app/views/decidim/forms/questionnaires/answers/_short_answer.html.erb +0 -3
  152. data/app/views/decidim/forms/questionnaires/answers/_single_option.html.erb +0 -32
  153. data/app/views/decidim/forms/questionnaires/answers/_sorting.html.erb +0 -26
  154. data/app/views/decidim/forms/questionnaires/answers/_title_and_description.html.erb +0 -1
  155. data/lib/decidim/api/answer_option_type.rb +0 -13
  156. data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +0 -149
  157. data/lib/decidim/forms/user_answers_serializer.rb +0 -105
  158. /data/app/cells/decidim/forms/{answer_readonly → response_readonly}/show.erb +0 -0
@@ -0,0 +1,159 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ shared_examples_for "manage questionnaire responses" do
6
+ let(:first_type) { "short_response" }
7
+ let!(:first) do
8
+ create(:questionnaire_question, questionnaire:, position: 1, question_type: first_type)
9
+ end
10
+ let!(:second) do
11
+ create(:questionnaire_question, questionnaire:, position: 2, question_type: "single_option")
12
+ end
13
+ let!(:third) do
14
+ create(:questionnaire_question, questionnaire:, position: 3, question_type: "files")
15
+ end
16
+ let(:questions) do
17
+ [first, second, third]
18
+ end
19
+
20
+ context "when there are responses" do
21
+ let!(:response1) { create(:response, questionnaire:, question: first) }
22
+ let!(:response2) { create(:response, body: "second response", questionnaire:, question: first) }
23
+ let!(:response3) { create(:response, questionnaire:, question: second) }
24
+ let!(:file_response) { create(:response, :with_attachments, questionnaire:, question: third, body: nil, user: response3.user, session_token: response3.session_token) }
25
+
26
+ it "shows the response admin link" do
27
+ within "tr", text: decidim_sanitize_translated(survey.title) do
28
+ find("button[data-controller='dropdown']").click
29
+ click_on "Questions"
30
+ end
31
+ expect(page).to have_content("Responses")
32
+ end
33
+
34
+ context "and managing responses page" do
35
+ before do
36
+ within "tr", text: decidim_sanitize_translated(survey.title) do
37
+ find("button[data-controller='dropdown']").click
38
+ click_on "Questions"
39
+ end
40
+ click_on "Responses"
41
+ end
42
+
43
+ it "shows the responses page" do
44
+ expect(page).to have_content(response1.body)
45
+ expect(page).to have_content(response1.question.body["en"])
46
+ expect(page).to have_content(response2.body)
47
+ expect(page).to have_content(response2.question.body["en"])
48
+ end
49
+
50
+ it "shows the percentage" do
51
+ expect(page).to have_content("33%")
52
+ end
53
+
54
+ it "has a detail link" do
55
+ within "tr", text: decidim_sanitize_translated(response1.body) do
56
+ find("button[data-controller='dropdown']").click
57
+ expect(page).to have_link("Show responses")
58
+ end
59
+ end
60
+
61
+ it "has an export link" do
62
+ expect(page).to have_link(response1.body)
63
+ expect(page).to have_link(response2.body)
64
+ within "tr", text: decidim_sanitize_translated(response1.body) do
65
+ find("button[data-controller='dropdown']").click
66
+ expect(page).to have_link("Export")
67
+ end
68
+ end
69
+
70
+ context "when no short response exist" do
71
+ let(:first_type) { "long_response" }
72
+
73
+ it "shows session token" do
74
+ expect(page).to have_no_content(response1.body)
75
+ expect(page).to have_content(response1.session_token)
76
+ expect(page).to have_content(response2.session_token)
77
+ expect(page).to have_content(response3.session_token)
78
+ expect(page).to have_content("User identifier")
79
+ end
80
+ end
81
+
82
+ context "when multiple response choice" do
83
+ let(:first_type) { "multiple_option" }
84
+ let!(:response1) { create(:response, questionnaire:, question: first, body: nil) }
85
+ let!(:response_option) { create(:response_option, question: first) }
86
+ let!(:response_choice) { create(:response_choice, response: response1, response_option:, body: translated(response_option.body, locale: I18n.locale)) }
87
+
88
+ it "shows the responses page with custom body" do
89
+ within "tr", text: decidim_sanitize_translated(response1.session_token) do
90
+ find("button[data-controller='dropdown']").click
91
+ new_window = window_opened_by { click_on "Show responses" }
92
+ page.within_window(new_window) do
93
+ within "#responses" do
94
+ expect(page).to have_css("dt", text: translated(first.body))
95
+ expect(page).to have_css("li", text: translated(response_option.body))
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ context "and managing individual response page" do
104
+ let!(:response11) { create(:response, questionnaire:, body: "", user: response1.user, question: second) }
105
+
106
+ before do
107
+ within "tr", text: decidim_sanitize_translated(survey.title) do
108
+ find("button[data-controller='dropdown']").click
109
+ click_on "Questions"
110
+ end
111
+ click_on "Responses"
112
+ end
113
+
114
+ it "shows all the questions and responses" do
115
+ click_on response1.body, match: :first
116
+ expect(page).to have_content(first.body["en"])
117
+ expect(page).to have_content(second.body["en"])
118
+ expect(page).to have_content(response1.body)
119
+ end
120
+
121
+ it "first response has a next link" do
122
+ click_on response1.body, match: :first
123
+ expect(page).to have_link("Next ›")
124
+ expect(page).to have_no_link("‹ Prev")
125
+ end
126
+
127
+ it "second response has prev/next links" do
128
+ click_on response2.body, match: :first
129
+ expect(page).to have_link("Next ›")
130
+ expect(page).to have_link("‹ Prev")
131
+ end
132
+
133
+ it "third response has prev link" do
134
+ click_on response3.session_token, match: :first
135
+ expect(page).to have_no_link("Next ›")
136
+ expect(page).to have_link("‹ Prev")
137
+ end
138
+
139
+ it "third response has download link for the attachments" do
140
+ click_on response3.session_token, match: :first
141
+ expect(page).to have_content(translated(file_response.attachments.first.title))
142
+ expect(page).to have_content(translated(file_response.attachments.second.title))
143
+ end
144
+
145
+ context "when the file response does not have a title for the attachment" do
146
+ let!(:file_response) { create(:response, questionnaire:, question: third, body: nil, user: response3.user, session_token: response3.session_token) }
147
+
148
+ before do
149
+ create(:attachment, :with_image, attached_to: file_response, title: {}, description: {})
150
+ end
151
+
152
+ it "third response has download link for the attachments" do
153
+ click_on response3.session_token, match: :first
154
+ expect(page).to have_content("Download attachment")
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
@@ -4,7 +4,7 @@ require "spec_helper"
4
4
 
5
5
  shared_examples_for "add display conditions" do
6
6
  context "when adding display conditions to a question" do
7
- let!(:answer_options) do
7
+ let!(:response_options) do
8
8
  3.times.to_a.map do |x|
9
9
  {
10
10
  "body" => Decidim::Faker::Localized.sentence,
@@ -14,7 +14,7 @@ shared_examples_for "add display conditions" do
14
14
  end
15
15
 
16
16
  context "when questionnaire has only one question" do
17
- let!(:question) { create(:questionnaire_question, questionnaire:, body:, question_type: "short_answer") }
17
+ let!(:question) { create(:questionnaire_question, questionnaire:, body:, question_type: "short_response") }
18
18
 
19
19
  before do
20
20
  click_on "Save"
@@ -36,19 +36,19 @@ shared_examples_for "add display conditions" do
36
36
  end
37
37
 
38
38
  context "when questionnaire has more than one question" do
39
- let!(:question_short_answer) do
39
+ let!(:question_short_response) do
40
40
  create(:questionnaire_question,
41
41
  position: 0,
42
42
  questionnaire:,
43
43
  body: Decidim::Faker::Localized.sentence,
44
- question_type: "short_answer")
44
+ question_type: "short_response")
45
45
  end
46
- let!(:question_long_answer) do
46
+ let!(:question_long_response) do
47
47
  create(:questionnaire_question,
48
48
  position: 1,
49
49
  questionnaire:,
50
50
  body: Decidim::Faker::Localized.sentence,
51
- question_type: "long_answer")
51
+ question_type: "long_response")
52
52
  end
53
53
  let!(:question_single_option) do
54
54
  create(:questionnaire_question,
@@ -56,7 +56,7 @@ shared_examples_for "add display conditions" do
56
56
  questionnaire:,
57
57
  body: Decidim::Faker::Localized.sentence,
58
58
  question_type: "single_option",
59
- options: answer_options)
59
+ options: response_options)
60
60
  end
61
61
  let!(:question_multiple_option) do
62
62
  create(:questionnaire_question,
@@ -64,10 +64,10 @@ shared_examples_for "add display conditions" do
64
64
  questionnaire:,
65
65
  body: Decidim::Faker::Localized.sentence,
66
66
  question_type: "multiple_option",
67
- options: answer_options)
67
+ options: response_options)
68
68
  end
69
69
 
70
- let(:questions) { [question_short_answer, question_long_answer, question_single_option, question_multiple_option] }
70
+ let(:questions) { [question_short_response, question_long_response, question_single_option, question_multiple_option] }
71
71
 
72
72
  before do
73
73
  click_on "Save"
@@ -82,15 +82,15 @@ shared_examples_for "add display conditions" do
82
82
  expect(page).to have_css("[id$=mandatory]")
83
83
 
84
84
  select question_single_option.body["en"], from: "Question"
85
- select "Answered", from: "Condition"
85
+ select "Responded", from: "Condition"
86
86
 
87
- expect(page).to have_no_select("Answer option")
87
+ expect(page).to have_no_select("Response option")
88
88
  expect(page).to have_no_css("[id$=condition_value_en]", visible: :visible)
89
89
 
90
90
  select question_single_option.body["en"], from: "Question"
91
91
  select "Equal", from: "Condition"
92
92
 
93
- expect(page).to have_select("Answer option")
93
+ expect(page).to have_select("Response option")
94
94
  expect(page).to have_no_css("[id$=condition_value_en]", visible: :visible)
95
95
  end
96
96
  end
@@ -112,9 +112,9 @@ shared_examples_for "add display conditions" do
112
112
  context "when a text question is selected" do
113
113
  it "fills condition_type select with correct options" do
114
114
  within_add_display_condition do
115
- select question_short_answer.body["en"], from: "Question"
115
+ select question_short_response.body["en"], from: "Question"
116
116
 
117
- options = ["Select a condition type", "Answered", "Not answered", "Includes text"]
117
+ options = ["Select a condition type", "Responded", "Not responded", "Includes text"]
118
118
 
119
119
  option_elements = page.all("select[id$=condition_type] option")
120
120
  option_elements = option_elements.to_a.reject { |option| option[:style].match? "display: none" }
@@ -129,7 +129,7 @@ shared_examples_for "add display conditions" do
129
129
  within_add_display_condition do
130
130
  select question_single_option.body["en"], from: "Question"
131
131
 
132
- options = ["Select a condition type", "Answered", "Not answered", "Equal", "Not equal", "Includes text"]
132
+ options = ["Select a condition type", "Responded", "Not responded", "Equal", "Not equal", "Includes text"]
133
133
 
134
134
  option_elements = page.all("select[id$=condition_type] option")
135
135
  option_elements = option_elements.to_a.reject { |option| option[:style].match? "display: none" }
@@ -139,15 +139,15 @@ shared_examples_for "add display conditions" do
139
139
  end
140
140
  end
141
141
 
142
- it "fills answer_options select with correct options" do
142
+ it "fills response_options select with correct options" do
143
143
  within_add_display_condition do
144
144
  select question_single_option.body["en"], from: "Question"
145
145
  select "Equal", from: "Condition"
146
146
 
147
- options = answer_options.map { |option| option["body"]["en"] }
148
- options << "Select answer option"
147
+ options = response_options.map { |option| option["body"]["en"] }
148
+ options << "Select response option"
149
149
 
150
- expect(page).to have_select("Answer option", options:, wait: 5)
150
+ expect(page).to have_select("Response option", options:, wait: 5)
151
151
  end
152
152
  end
153
153
 
@@ -10,16 +10,16 @@ shared_examples_for "add questions" do
10
10
  select "Multiple option", from: "Type"
11
11
  expect(page).to have_select("Maximum number of choices", options: %w(Any 2))
12
12
 
13
- click_on "Add answer option"
13
+ click_on "Add response option"
14
14
  expect(page).to have_select("Maximum number of choices", options: %w(Any 2 3))
15
15
 
16
- click_on "Add answer option"
16
+ click_on "Add response option"
17
17
  expect(page).to have_select("Maximum number of choices", options: %w(Any 2 3 4))
18
18
 
19
- within(".questionnaire-question-answer-option:last-of-type") { click_on "Remove" }
19
+ within(".questionnaire-question-response-option:last-of-type") { click_on "Remove" }
20
20
  expect(page).to have_select("Maximum number of choices", options: %w(Any 2 3))
21
21
 
22
- within(".questionnaire-question-answer-option:last-of-type") { click_on "Remove" }
22
+ within(".questionnaire-question-response-option:last-of-type") { click_on "Remove" }
23
23
  expect(page).to have_select("Maximum number of choices", options: %w(Any 2))
24
24
 
25
25
  click_on "Add question"
@@ -108,9 +108,9 @@ shared_examples_for "add questions" do
108
108
  expect(page).to have_css("strong", text: "Superkalifragilistic description")
109
109
  end
110
110
 
111
- it "adds a question with answer options" do
111
+ it "adds a question with response options" do
112
112
  question_body = ["This is the first question", "This is the second question"]
113
- answer_options_body = [
113
+ response_options_body = [
114
114
  [
115
115
  "This is the Q1 first option",
116
116
  "This is the Q1 second option",
@@ -133,19 +133,19 @@ shared_examples_for "add questions" do
133
133
  end
134
134
  end
135
135
 
136
- expect(page).to have_no_content "Add answer option"
136
+ expect(page).to have_no_content "Add response option"
137
137
 
138
138
  page.all(".questionnaire-question").each do |question|
139
139
  within question do
140
140
  select "Single option", from: "Type"
141
- click_on "Add answer option"
141
+ click_on "Add response option"
142
142
  end
143
143
  end
144
144
 
145
145
  page.all(".questionnaire-question").each_with_index do |question, question_idx|
146
- question.all(".questionnaire-question-answer-option").each_with_index do |question_answer_option, answer_option_idx|
147
- within question_answer_option do
148
- fill_in find_nested_form_field_locator("body_en"), with: answer_options_body[question_idx][answer_option_idx]
146
+ question.all(".questionnaire-question-response-option").each_with_index do |question_response_option, response_option_idx|
147
+ within question_response_option do
148
+ fill_in find_nested_form_field_locator("body_en"), with: response_options_body[question_idx][response_option_idx]
149
149
  end
150
150
  end
151
151
  end
@@ -170,57 +170,57 @@ shared_examples_for "add questions" do
170
170
  click_on "Add question"
171
171
  expand_all_questions
172
172
 
173
- select "Long answer", from: "Type"
174
- expect(page).to have_no_css(".questionnaire-question-answer-option")
173
+ select "Long response", from: "Type"
174
+ expect(page).to have_no_css(".questionnaire-question-response-option")
175
175
  expect(page).to have_no_css(".questionnaire-question-matrix-row")
176
176
 
177
177
  select "Single option", from: "Type"
178
- expect(page).to have_css(".questionnaire-question-answer-option", count: 2)
178
+ expect(page).to have_css(".questionnaire-question-response-option", count: 2)
179
179
  expect(page).to have_no_css(".questionnaire-question-matrix-row")
180
180
 
181
181
  select "Multiple option", from: "Type"
182
- expect(page).to have_css(".questionnaire-question-answer-option", count: 2)
182
+ expect(page).to have_css(".questionnaire-question-response-option", count: 2)
183
183
  expect(page).to have_no_css(".questionnaire-question-matrix-row")
184
184
 
185
185
  select "Matrix (Multiple option)", from: "Type"
186
- expect(page).to have_css(".questionnaire-question-answer-option", count: 2)
186
+ expect(page).to have_css(".questionnaire-question-response-option", count: 2)
187
187
  expect(page).to have_css(".questionnaire-question-matrix-row", count: 2)
188
188
 
189
- select "Short answer", from: "Type"
190
- expect(page).to have_no_css(".questionnaire-question-answer-option")
189
+ select "Short response", from: "Type"
190
+ expect(page).to have_no_css(".questionnaire-question-response-option")
191
191
  expect(page).to have_no_css(".questionnaire-question-matrix-row")
192
192
 
193
193
  select "Matrix (Single option)", from: "Type"
194
- expect(page).to have_css(".questionnaire-question-answer-option", count: 2)
194
+ expect(page).to have_css(".questionnaire-question-response-option", count: 2)
195
195
  expect(page).to have_css(".questionnaire-question-matrix-row", count: 2)
196
196
  end
197
197
 
198
- it "does not incorrectly reorder when clicking answer options" do
198
+ it "does not incorrectly reorder when clicking response options" do
199
199
  click_on "Add question"
200
200
  expand_all_questions
201
201
 
202
202
  select "Single option", from: "Type"
203
- 2.times { click_on "Add answer option" }
203
+ 2.times { click_on "Add response option" }
204
204
 
205
- within ".questionnaire-question-answer-option:first-of-type" do
205
+ within ".questionnaire-question-response-option:first-of-type" do
206
206
  fill_in find_nested_form_field_locator("body_en"), with: "Something"
207
207
  end
208
208
 
209
- within ".questionnaire-question-answer-option:last-of-type" do
209
+ within ".questionnaire-question-response-option:last-of-type" do
210
210
  fill_in find_nested_form_field_locator("body_en"), with: "Else"
211
211
  end
212
212
 
213
213
  # If JS events for option reordering are incorrectly bound, clicking on
214
214
  # the field to gain focus can cause the options to get inverted... :S
215
- within ".questionnaire-question-answer-option:first-of-type" do
215
+ within ".questionnaire-question-response-option:first-of-type" do
216
216
  find_nested_form_field("body_en").click
217
217
  end
218
218
 
219
- within ".questionnaire-question-answer-option:first-of-type" do
219
+ within ".questionnaire-question-response-option:first-of-type" do
220
220
  expect(page).to have_nested_field("body_en", with: "Something")
221
221
  end
222
222
 
223
- within ".questionnaire-question-answer-option:last-of-type" do
223
+ within ".questionnaire-question-response-option:last-of-type" do
224
224
  expect(page).to have_nested_field("body_en", with: "Else")
225
225
  end
226
226
  end
@@ -260,24 +260,24 @@ shared_examples_for "add questions" do
260
260
  expand_all_questions
261
261
 
262
262
  expect(page).to have_text("Type")
263
- select "Long answer", from: "Type"
263
+ select "Long response", from: "Type"
264
264
  click_on "Save"
265
265
 
266
266
  expand_all_questions
267
- expect(page).to have_select("Type", selected: "Long answer", wait: 10)
267
+ expect(page).to have_select("Type", selected: "Long response", wait: 10)
268
268
  end
269
269
 
270
- it "does not preserve spurious answer options from previous type selections" do
270
+ it "does not preserve spurious response options from previous type selections" do
271
271
  click_on "Add question"
272
272
  expand_all_questions
273
273
 
274
274
  select "Single option", from: "Type"
275
275
 
276
- within ".questionnaire-question-answer-option:first-of-type" do
276
+ within ".questionnaire-question-response-option:first-of-type" do
277
277
  fill_in find_nested_form_field_locator("body_en"), with: "Something"
278
278
  end
279
279
 
280
- select "Long answer", from: "Type"
280
+ select "Long response", from: "Type"
281
281
 
282
282
  click_on "Save"
283
283
  expand_all_questions
@@ -285,7 +285,7 @@ shared_examples_for "add questions" do
285
285
  expect(page).to have_text("Type")
286
286
  select "Single option", from: "Type"
287
287
 
288
- within ".questionnaire-question-answer-option:first-of-type" do
288
+ within ".questionnaire-question-response-option:first-of-type" do
289
289
  expect(page).to have_no_nested_field("body_en", with: "Something")
290
290
  end
291
291
  end
@@ -300,7 +300,7 @@ shared_examples_for "add questions" do
300
300
  fill_in find_nested_form_field_locator("body_en"), with: "Something"
301
301
  end
302
302
 
303
- select "Long answer", from: "Type"
303
+ select "Long response", from: "Type"
304
304
 
305
305
  click_on "Save"
306
306
  expand_all_questions
@@ -313,19 +313,19 @@ shared_examples_for "add questions" do
313
313
  end
314
314
  end
315
315
 
316
- it "preserves answer options form across submission failures" do
316
+ it "preserves response options form across submission failures" do
317
317
  click_on "Add question"
318
318
  expand_all_questions
319
319
 
320
320
  select "Multiple option", from: "Type"
321
321
 
322
- within ".questionnaire-question-answer-option:first-of-type" do
322
+ within ".questionnaire-question-response-option:first-of-type" do
323
323
  fill_in find_nested_form_field_locator("body_en"), with: "Something"
324
324
  end
325
325
 
326
- click_on "Add answer option"
326
+ click_on "Add response option"
327
327
 
328
- within ".questionnaire-question-answer-option:last-of-type" do
328
+ within ".questionnaire-question-response-option:last-of-type" do
329
329
  fill_in find_nested_form_field_locator("body_en"), with: "Else"
330
330
  end
331
331
 
@@ -334,12 +334,12 @@ shared_examples_for "add questions" do
334
334
  click_on "Save"
335
335
  expand_all_questions
336
336
 
337
- expect(page).to have_css(".questionnaire-question-answer-option")
338
- within ".questionnaire-question-answer-option:first-of-type" do
337
+ expect(page).to have_css(".questionnaire-question-response-option")
338
+ within ".questionnaire-question-response-option:first-of-type" do
339
339
  expect(page).to have_nested_field("body_en", with: "Something")
340
340
  end
341
341
 
342
- within ".questionnaire-question-answer-option:last-of-type" do
342
+ within ".questionnaire-question-response-option:last-of-type" do
343
343
  fill_in find_nested_form_field_locator("body_en"), with: "Else"
344
344
  end
345
345
 
@@ -397,7 +397,7 @@ shared_examples_for "add questions" do
397
397
  fill_in find_nested_form_field_locator("body_en"), with: "This is the first question"
398
398
  end
399
399
 
400
- expect(page).to have_no_content "Add answer option"
400
+ expect(page).to have_no_content "Add response option"
401
401
  expect(page).to have_no_select("Maximum number of choices")
402
402
  end
403
403
 
@@ -407,7 +407,7 @@ shared_examples_for "add questions" do
407
407
  select "Multiple option", from: "Type"
408
408
  expect(page).to have_css("input[type=checkbox][id$=_free_text]")
409
409
 
410
- select "Short answer", from: "Type"
410
+ select "Short response", from: "Type"
411
411
  expect(page).to have_no_css("input[type=checkbox][id$=_free_text]")
412
412
 
413
413
  select "Single option", from: "Type"
@@ -429,7 +429,7 @@ shared_examples_for "add questions" do
429
429
  fill_in find_nested_form_field_locator("body_en"), with: "This is the first question"
430
430
  end
431
431
 
432
- expect(page).to have_no_content "Add answer option"
432
+ expect(page).to have_no_content "Add response option"
433
433
  expect(page).to have_no_content "Add row"
434
434
  expect(page).to have_no_select("Maximum number of choices")
435
435
  end
@@ -440,7 +440,7 @@ shared_examples_for "add questions" do
440
440
  select "Matrix (Multiple option)", from: "Type"
441
441
  expect(page).to have_css("input[type=checkbox][id$=_free_text]")
442
442
 
443
- select "Short answer", from: "Type"
443
+ select "Short response", from: "Type"
444
444
  expect(page).to have_no_css("input[type=checkbox][id$=_free_text]")
445
445
 
446
446
  select "Matrix (Single option)", from: "Type"
@@ -4,18 +4,18 @@ require "spec_helper"
4
4
 
5
5
  shared_examples_for "update display conditions" do
6
6
  context "when loading a saved display condition" do
7
- let!(:condition_question_type) { "short_answer" }
7
+ let!(:condition_question_type) { "short_response" }
8
8
  let!(:condition_question) { create(:questionnaire_question, questionnaire:, question_type: condition_question_type, position: 1) }
9
- let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "short_answer", position: 2) }
10
- let!(:condition_type) { :answered }
11
- let!(:answer_option) { nil }
9
+ let!(:question) { create(:questionnaire_question, questionnaire:, question_type: "short_response", position: 2) }
10
+ let!(:condition_type) { :responded }
11
+ let!(:response_option) { nil }
12
12
 
13
13
  let!(:display_condition) do
14
14
  create(:display_condition,
15
15
  question:,
16
16
  condition_question:,
17
17
  condition_type:,
18
- answer_option:)
18
+ response_option:)
19
19
  end
20
20
 
21
21
  before do
@@ -35,20 +35,20 @@ shared_examples_for "update display conditions" do
35
35
 
36
36
  it "loads condition_type in select" do
37
37
  within ".questionnaire-question-display-condition" do
38
- expect(page).to have_select("Condition", selected: "Answered")
38
+ expect(page).to have_select("Condition", selected: "Responded")
39
39
  end
40
40
  end
41
41
 
42
42
  context "when condition_type is :equal" do
43
43
  let!(:condition_question_type) { "single_option" }
44
- let!(:answer_options) { create_list(:answer_option, 3, question: condition_question) }
45
- let!(:answer_option) { answer_options.third }
44
+ let!(:response_options) { create_list(:response_option, 3, question: condition_question) }
45
+ let!(:response_option) { response_options.third }
46
46
  let!(:condition_type) { :equal }
47
47
 
48
- it "loads answer_option in select" do
48
+ it "loads response_option in select" do
49
49
  within ".questionnaire-question-display-condition" do
50
50
  expect(page).to have_select("Condition", selected: "Equal")
51
- expect(page).to have_select("Answer option", selected: answer_option.body["en"])
51
+ expect(page).to have_select("Response option", selected: response_option.body["en"])
52
52
  end
53
53
  end
54
54
  end