decidim-forms 0.32.0.rc1 → 0.32.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb +10 -2
  3. data/config/locales/ar.yml +1 -0
  4. data/config/locales/bg.yml +1 -0
  5. data/config/locales/ca-IT.yml +2 -1
  6. data/config/locales/ca.yml +2 -1
  7. data/config/locales/cs.yml +1 -0
  8. data/config/locales/de.yml +1 -0
  9. data/config/locales/el.yml +1 -0
  10. data/config/locales/es-MX.yml +1 -0
  11. data/config/locales/es-PY.yml +1 -0
  12. data/config/locales/es.yml +1 -0
  13. data/config/locales/eu.yml +1 -0
  14. data/config/locales/fi-plain.yml +1 -0
  15. data/config/locales/fi.yml +1 -0
  16. data/config/locales/fr-CA.yml +1 -0
  17. data/config/locales/fr.yml +1 -0
  18. data/config/locales/ga-IE.yml +1 -0
  19. data/config/locales/gl.yml +1 -0
  20. data/config/locales/hu.yml +1 -0
  21. data/config/locales/id-ID.yml +1 -0
  22. data/config/locales/it.yml +1 -0
  23. data/config/locales/ja.yml +1 -0
  24. data/config/locales/kaa.yml +1 -0
  25. data/config/locales/lb.yml +1 -0
  26. data/config/locales/lt.yml +1 -0
  27. data/config/locales/lv.yml +1 -0
  28. data/config/locales/nl.yml +1 -0
  29. data/config/locales/no.yml +1 -0
  30. data/config/locales/pl.yml +1 -0
  31. data/config/locales/pt-BR.yml +1 -0
  32. data/config/locales/pt.yml +1 -0
  33. data/config/locales/ro-RO.yml +1 -0
  34. data/config/locales/ru.yml +1 -0
  35. data/config/locales/sk.yml +187 -0
  36. data/config/locales/sv.yml +1 -0
  37. data/config/locales/tr-TR.yml +1 -0
  38. data/config/locales/val-ES.yml +1 -0
  39. data/config/locales/zh-CN.yml +1 -0
  40. data/config/locales/zh-TW.yml +1 -0
  41. data/decidim-forms.gemspec +1 -1
  42. data/lib/decidim/forms/test/shared_examples/questionnaire_admin_access.rb +95 -0
  43. data/lib/decidim/forms/test/shared_examples/questionnaire_admin_controller_permissions.rb +41 -0
  44. data/lib/decidim/forms/version.rb +1 -1
  45. metadata +9 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18fed0b0314ee79c04d1a36d62204f4355dcb73cc502b2b01a9a3dab3b5ceda6
4
- data.tar.gz: d68ec90f7e93ec48e82dd38f4db613f28c243ab970a8b3f81e884bce3b186c28
3
+ metadata.gz: b2bdd9c7d73187666ed28df6751ec71cb2d826f0e2b1a887c5275e10082526ef
4
+ data.tar.gz: e11d7a2163dc910d3b09edead55eb9390e677f6fa153666c0f537e9a528f6d4f
5
5
  SHA512:
6
- metadata.gz: 383d83fb7d21ed05daa0a895c49d48379c4566c462026337d2d52e7369e53679609e8b908a8a6b5f044490b3c4fc1efe0f4783ec0d965e816f876b0bf7552edb
7
- data.tar.gz: 97646d70d6c51357cf32a0e27c6e472b4327c17a6219217c9d4747e03a8e852e0ba2fc87e60fe7820cd7dc4b95bdbf109eda8e79b912da47a9a9b53a7d70973f
6
+ metadata.gz: e6a3dc54dda3a03fbc703d09fb29643de3587700d05aee3fac6d154f0da2e1bb0b4a98a89670626f53b326ebea26fce180e889f4f2370fcebfd3e846e41e0356
7
+ data.tar.gz: ff7eb2cc83c9a8d146e5cd3a31022eb4085dcadf41eac78d3818319be45851d081872e030edf25f3b8f00f64fc37f3b61cade99b4c82f6e0d02b992fd638b43c
@@ -35,7 +35,7 @@ module Decidim
35
35
  end
36
36
 
37
37
  def edit
38
- enforce_permission_to(:update, :questionnaire, questionnaire:)
38
+ enforce_permission_to(:update, permission_subject, questionnaire:)
39
39
 
40
40
  @form = form(Admin::QuestionnaireForm).from_model(questionnaire)
41
41
 
@@ -43,7 +43,7 @@ module Decidim
43
43
  end
44
44
 
45
45
  def update
46
- enforce_permission_to(:update, :questionnaire, questionnaire:)
46
+ enforce_permission_to(:update, permission_subject, questionnaire:)
47
47
 
48
48
  @form = form(Admin::QuestionnaireForm).from_params(params)
49
49
 
@@ -63,6 +63,8 @@ module Decidim
63
63
  end
64
64
 
65
65
  def edit_questions
66
+ enforce_permission_to(:update, permission_subject, questionnaire:)
67
+
66
68
  @form = form(Admin::QuestionsForm).from_model(questionnaire)
67
69
 
68
70
  render template: edit_questions_template
@@ -71,6 +73,8 @@ module Decidim
71
73
  # i18n-tasks-use t("decidim.forms.admin.questionnaires.questions_form.update.success")
72
74
  # i18n-tasks-use t("decidim.forms.admin.questionnaires.update.invalid")
73
75
  def update_questions
76
+ enforce_permission_to(:update, permission_subject, questionnaire:)
77
+
74
78
  @form = form(Admin::QuestionsForm).from_params(params)
75
79
  Admin::UpdateQuestions.call(@form, questionnaire) do
76
80
  on(:ok) do
@@ -182,6 +186,10 @@ module Decidim
182
186
  [condition_type, I18n.t("decidim.forms.admin.questionnaires.display_condition.condition_types.#{condition_type}")]
183
187
  end
184
188
  end
189
+
190
+ def permission_subject
191
+ :questionnaire
192
+ end
185
193
  end
186
194
  end
187
195
  end
@@ -1,3 +1,4 @@
1
+ ---
1
2
  ar:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  bg:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  ca-IT:
2
3
  activemodel:
3
4
  attributes:
@@ -188,7 +189,7 @@ ca-IT:
188
189
  of_total_steps: de %{total_steps}
189
190
  questionnaire_closed:
190
191
  body: El formulari està tancat i no es pot respondre.
191
- title: S'ha tancat el formulari
192
+ title: Formulari tancat
192
193
  questionnaire_for_members:
193
194
  body: El formulari només està disponible per a membres
194
195
  title: S'ha tancat el formulari
@@ -1,3 +1,4 @@
1
+ ---
1
2
  ca:
2
3
  activemodel:
3
4
  attributes:
@@ -188,7 +189,7 @@ ca:
188
189
  of_total_steps: de %{total_steps}
189
190
  questionnaire_closed:
190
191
  body: El formulari està tancat i no es pot respondre.
191
- title: S'ha tancat el formulari
192
+ title: Formulari tancat
192
193
  questionnaire_for_members:
193
194
  body: El formulari només està disponible per a membres
194
195
  title: S'ha tancat el formulari
@@ -1,3 +1,4 @@
1
+ ---
1
2
  cs:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  de:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  el:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  es-MX:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  es-PY:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  es:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  eu:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  fi-pl:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  fi:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  fr-CA:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  fr:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  ga:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  gl:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  hu:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  id:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  it:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  ja:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  kaa:
2
3
  decidim:
3
4
  forms:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  lb:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  lt:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  lv:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  nl:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  "no":
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  pl:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  pt-BR:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  pt:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  ro:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  ru:
2
3
  decidim:
3
4
  forms:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  sk:
2
3
  activemodel:
3
4
  attributes:
@@ -6,40 +7,226 @@ sk:
6
7
  question_type: Typ
7
8
  questionnaire_question:
8
9
  mandatory: Povinné
10
+ max_characters: Limit znakov (ponechajte 0, ak bez limitu)
11
+ response:
12
+ body: Odpoveď
13
+ choices: Možnosti
14
+ selected_choices: Vybrané možnosti
15
+ errors:
16
+ models:
17
+ questionnaire:
18
+ request_invalid: Pri spracovaní požiadavky sa vyskytol problém. Skúste to znova.
19
+ response:
20
+ attributes:
21
+ add_documents:
22
+ needs_to_be_reattached: Je potrebné znova pripojiť
23
+ body:
24
+ too_long: je príliš dlhé
25
+ choices:
26
+ missing: nie sú úplné
27
+ too_many: Môžete si vybrať maximálne %{count}.
9
28
  decidim:
29
+ download_your_data:
30
+ help:
31
+ responses:
32
+ id: Jedinečný identifikátor odpovede
33
+ question: Otázka, na ktorú sa odpovedalo
34
+ questionnaire: Dotazník, na ktorý sa odpovedalo
35
+ response: Odpoveď na otázku
36
+ user: Používateľ, ktorý odpovedal na dotazník
37
+ show:
38
+ responses: Export odpovedí
39
+ survey_user_responses: Odpovede používateľov v prieskume
10
40
  forms:
11
41
  admin:
12
42
  models:
13
43
  components:
44
+ allow_editing_responses: Povoliť registrovaným používateľom upravovať vlastné odpovede v prieskume
45
+ allow_responses: Povoliť odpovede
46
+ allow_unregistered: Povoliť neregistrovaným používateľom odpovedať na prieskum
47
+ allow_unregistered_help: Ak je táto možnosť aktívna, na odpovedanie na prieskum nebude potrebné prihlásenie. To môže viesť k nekvalitným alebo nespoľahlivým údajom a bude to zraniteľnejšie voči automatizovaným útokom. Používajte opatrne! Majte na pamäti, že účastník môže na ten istý prieskum odpovedať viackrát pomocou rôznych prehliadačov alebo funkcie „súkromné prehliadanie“ vo svojom webovom prehliadači.
48
+ announcement: Oznámenie
49
+ clean_after_publish: Vymazať odpovede pri zverejnení prieskumu
14
50
  description: Popis
51
+ ends_at: Odpovede prijímané do
52
+ ends_at_help: Ponechajte prázdne, ak nie je určený konkrétny dátum
53
+ starts_at: Odpovede prijímané od
54
+ starts_at_help: Ponechajte prázdne, ak nie je určený konkrétny dátum
15
55
  tos: Podmienky použitia
16
56
  questionnaires:
57
+ actions:
58
+ back: Späť na odpovede
59
+ publish_responses: Zverejniť odpovede
60
+ show: Odpovede
61
+ display_condition:
62
+ condition_question: Otázka
63
+ condition_type: Podmienka
64
+ condition_types:
65
+ equal: Rovná sa
66
+ match: Obsahuje text
67
+ not_equal: Nerovná sa
68
+ not_responded: Nezodpovedané
69
+ responded: Zodpovedané
70
+ condition_value: Zahrnutý text
71
+ display_condition: Podmienka zobrazenia
72
+ mandatory: Táto podmienka musí byť splnená vždy bez ohľadu na stav iných podmienok
73
+ remove: Odstrániť
74
+ response_option: Možnosť odpovede
75
+ save_warning: Nezabudnite uložiť formulár pred konfiguráciou podmienok zobrazenia
76
+ select_condition_question: Vyberte otázku
77
+ select_condition_type: Vyberte typ podmienky
78
+ select_response_option: Vyberte možnosť odpovede
17
79
  edit:
18
80
  save: Uložiť
81
+ title: Upraviť dotazník
82
+ edit_questions:
83
+ add_question: Pridať otázku
84
+ add_separator: Pridať oddeľovač
85
+ add_title_and_description: Pridať názov a popis
86
+ save: Uložiť
87
+ title: Otázky
19
88
  form:
20
89
  add_question: Pridať otázku
90
+ collapse: Zbaliť všetky otázky
91
+ expand: Rozbaliť všetky otázky
92
+ preview: Náhľad
93
+ title: Upraviť formulár pre %{questionnaire_for}
21
94
  matrix_row:
95
+ matrix_row: Riadok
22
96
  remove: Odstrániť
23
97
  statement: Prehlásenie
24
98
  question:
99
+ add_display_condition: Pridať podmienku zobrazenia
100
+ add_display_condition_info: Uložte formulár pre konfiguráciu podmienok zobrazenia
101
+ add_matrix_row: Pridať riadok
102
+ add_response_option: Pridať možnosť odpovede
25
103
  any: Akékoľvek
104
+ collapse: Zbaliť
26
105
  description: Popis
106
+ expand: Rozbaliť
27
107
  question: Otázka
28
108
  remove: Odstrániť
29
109
  statement: Prehlásenie
110
+ questions_form:
111
+ already_responded_warning: Na formulár už odpovedali niektorí používatelia, takže nemôžete upravovať jeho otázky.
112
+ collapse: Zbaliť všetky otázky
113
+ expand: Rozbaliť všetky otázky
114
+ unpublished_warning: Formulár nie je zverejnený. Môžete upraviť jeho otázky, ale týmto krokom sa vymažú aktuálne odpovede.
115
+ update:
116
+ success: Otázky prieskumu boli úspešne uložené.
117
+ response_option:
118
+ free_text: Voľný text
119
+ remove: Odstrániť
120
+ response_option: Možnosť odpovede
121
+ statement: Tvrdenie
122
+ responses:
123
+ actions:
124
+ back: Späť na odpovede
125
+ export: Exportovať
126
+ next: Ďalej ›
127
+ previous: "‹ Predchádzajúce"
128
+ show: Zobraziť odpovede
129
+ empty: Zatiaľ žiadne odpovede
130
+ export:
131
+ response:
132
+ title: 'Odpoveď č. %{number}'
133
+ export_response:
134
+ title: survey_user_responses_%{token}
135
+ index:
136
+ title: "Celkovo %{total} odpovedí"
137
+ show:
138
+ title: 'Odpoveď č. %{number}'
139
+ separator:
140
+ remove: Odstrániť
141
+ separator: Oddeľovač
142
+ title_and_description:
143
+ collapse: Zbaliť
144
+ description: Popis
145
+ expand: Rozbaliť
146
+ remove: Odstrániť
147
+ title: Názov
148
+ title_and_description: Názov a popis
30
149
  update:
31
150
  invalid: Vyskytol sa problém s ukladaním formulára.
151
+ success: Formulár bol úspešne uložený.
152
+ admin_log:
153
+ question:
154
+ publish_responses: "%{user_name} zverejnil/a odpovede na otázku %{resource_name} v priestore %{space_name}"
155
+ unpublish_responses: "%{user_name} zrušil/a zverejnenie odpovedí na otázku %{resource_name} v priestore %{space_name}"
156
+ questionnaire:
157
+ update: "%{user_name} aktualizoval/a dotazník %{resource_name}"
158
+ errors:
159
+ response:
160
+ body: Telo nemôže byť prázdne
161
+ images:
162
+ dimensions: "%{width} x %{height} px"
163
+ processors:
164
+ resize_and_pad: Veľkosť tohto obrázka sa zmení a doplní na %{dimensions}.
165
+ resize_to_fit: Veľkosť tohto obrázka sa zmení tak, aby sa zmestil do %{dimensions}.
32
166
  question_types:
167
+ files: Súbory
168
+ long_response: Dlhá odpoveď
169
+ matrix_multiple: Matica (Viacero možností)
170
+ matrix_single: Matica (Jedna možnosť)
33
171
  multiple_option: Viacero možností
172
+ short_response: Krátka odpoveď
34
173
  single_option: Jedna možnosť
35
174
  sorting: Zoradenie
175
+ title_and_description: Názov a popis
176
+ questionnaire_response_presenter:
177
+ download_attachment: Stiahnuť prílohu
36
178
  questionnaires:
37
179
  question:
38
180
  max_choices: 'Maximum možností: %{n}'
181
+ response:
182
+ invalid: Pri odpovedaní na formulár sa vyskytol problém.
183
+ max_choices_alert: Je vybratých príliš veľa možností
184
+ spam_detected: Pri odpovedaní na formulár sa vyskytol problém. Možno ste boli príliš rýchli, môžete to skúsiť znova?
185
+ success: Formulár bol úspešne vyplnený.
39
186
  show:
187
+ current_step: Krok %{step}
188
+ empty: Pre tento formulár zatiaľ nie sú nakonfigurované žiadne otázky.
189
+ of_total_steps: z %{total_steps}
40
190
  questionnaire_closed:
191
+ body: Formulár je uzavretý a nie je možné naň odpovedať.
41
192
  title: Formulár je uzavretý.
193
+ questionnaire_for_members:
194
+ body: Formulár je dostupný len pre členov
195
+ title: Formulár je uzavretý
196
+ questionnaire_js_disabled:
197
+ body: Niektoré funkcie tohto formulára budú vypnuté. Pre lepšiu skúsenosť si vo svojom prehliadači povoľte JavaScript.
198
+ title: JavaScript je vypnutý
199
+ questionnaire_not_published:
200
+ body: Tento formulár zatiaľ nie je zverejnený.
201
+ questionnaire_responded:
202
+ body: Na tento formulár ste už odpovedali.
203
+ title: Už ste odpovedali
204
+ questionnaire_responded_edit:
205
+ body: Na tento formulár ste už odpovedali. %{link}
206
+ edit: Upraviť vaše odpovede
207
+ response_questionnaire:
208
+ already_have_an_account?: Už máte účet?
209
+ are_you_new?: Nový používateľ?
210
+ sign_in_description: Prihláste sa, aby ste sa mohli zúčastniť prieskumu
211
+ sign_up_description: Vytvorte si účastnícky účet, aby ste sa mohli zúčastniť prieskumu
212
+ title: Odpovedať na formulár
42
213
  tos_agreement: Účasťou súhlasíte s našimi Podmienkami použitia
43
214
  step_navigation:
44
215
  show:
216
+ are_you_sure_edit_guest: Ak chcete mať možnosť neskôr upraviť svoje odpovede, musíte sa prihlásiť alebo si vytvoriť účet.
217
+ are_you_sure_no_edit: Túto akciu nie je možné vrátiť späť a nebudete môcť upraviť svoje odpovede. Ste si istí?
218
+ back: Späť
219
+ continue: Pokračovať
220
+ disallowed: Nemáte povolenie upravovať svoje odpovede.
45
221
  submit: Poslať
222
+ user_responses_serializer:
223
+ body: Odpoveď
224
+ completion: Dokončenie
225
+ created_at: Odpovedané dňa
226
+ id: ID odpovede
227
+ ip_hash: IP Hash
228
+ question: Otázka
229
+ registered: Registrovaný
230
+ session_token: Identifikátor používateľa
231
+ unregistered: Neregistrovaný
232
+ user_status: Stav používateľa
@@ -1,3 +1,4 @@
1
+ ---
1
2
  sv:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  tr:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  val:
2
3
  decidim:
3
4
  forms:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  zh-CN:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  zh-TW:
2
3
  activemodel:
3
4
  attributes:
@@ -4,7 +4,7 @@ $LOAD_PATH.push File.expand_path("lib", __dir__)
4
4
 
5
5
  # Describe your gem and declare its dependencies:
6
6
  Gem::Specification.new do |s|
7
- version = "0.32.0.rc1"
7
+ version = "0.32.0.rc2"
8
8
  s.version = version
9
9
  s.authors = ["Josep Jaume Rey Peroy", "Marc Riera Casals", "Oriol Gual Oliva", "Rubén González Valero"]
10
10
  s.email = ["josepjaume@gmail.com", "mrc2407@gmail.com", "oriolgual@gmail.com", "rbngzlv@gmail.com"]
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ shared_examples_for "questionnaire admin access" do |denied_error:, allow_process_admin: true|
6
+ context "when the user is not an admin", driver: :rack_test do
7
+ let(:regular_user) { create(:user, :confirmed, organization:) }
8
+ let(:target_path) { manage_questions_path }
9
+
10
+ before do
11
+ login_as regular_user, scope: :user
12
+ end
13
+
14
+ before do
15
+ allow(Rails.application).to \
16
+ receive(:env_config).with(no_args).and_wrap_original do |m, *|
17
+ m.call.merge(
18
+ "action_dispatch.show_exceptions" => true,
19
+ "action_dispatch.show_detailed_exceptions" => false
20
+ )
21
+ end
22
+
23
+ visit target_path
24
+ end
25
+
26
+ it "leads to an error" do
27
+ denied_response = case denied_error
28
+ when 403
29
+ page.status_code == 403 || page.has_content?("You are not authorized to perform this action")
30
+ when 404
31
+ page.status_code == 404 || page.has_content?("The page you are looking for cannot be found")
32
+ else
33
+ raise ArgumentError, "unsupported denied_error: #{denied_error.inspect}. Use 403 or 404"
34
+ end
35
+
36
+ expect(denied_response).to be(true)
37
+ end
38
+ end
39
+
40
+ if allow_process_admin
41
+ context "when the user is a process admin" do
42
+ let(:process_admin) { create(:process_admin, :confirmed, participatory_process:) }
43
+
44
+ it "allows access to the questionnaire" do
45
+ login_as process_admin, scope: :user
46
+ visit manage_questions_path
47
+
48
+ expect(page).to have_current_path(manage_questions_path)
49
+ end
50
+ end
51
+ else
52
+ context "when the user is a process admin", driver: :rack_test do
53
+ let(:participatory_process) { create(:participatory_process, organization:) }
54
+ let(:process_admin) { create(:process_admin, :confirmed, participatory_process:) }
55
+
56
+ before do
57
+ login_as process_admin, scope: :user
58
+
59
+ allow(Rails.application).to \
60
+ receive(:env_config).with(no_args).and_wrap_original do |m, *|
61
+ m.call.merge(
62
+ "action_dispatch.show_exceptions" => true,
63
+ "action_dispatch.show_detailed_exceptions" => false
64
+ )
65
+ end
66
+
67
+ visit manage_questions_path
68
+ end
69
+
70
+ it "denies access to the questionnaire" do
71
+ denied_response = case denied_error
72
+ when 403
73
+ page.status_code == 403 || page.has_content?("You are not authorized to perform this action")
74
+ when 404
75
+ page.status_code == 404 || page.has_content?("The page you are looking for cannot be found")
76
+ else
77
+ raise ArgumentError, "unsupported denied_error: #{denied_error.inspect}. Use 403 or 404"
78
+ end
79
+
80
+ expect(denied_response).to be(true)
81
+ end
82
+ end
83
+ end
84
+
85
+ context "when the user is an admin" do
86
+ let(:admin) { create(:user, :admin, :confirmed, organization:) }
87
+
88
+ it "allows access to the questionnaire" do
89
+ login_as admin, scope: :user
90
+ visit manage_questions_path
91
+
92
+ expect(page).to have_current_path(manage_questions_path)
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ shared_examples_for "questionnaire admin controller permissions" do
6
+ describe "GET #edit" do
7
+ let(:action) { :edit }
8
+
9
+ it "enforces permission to update the questionnaire" do
10
+ expect(controller).to receive(:enforce_permission_to).with(:update, permission_subject, questionnaire:)
11
+ get action
12
+ end
13
+ end
14
+
15
+ describe "PATCH #update" do
16
+ let(:action) { :update }
17
+
18
+ it "enforces permission to update the questionnaire" do
19
+ expect(controller).to receive(:enforce_permission_to).with(:update, permission_subject, questionnaire:)
20
+ patch action, params: { questionnaire: {} }
21
+ end
22
+ end
23
+
24
+ describe "GET #edit_questions" do
25
+ let(:action) { :edit_questions }
26
+
27
+ it "enforces permission to update the questionnaire" do
28
+ expect(controller).to receive(:enforce_permission_to).with(:update, permission_subject, questionnaire:)
29
+ get action
30
+ end
31
+ end
32
+
33
+ describe "PATCH #update_questions" do
34
+ let(:action) { :update_questions }
35
+
36
+ it "enforces permission to update the questionnaire" do
37
+ expect(controller).to receive(:enforce_permission_to).with(:update, permission_subject, questionnaire:)
38
+ patch action, params: { questions: {} }
39
+ end
40
+ end
41
+ end
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-forms version.
5
5
  module Forms
6
6
  def self.version
7
- "0.32.0.rc1"
7
+ "0.32.0.rc2"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.0.rc1
4
+ version: 0.32.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -18,42 +18,42 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.32.0.rc1
21
+ version: 0.32.0.rc2
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 0.32.0.rc1
28
+ version: 0.32.0.rc2
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: decidim-admin
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 0.32.0.rc1
35
+ version: 0.32.0.rc2
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 0.32.0.rc1
42
+ version: 0.32.0.rc2
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: decidim-dev
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - '='
48
48
  - !ruby/object:Gem::Version
49
- version: 0.32.0.rc1
49
+ version: 0.32.0.rc2
50
50
  type: :development
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - '='
55
55
  - !ruby/object:Gem::Version
56
- version: 0.32.0.rc1
56
+ version: 0.32.0.rc2
57
57
  description: A forms gem for decidim.
58
58
  email:
59
59
  - josepjaume@gmail.com
@@ -286,6 +286,8 @@ files:
286
286
  - lib/decidim/forms/test/shared_examples/manage_questionnaires/draggable_behavior.rb
287
287
  - lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb
288
288
  - lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb
289
+ - lib/decidim/forms/test/shared_examples/questionnaire_admin_access.rb
290
+ - lib/decidim/forms/test/shared_examples/questionnaire_admin_controller_permissions.rb
289
291
  - lib/decidim/forms/user_responses_serializer.rb
290
292
  - lib/decidim/forms/version.rb
291
293
  homepage: https://decidim.org