decidim-core 0.27.5 → 0.27.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/activity_cell.rb +2 -2
- data/app/cells/decidim/card_cell.rb +2 -2
- data/app/cells/decidim/card_m/top.erb +1 -1
- data/app/cells/decidim/card_m_cell.rb +1 -1
- data/app/cells/decidim/follow_button_cell.rb +1 -1
- data/app/cells/decidim/notification/moderated.erb +24 -0
- data/app/cells/decidim/notification_cell.rb +5 -1
- data/app/cells/decidim/scopes_picker/scope_picker_values.erb +1 -1
- data/app/cells/decidim/tags_cell.rb +3 -1
- data/app/cells/decidim/user_profile_cell.rb +1 -1
- data/app/commands/decidim/create_omniauth_registration.rb +2 -4
- data/app/commands/decidim/messaging/reply_to_conversation.rb +3 -0
- data/app/commands/decidim/messaging/start_conversation.rb +3 -0
- data/app/controllers/concerns/decidim/devise_authentication_methods.rb +36 -0
- data/app/controllers/concerns/decidim/force_authentication.rb +1 -1
- data/app/controllers/concerns/decidim/paginable.rb +1 -1
- data/app/controllers/concerns/decidim/use_organization_time_zone.rb +1 -1
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +1 -22
- data/app/controllers/decidim/devise/sessions_controller.rb +1 -24
- data/app/controllers/decidim/links_controller.rb +13 -1
- data/app/controllers/decidim/widgets_controller.rb +6 -0
- data/app/events/decidim/welcome_notification_event.rb +6 -9
- data/app/helpers/decidim/cells_paginate_helper.rb +1 -1
- data/app/helpers/decidim/check_boxes_tree_helper.rb +4 -4
- data/app/helpers/decidim/newsletters_helper.rb +83 -16
- data/app/helpers/decidim/resource_helper.rb +1 -1
- data/app/helpers/decidim/sanitize_helper.rb +9 -0
- data/app/helpers/decidim/user_profile_helper.rb +7 -2
- data/app/mailers/decidim/application_mailer.rb +40 -6
- data/app/mailers/decidim/messaging/conversation_mailer.rb +3 -72
- data/app/models/decidim/push_notification_message.rb +39 -0
- data/app/packs/images/decidim/.keep +0 -0
- data/app/packs/src/decidim/input_hashtags.js +1 -1
- data/app/packs/src/decidim/input_mentions.js +1 -1
- data/app/packs/src/decidim/input_multiple_mentions.js +1 -1
- data/app/packs/src/decidim/vizzs/index.js +1 -1
- data/app/packs/stylesheets/decidim/plugins/leaflet.scss +118 -114
- data/app/presenters/decidim/admin_log/oauth_application_resource_presenter.rb +1 -1
- data/app/presenters/decidim/admin_log/organization_presenter.rb +1 -1
- data/app/presenters/decidim/log/resource_presenter.rb +7 -1
- data/app/presenters/decidim/notification_to_mailer_presenter.rb +9 -0
- data/app/services/decidim/events_manager.rb +6 -0
- data/app/services/decidim/log/diff_changeset_calculator.rb +1 -1
- data/app/services/decidim/push_notification_message_sender.rb +36 -0
- data/app/services/decidim/send_push_notification.rb +22 -8
- data/app/views/decidim/devise/registrations/new.html.erb +2 -2
- data/app/views/decidim/links/new.html.erb +2 -0
- data/app/views/decidim/notifications_digest_mailer/_email_content.html.erb +7 -0
- data/app/views/decidim/shared/_address_details.html.erb +2 -2
- data/app/views/layouts/decidim/_js_configuration.html.erb +1 -0
- data/config/locales/ar.yml +4 -3
- data/config/locales/bg.yml +484 -1
- data/config/locales/ca.yml +23 -22
- data/config/locales/cs.yml +0 -1
- data/config/locales/de.yml +28 -27
- data/config/locales/el.yml +5 -4
- data/config/locales/en.yml +1 -0
- data/config/locales/eo.yml +3 -0
- data/config/locales/es-MX.yml +6 -5
- data/config/locales/es-PY.yml +6 -5
- data/config/locales/es.yml +25 -24
- data/config/locales/eu.yml +12 -2
- data/config/locales/fi-plain.yml +1 -0
- data/config/locales/fi.yml +4 -3
- data/config/locales/fr-CA.yml +5 -4
- data/config/locales/fr.yml +3 -2
- data/config/locales/ga-IE.yml +5 -0
- data/config/locales/gl.yml +3 -0
- data/config/locales/he-IL.yml +1 -0
- data/config/locales/hu.yml +41 -9
- data/config/locales/it.yml +5 -4
- data/config/locales/ja.yml +5 -3
- data/config/locales/lb.yml +5 -4
- data/config/locales/lt.yml +4 -4
- data/config/locales/lv.yml +4 -1
- data/config/locales/nl.yml +4 -1
- data/config/locales/no.yml +5 -4
- data/config/locales/pl.yml +168 -1
- data/config/locales/pt-BR.yml +113 -22
- data/config/locales/pt.yml +5 -4
- data/config/locales/ro-RO.yml +1 -3
- data/config/locales/ru.yml +13 -0
- data/config/locales/sk.yml +6 -1
- data/config/locales/sl.yml +5 -0
- data/config/locales/sv.yml +26 -3
- data/config/locales/tr-TR.yml +3 -3
- data/config/locales/uk.yml +15 -0
- data/config/locales/zh-CN.yml +0 -4
- data/config/locales/zh-TW.yml +4 -4
- data/decidim-core.gemspec +78 -0
- data/lib/decidim/acts_as_tree.rb +14 -1
- data/lib/decidim/asset_router/storage.rb +4 -0
- data/lib/decidim/attribute_encryptor.rb +6 -4
- data/lib/decidim/core/engine.rb +7 -3
- data/lib/decidim/core/test/factories.rb +314 -95
- data/lib/decidim/core/test/shared_examples/amendable/amendment_created_event_examples.rb +6 -26
- data/lib/decidim/core/test/shared_examples/amendable/amendment_promoted_event_examples.rb +8 -26
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +32 -0
- data/lib/decidim/core/test/shared_examples/embed_resource_examples.rb +187 -11
- data/lib/decidim/core/test/shared_examples/has_attachment_collections.rb +8 -6
- data/lib/decidim/core/test/shared_examples/has_attachments.rb +4 -4
- data/lib/decidim/core/test/shared_examples/has_category.rb +27 -0
- data/lib/decidim/core/test/shared_examples/has_reference.rb +1 -1
- data/lib/decidim/core/test/shared_examples/has_space_in_mcell_examples.rb +1 -2
- data/lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb +6 -3
- data/lib/decidim/core/test/shared_examples/resource_locator_presenter_examples.rb +134 -0
- data/lib/decidim/core/test/shared_examples/searchable_results_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/simple_event.rb +50 -2
- data/lib/decidim/core/test.rb +1 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/core.rb +1 -0
- data/lib/decidim/engine_router.rb +17 -4
- data/lib/decidim/events/base_event.rb +9 -2
- data/lib/decidim/events/simple_event.rb +3 -17
- data/lib/decidim/form_builder.rb +13 -1
- data/lib/decidim/has_category.rb +1 -1
- data/lib/decidim/has_conversations.rb +91 -0
- data/lib/decidim/organization_settings.rb +10 -2
- data/lib/decidim/participable.rb +17 -0
- data/lib/decidim/view_model.rb +1 -0
- data/lib/decidim/webpacker/webpack/.modernizrrc +9 -0
- data/lib/premailer/adapter/decidim.rb +5 -4
- data/lib/tasks/decidim_reminders_tasks.rake +1 -0
- data/lib/tasks/upgrade/decidim_fix_categorization.rake +15 -0
- metadata +29 -27
- data/config/environment.rb +0 -3
@@ -8,8 +8,39 @@ require "decidim/participatory_processes/test/factories"
|
|
8
8
|
require "decidim/assemblies/test/factories"
|
9
9
|
require "decidim/comments/test/factories"
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def generate_component_name(locales, manifest_name, skip_injection: false)
|
12
|
+
prepend = skip_injection ? "" : "<script>alert('#{manifest_name}');</script>"
|
13
|
+
|
14
|
+
Decidim::Components::Namer.new(locales, manifest_name).i18n_name.transform_values { |v| [prepend, v].compact_blank.join(" ") }
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_localized_description(field = nil, skip_injection: false, before: "<p>", after: "</p>")
|
18
|
+
Decidim::Faker::Localized.wrapped(before, after) do
|
19
|
+
generate_localized_title(field, skip_injection: skip_injection)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_localized_word(field = nil, skip_injection: false)
|
24
|
+
skip_injection = true if field.nil?
|
25
|
+
Decidim::Faker::Localized.localized do
|
26
|
+
if skip_injection
|
27
|
+
Faker::Lorem.word
|
28
|
+
else
|
29
|
+
"<script>alert('#{field}');</script> #{Faker::Lorem.word}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def generate_localized_title(field = nil, skip_injection: false)
|
35
|
+
skip_injection = true if field.nil?
|
36
|
+
|
37
|
+
Decidim::Faker::Localized.localized do
|
38
|
+
if skip_injection
|
39
|
+
generate(:title)
|
40
|
+
else
|
41
|
+
"<script>alert('#{field}');</script> #{generate(:title)}"
|
42
|
+
end
|
43
|
+
end
|
13
44
|
end
|
14
45
|
|
15
46
|
FactoryBot.define do
|
@@ -54,21 +85,29 @@ FactoryBot.define do
|
|
54
85
|
end
|
55
86
|
|
56
87
|
factory :category, class: "Decidim::Category" do
|
57
|
-
|
58
|
-
|
88
|
+
transient do
|
89
|
+
skip_injection { false }
|
90
|
+
end
|
91
|
+
|
92
|
+
name { generate_localized_title(:category_name, skip_injection: skip_injection) }
|
93
|
+
description { generate_localized_description(:category_description, skip_injection: skip_injection) }
|
59
94
|
weight { 0 }
|
60
95
|
|
61
96
|
association :participatory_space, factory: :participatory_process
|
62
97
|
end
|
63
98
|
|
64
99
|
factory :subcategory, parent: :category do
|
65
|
-
|
100
|
+
transient do
|
101
|
+
skip_injection { false }
|
102
|
+
end
|
103
|
+
parent { build(:category, skip_injection: skip_injection) }
|
66
104
|
|
67
105
|
participatory_space { parent.participatory_space }
|
68
106
|
end
|
69
107
|
|
70
108
|
factory :organization, class: "Decidim::Organization" do
|
71
109
|
transient do
|
110
|
+
skip_injection { false }
|
72
111
|
create_static_pages { true }
|
73
112
|
end
|
74
113
|
|
@@ -81,7 +120,7 @@ FactoryBot.define do
|
|
81
120
|
youtube_handler { Faker::Hipster.word }
|
82
121
|
github_handler { Faker::Hipster.word }
|
83
122
|
sequence(:host) { |n| "#{n}.lvh.me" }
|
84
|
-
description {
|
123
|
+
description { generate_localized_description(:organization_description, skip_injection: skip_injection) }
|
85
124
|
favicon { Decidim::Dev.test_file("icon.png", "image/png") }
|
86
125
|
default_locale { Decidim.default_locale }
|
87
126
|
available_locales { Decidim.available_locales }
|
@@ -95,7 +134,7 @@ FactoryBot.define do
|
|
95
134
|
user_groups_enabled { true }
|
96
135
|
send_welcome_notification { true }
|
97
136
|
comments_max_length { 1000 }
|
98
|
-
admin_terms_of_use_body {
|
137
|
+
admin_terms_of_use_body { generate_localized_description(:admin_terms_of_service_body, skip_injection: skip_injection) }
|
99
138
|
force_users_to_authenticate_before_access_organization { false }
|
100
139
|
machine_translation_display_priority { "original" }
|
101
140
|
external_domain_whitelist { ["example.org", "twitter.com", "facebook.com", "youtube.com", "github.com", "mytesturl.me"] }
|
@@ -118,12 +157,15 @@ FactoryBot.define do
|
|
118
157
|
after(:create) do |organization, evaluator|
|
119
158
|
if evaluator.create_static_pages
|
120
159
|
tos_page = Decidim::StaticPage.find_by(slug: "terms-and-conditions", organization: organization)
|
121
|
-
create(:static_page, :tos, organization: organization) if tos_page.nil?
|
160
|
+
create(:static_page, :tos, organization: organization, skip_injection: evaluator.skip_injection) if tos_page.nil?
|
122
161
|
end
|
123
162
|
end
|
124
163
|
end
|
125
164
|
|
126
165
|
factory :user, class: "Decidim::User" do
|
166
|
+
transient do
|
167
|
+
skip_injection { false }
|
168
|
+
end
|
127
169
|
email { generate(:email) }
|
128
170
|
name { generate(:name) }
|
129
171
|
nickname { generate(:nickname) }
|
@@ -132,7 +174,7 @@ FactoryBot.define do
|
|
132
174
|
tos_agreement { "1" }
|
133
175
|
avatar { Decidim::Dev.test_file("avatar.jpg", "image/jpeg") }
|
134
176
|
personal_url { Faker::Internet.url }
|
135
|
-
about {
|
177
|
+
about { generate_localized_title(:user_about, skip_injection: skip_injection) }
|
136
178
|
confirmation_sent_at { Time.current }
|
137
179
|
accepted_tos_version { organization.tos_version }
|
138
180
|
notifications_sending_frequency { "real_time" }
|
@@ -181,7 +223,7 @@ FactoryBot.define do
|
|
181
223
|
|
182
224
|
trait :officialized do
|
183
225
|
officialized_at { Time.current }
|
184
|
-
officialized_as { generate_localized_title }
|
226
|
+
officialized_as { generate_localized_title(:officialized_as, skip_injection: skip_injection) }
|
185
227
|
end
|
186
228
|
|
187
229
|
after(:build) do |user, evaluator|
|
@@ -194,17 +236,24 @@ FactoryBot.define do
|
|
194
236
|
end
|
195
237
|
|
196
238
|
factory :participatory_space_private_user, class: "Decidim::ParticipatorySpacePrivateUser" do
|
239
|
+
transient do
|
240
|
+
skip_injection { false }
|
241
|
+
end
|
197
242
|
user
|
198
|
-
privatable_to { create
|
243
|
+
privatable_to { create(:participatory_process, organization: user.organization, skip_injection: skip_injection) }
|
199
244
|
end
|
200
245
|
|
201
246
|
factory :assembly_private_user, class: "Decidim::ParticipatorySpacePrivateUser" do
|
247
|
+
transient do
|
248
|
+
skip_injection { false }
|
249
|
+
end
|
202
250
|
user
|
203
|
-
privatable_to { create
|
251
|
+
privatable_to { create(:assembly, organization: user.organization, skip_injection: skip_injection) }
|
204
252
|
end
|
205
253
|
|
206
254
|
factory :user_group, class: "Decidim::UserGroup" do
|
207
255
|
transient do
|
256
|
+
skip_injection { false }
|
208
257
|
document_number { "#{Faker::Number.number(digits: 8)}X" }
|
209
258
|
phone { Faker::PhoneNumber.phone_number }
|
210
259
|
rejected_at { nil }
|
@@ -214,7 +263,7 @@ FactoryBot.define do
|
|
214
263
|
sequence(:name) { |n| "#{Faker::Company.name} #{n}" }
|
215
264
|
email { generate(:user_group_email) }
|
216
265
|
nickname { generate(:nickname) }
|
217
|
-
about {
|
266
|
+
about { generate_localized_title(:user_group_about, skip_injection: skip_injection) }
|
218
267
|
organization
|
219
268
|
avatar { Decidim::Dev.test_file("avatar.jpg", "image/jpeg") } # Keep after organization
|
220
269
|
|
@@ -255,21 +304,27 @@ FactoryBot.define do
|
|
255
304
|
next if users.empty?
|
256
305
|
|
257
306
|
creator = users.shift
|
258
|
-
create(:user_group_membership, user: creator, user_group: user_group, role: :creator)
|
307
|
+
create(:user_group_membership, user: creator, user_group: user_group, role: :creator, skip_injection: evaluator.skip_injection)
|
259
308
|
|
260
309
|
users.each do |user|
|
261
|
-
create(:user_group_membership, user: user, user_group: user_group, role: :admin)
|
310
|
+
create(:user_group_membership, user: user, user_group: user_group, role: :admin, skip_injection: evaluator.skip_injection)
|
262
311
|
end
|
263
312
|
end
|
264
313
|
end
|
265
314
|
|
266
315
|
factory :user_group_membership, class: "Decidim::UserGroupMembership" do
|
267
|
-
|
316
|
+
transient do
|
317
|
+
skip_injection { false }
|
318
|
+
end
|
319
|
+
user { create(:user, :confirmed, organization: user_group.organization, skip_injection: skip_injection) }
|
268
320
|
role { :creator }
|
269
321
|
user_group
|
270
322
|
end
|
271
323
|
|
272
324
|
factory :identity, class: "Decidim::Identity" do
|
325
|
+
transient do
|
326
|
+
skip_injection { false }
|
327
|
+
end
|
273
328
|
provider { "facebook" }
|
274
329
|
sequence(:uid)
|
275
330
|
user
|
@@ -277,6 +332,9 @@ FactoryBot.define do
|
|
277
332
|
end
|
278
333
|
|
279
334
|
factory :authorization, class: "Decidim::Authorization" do
|
335
|
+
transient do
|
336
|
+
skip_injection { false }
|
337
|
+
end
|
280
338
|
sequence(:name) { |n| "dummy_authorization_#{n}" }
|
281
339
|
user
|
282
340
|
metadata { {} }
|
@@ -292,10 +350,13 @@ FactoryBot.define do
|
|
292
350
|
end
|
293
351
|
|
294
352
|
factory :static_page, class: "Decidim::StaticPage" do
|
353
|
+
transient do
|
354
|
+
skip_injection { false }
|
355
|
+
end
|
295
356
|
slug { generate(:slug) }
|
296
|
-
title { generate_localized_title }
|
297
|
-
content {
|
298
|
-
organization { build(:organization) }
|
357
|
+
title { generate_localized_title(:static_page_title, skip_injection: skip_injection) }
|
358
|
+
content { generate_localized_description(:static_page_content, skip_injection: skip_injection) }
|
359
|
+
organization { build(:organization, skip_injection: skip_injection) }
|
299
360
|
allow_public_access { false }
|
300
361
|
|
301
362
|
trait :default do
|
@@ -311,8 +372,8 @@ FactoryBot.define do
|
|
311
372
|
end
|
312
373
|
|
313
374
|
trait :with_topic do
|
314
|
-
after(:create) do |static_page|
|
315
|
-
topic = create(:static_page_topic, organization: static_page.organization)
|
375
|
+
after(:create) do |static_page, evaluator|
|
376
|
+
topic = create(:static_page_topic, organization: static_page.organization, skip_injection: evaluator.skip_injection)
|
316
377
|
static_page.topic = topic
|
317
378
|
static_page.save
|
318
379
|
end
|
@@ -320,24 +381,33 @@ FactoryBot.define do
|
|
320
381
|
end
|
321
382
|
|
322
383
|
factory :static_page_topic, class: "Decidim::StaticPageTopic" do
|
323
|
-
|
324
|
-
|
384
|
+
transient do
|
385
|
+
skip_injection { false }
|
386
|
+
end
|
387
|
+
title { generate_localized_title(:static_page_topic_title, skip_injection: skip_injection) }
|
388
|
+
description { generate_localized_description(:static_page_topic_description, skip_injection: skip_injection) }
|
325
389
|
organization
|
326
390
|
end
|
327
391
|
|
328
392
|
factory :attachment_collection, class: "Decidim::AttachmentCollection" do
|
329
|
-
|
330
|
-
|
393
|
+
transient do
|
394
|
+
skip_injection { false }
|
395
|
+
end
|
396
|
+
name { generate_localized_title(:attachment_collection_name, skip_injection: skip_injection) }
|
397
|
+
description { generate_localized_title(:attachment_collection_description, skip_injection: skip_injection) }
|
331
398
|
weight { Faker::Number.number(digits: 1) }
|
332
399
|
|
333
400
|
association :collection_for, factory: :participatory_process
|
334
401
|
end
|
335
402
|
|
336
403
|
factory :attachment, class: "Decidim::Attachment" do
|
337
|
-
|
338
|
-
|
404
|
+
transient do
|
405
|
+
skip_injection { false }
|
406
|
+
end
|
407
|
+
title { generate_localized_title(:attachment_title, skip_injection: skip_injection) }
|
408
|
+
description { generate_localized_title(:attachment_description, skip_injection: skip_injection) }
|
339
409
|
weight { Faker::Number.number(digits: 1) }
|
340
|
-
attached_to { build(:participatory_process) }
|
410
|
+
attached_to { build(:participatory_process, skip_injection: skip_injection) }
|
341
411
|
content_type { "image/jpeg" }
|
342
412
|
file { Decidim::Dev.test_file("city.jpeg", "image/jpeg") } # Keep after attached_to
|
343
413
|
file_size { 108_908 }
|
@@ -355,23 +425,24 @@ FactoryBot.define do
|
|
355
425
|
|
356
426
|
factory :component, class: "Decidim::Component" do
|
357
427
|
transient do
|
358
|
-
|
428
|
+
skip_injection { false }
|
429
|
+
organization { create(:organization, skip_injection: skip_injection) }
|
359
430
|
end
|
360
431
|
|
361
|
-
name { generate_localized_title }
|
362
|
-
participatory_space { create(:participatory_process, organization: organization) }
|
432
|
+
name { generate_localized_title(:component_name, skip_injection: skip_injection) }
|
433
|
+
participatory_space { create(:participatory_process, organization: organization, skip_injection: skip_injection) }
|
363
434
|
manifest_name { "dummy" }
|
364
435
|
published_at { Time.current }
|
365
436
|
settings do
|
366
437
|
{
|
367
|
-
dummy_global_translatable_text: generate_localized_title,
|
438
|
+
dummy_global_translatable_text: generate_localized_title(:dummy_global_translatable_text, skip_injection: skip_injection),
|
368
439
|
comments_max_length: participatory_space.organization.comments_max_length || organization.comments_max_length
|
369
440
|
}
|
370
441
|
end
|
371
442
|
|
372
443
|
default_step_settings do
|
373
444
|
{
|
374
|
-
dummy_step_translatable_text: generate_localized_title
|
445
|
+
dummy_step_translatable_text: generate_localized_title(:dummy_step_translatable_text, skip_injection: skip_injection)
|
375
446
|
}
|
376
447
|
end
|
377
448
|
|
@@ -409,7 +480,8 @@ FactoryBot.define do
|
|
409
480
|
create(:participatory_process_step,
|
410
481
|
active: true,
|
411
482
|
end_date: 1.month.from_now,
|
412
|
-
participatory_process: participatory_space
|
483
|
+
participatory_process: participatory_space,
|
484
|
+
skip_injection: skip_injection)
|
413
485
|
participatory_space.reload
|
414
486
|
participatory_space.steps.reload
|
415
487
|
end
|
@@ -452,20 +524,29 @@ FactoryBot.define do
|
|
452
524
|
end
|
453
525
|
|
454
526
|
factory :scope_type, class: "Decidim::ScopeType" do
|
455
|
-
|
527
|
+
transient do
|
528
|
+
skip_injection { false }
|
529
|
+
end
|
530
|
+
name { generate_localized_word(:scope_type_name, skip_injection: skip_injection) }
|
456
531
|
plural { Decidim::Faker::Localized.literal(name.values.first.pluralize) }
|
457
532
|
organization
|
458
533
|
end
|
459
534
|
|
460
535
|
factory :scope, class: "Decidim::Scope" do
|
536
|
+
transient do
|
537
|
+
skip_injection { false }
|
538
|
+
end
|
461
539
|
name { Decidim::Faker::Localized.literal(generate(:scope_name)) }
|
462
540
|
code { generate(:scope_code) }
|
463
|
-
scope_type { create(:scope_type, organization: organization) }
|
464
|
-
organization { parent ? parent.organization : build(:organization) }
|
541
|
+
scope_type { create(:scope_type, organization: organization, skip_injection: skip_injection) }
|
542
|
+
organization { parent ? parent.organization : build(:organization, skip_injection: skip_injection) }
|
465
543
|
end
|
466
544
|
|
467
545
|
factory :subscope, parent: :scope do
|
468
|
-
|
546
|
+
transient do
|
547
|
+
skip_injection { false }
|
548
|
+
end
|
549
|
+
parent { build(:scope, skip_injection: skip_injection) }
|
469
550
|
|
470
551
|
before(:create) do |object|
|
471
552
|
object.parent.save unless object.parent.persisted?
|
@@ -473,84 +554,111 @@ FactoryBot.define do
|
|
473
554
|
end
|
474
555
|
|
475
556
|
factory :area_type, class: "Decidim::AreaType" do
|
476
|
-
|
557
|
+
transient do
|
558
|
+
skip_injection { false }
|
559
|
+
end
|
560
|
+
name { generate_localized_word(:area_type_name, skip_injection: skip_injection) }
|
477
561
|
plural { Decidim::Faker::Localized.literal(name.values.first.pluralize) }
|
478
562
|
organization
|
479
563
|
end
|
480
564
|
|
481
565
|
factory :area, class: "Decidim::Area" do
|
566
|
+
transient do
|
567
|
+
skip_injection { false }
|
568
|
+
end
|
482
569
|
name { Decidim::Faker::Localized.literal(generate(:area_name)) }
|
483
570
|
organization
|
484
571
|
end
|
485
572
|
|
486
573
|
factory :coauthorship, class: "Decidim::Coauthorship" do
|
487
|
-
|
574
|
+
transient do
|
575
|
+
skip_injection { false }
|
576
|
+
end
|
577
|
+
coauthorable { create(:dummy_resource, skip_injection: skip_injection) }
|
488
578
|
transient do
|
489
579
|
organization { coauthorable.component.participatory_space.organization }
|
490
580
|
end
|
491
|
-
author { create(:user, :confirmed, organization: organization) }
|
581
|
+
author { create(:user, :confirmed, organization: organization, skip_injection: skip_injection) }
|
492
582
|
end
|
493
583
|
|
494
584
|
factory :dummy_resource, class: "Decidim::DummyResources::DummyResource" do
|
495
585
|
transient do
|
586
|
+
skip_injection { false }
|
496
587
|
users { nil }
|
497
588
|
# user_groups correspondence to users is by sorting order
|
498
589
|
user_groups { [] }
|
499
590
|
end
|
500
|
-
title {
|
501
|
-
component { create(:
|
502
|
-
author { create(:user, :confirmed, organization: component.organization) }
|
503
|
-
scope { create(:scope, organization: component.organization) }
|
591
|
+
title { generate_localized_title(:dummy_resource_title, skip_injection: skip_injection) }
|
592
|
+
component { create(:dummy_component, skip_injection: skip_injection) }
|
593
|
+
author { create(:user, :confirmed, organization: component.organization, skip_injection: skip_injection) }
|
594
|
+
scope { create(:scope, organization: component.organization, skip_injection: skip_injection) }
|
504
595
|
|
505
596
|
trait :published do
|
506
597
|
published_at { Time.current }
|
507
598
|
end
|
508
599
|
|
509
600
|
trait :with_endorsements do
|
510
|
-
after :create do |resource|
|
601
|
+
after :create do |resource, evaluator|
|
511
602
|
5.times.collect do
|
512
|
-
create(:endorsement, resource: resource,
|
603
|
+
create(:endorsement, resource: resource, skip_injection: evaluator.skip_injection,
|
604
|
+
author: build(:user, organization: resource.component.organization, skip_injection: evaluator.skip_injection))
|
513
605
|
end
|
514
606
|
end
|
515
607
|
end
|
608
|
+
|
609
|
+
trait :moderated do
|
610
|
+
after(:create) do |resource, evaluator|
|
611
|
+
create(:moderation, reportable: resource, hidden_at: 2.days.ago, skip_injection: evaluator.skip_injection)
|
612
|
+
end
|
613
|
+
end
|
516
614
|
end
|
517
615
|
|
518
616
|
factory :nested_dummy_resource, class: "Decidim::DummyResources::NestedDummyResource" do
|
617
|
+
transient do
|
618
|
+
skip_injection { false }
|
619
|
+
end
|
519
620
|
title { generate(:name) }
|
520
|
-
dummy_resource { create(:dummy_resource) }
|
621
|
+
dummy_resource { create(:dummy_resource, skip_injection: skip_injection) }
|
521
622
|
end
|
522
623
|
|
523
624
|
factory :coauthorable_dummy_resource, class: "Decidim::DummyResources::CoauthorableDummyResource" do
|
524
|
-
title { generate(:name) }
|
525
|
-
component { create(:component, manifest_name: "dummy") }
|
526
|
-
|
527
625
|
transient do
|
528
|
-
|
626
|
+
skip_injection { false }
|
627
|
+
|
628
|
+
authors_list { [create(:user, organization: component.organization, skip_injection: skip_injection)] }
|
529
629
|
end
|
630
|
+
title { generate(:name) }
|
631
|
+
component { create(:component, manifest_name: "dummy", skip_injection: skip_injection) }
|
530
632
|
|
531
633
|
after :build do |resource, evaluator|
|
532
634
|
evaluator.authors_list.each do |coauthor|
|
533
635
|
resource.coauthorships << if coauthor.is_a?(::Decidim::UserGroup)
|
534
|
-
build(:coauthorship, author: coauthor.users.first, user_group: coauthor, coauthorable: resource,
|
636
|
+
build(:coauthorship, author: coauthor.users.first, user_group: coauthor, coauthorable: resource,
|
637
|
+
organization: evaluator.component.organization, skip_injection: evaluator.skip_injection)
|
535
638
|
else
|
536
|
-
build(:coauthorship, author: coauthor, coauthorable: resource,
|
639
|
+
build(:coauthorship, author: coauthor, coauthorable: resource,
|
640
|
+
organization: evaluator.component.organization, skip_injection: evaluator.skip_injection)
|
537
641
|
end
|
538
642
|
end
|
539
643
|
end
|
540
644
|
end
|
541
645
|
|
542
646
|
factory :resource_link, class: "Decidim::ResourceLink" do
|
647
|
+
transient do
|
648
|
+
skip_injection { false }
|
649
|
+
end
|
543
650
|
name { generate(:slug) }
|
544
|
-
to { build(:dummy_resource) }
|
545
|
-
from { build(:dummy_resource, component: to.component) }
|
651
|
+
to { build(:dummy_resource, skip_injection: skip_injection) }
|
652
|
+
from { build(:dummy_resource, component: to.component, skip_injection: skip_injection) }
|
546
653
|
end
|
547
654
|
|
548
655
|
factory :newsletter, class: "Decidim::Newsletter" do
|
549
656
|
transient do
|
550
|
-
|
657
|
+
skip_injection { false }
|
658
|
+
body { generate_localized_description(:newsletter_body, skip_injection: skip_injection) }
|
551
659
|
end
|
552
660
|
|
553
|
-
author { build(:user, :confirmed, organization: organization) }
|
661
|
+
author { build(:user, :confirmed, organization: organization, skip_injection: skip_injection) }
|
554
662
|
organization
|
555
663
|
|
556
664
|
subject { generate_localized_title }
|
@@ -562,7 +670,8 @@ FactoryBot.define do
|
|
562
670
|
organization: evaluator.organization,
|
563
671
|
scoped_resource_id: newsletter.id,
|
564
672
|
manifest_name: "basic_only_text",
|
565
|
-
settings: evaluator.body.transform_keys { |key| "body_#{key}" }
|
673
|
+
settings: evaluator.body.transform_keys { |key| "body_#{key}" },
|
674
|
+
skip_injection: evaluator.skip_injection
|
566
675
|
)
|
567
676
|
end
|
568
677
|
|
@@ -572,7 +681,10 @@ FactoryBot.define do
|
|
572
681
|
end
|
573
682
|
|
574
683
|
factory :moderation, class: "Decidim::Moderation" do
|
575
|
-
|
684
|
+
transient do
|
685
|
+
skip_injection { false }
|
686
|
+
end
|
687
|
+
reportable { build(:dummy_resource, skip_injection: skip_injection) }
|
576
688
|
participatory_space { reportable.component.participatory_space }
|
577
689
|
|
578
690
|
trait :hidden do
|
@@ -581,35 +693,47 @@ FactoryBot.define do
|
|
581
693
|
end
|
582
694
|
|
583
695
|
factory :report, class: "Decidim::Report" do
|
696
|
+
transient do
|
697
|
+
skip_injection { false }
|
698
|
+
end
|
584
699
|
moderation
|
585
|
-
user { build(:user, organization: moderation.reportable.organization) }
|
700
|
+
user { build(:user, organization: moderation.reportable.organization, skip_injection: skip_injection) }
|
586
701
|
reason { "spam" }
|
587
702
|
end
|
588
703
|
|
589
704
|
factory :impersonation_log, class: "Decidim::ImpersonationLog" do
|
590
|
-
|
591
|
-
|
705
|
+
transient do
|
706
|
+
skip_injection { false }
|
707
|
+
end
|
708
|
+
admin { build(:user, :admin, skip_injection: skip_injection) }
|
709
|
+
user { build(:user, :managed, organization: admin.organization, skip_injection: skip_injection) }
|
592
710
|
started_at { 10.minutes.ago }
|
593
711
|
end
|
594
712
|
|
595
713
|
factory :follow, class: "Decidim::Follow" do
|
714
|
+
transient do
|
715
|
+
skip_injection { false }
|
716
|
+
end
|
596
717
|
user do
|
597
718
|
build(
|
598
719
|
:user,
|
599
|
-
organization: followable.try(:organization) || build(:organization)
|
720
|
+
organization: followable.try(:organization) || build(:organization, skip_injection: skip_injection)
|
600
721
|
)
|
601
722
|
end
|
602
|
-
followable { build(:dummy_resource) }
|
723
|
+
followable { build(:dummy_resource, skip_injection: skip_injection) }
|
603
724
|
end
|
604
725
|
|
605
726
|
factory :notification, class: "Decidim::Notification" do
|
727
|
+
transient do
|
728
|
+
skip_injection { false }
|
729
|
+
end
|
606
730
|
user do
|
607
731
|
build(
|
608
732
|
:user,
|
609
|
-
organization: resource.try(:organization) || build(:organization)
|
733
|
+
organization: resource.try(:organization) || build(:organization, skip_injection: skip_injection)
|
610
734
|
)
|
611
735
|
end
|
612
|
-
resource { build(:dummy_resource) }
|
736
|
+
resource { build(:dummy_resource, skip_injection: skip_injection) }
|
613
737
|
event_name { resource.class.name.underscore.tr("/", ".") }
|
614
738
|
event_class { "Decidim::DummyResourceEvent" }
|
615
739
|
extra do
|
@@ -619,16 +743,60 @@ FactoryBot.define do
|
|
619
743
|
end
|
620
744
|
end
|
621
745
|
|
746
|
+
factory :conversation, class: "Decidim::Messaging::Conversation" do
|
747
|
+
transient do
|
748
|
+
skip_injection { false }
|
749
|
+
end
|
750
|
+
|
751
|
+
originator { build(:user) }
|
752
|
+
interlocutors { [build(:user)] }
|
753
|
+
body { Faker::Lorem.sentence }
|
754
|
+
user
|
755
|
+
|
756
|
+
after(:create) do |object|
|
757
|
+
object.participants ||= [originator + interlocutors].flatten
|
758
|
+
end
|
759
|
+
|
760
|
+
initialize_with { Decidim::Messaging::Conversation.start(originator: originator, interlocutors: interlocutors, body: body, user: user) }
|
761
|
+
end
|
762
|
+
|
763
|
+
factory :message, class: "Decidim::Messaging::Message" do
|
764
|
+
transient do
|
765
|
+
skip_injection { false }
|
766
|
+
end
|
767
|
+
|
768
|
+
body { generate_localized_description(:message_body) }
|
769
|
+
conversation
|
770
|
+
|
771
|
+
before(:create) do |object|
|
772
|
+
object.sender ||= object.conversation.participants.take
|
773
|
+
end
|
774
|
+
end
|
775
|
+
|
776
|
+
factory :push_notification_message, class: "Decidim::PushNotificationMessage" do
|
777
|
+
transient do
|
778
|
+
skip_injection { false }
|
779
|
+
end
|
780
|
+
|
781
|
+
recipient { build(:user) }
|
782
|
+
conversation { create(:conversation) }
|
783
|
+
message { generate_localized_description(:push_notification_message_message) }
|
784
|
+
|
785
|
+
skip_create
|
786
|
+
initialize_with { Decidim::PushNotificationMessage.new(recipient: recipient, conversation: conversation, message: message) }
|
787
|
+
end
|
788
|
+
|
622
789
|
factory :action_log, class: "Decidim::ActionLog" do
|
623
790
|
transient do
|
791
|
+
skip_injection { false }
|
624
792
|
extra_data { {} }
|
625
793
|
end
|
626
794
|
|
627
795
|
organization { user.organization }
|
628
796
|
user
|
629
|
-
participatory_space { build
|
630
|
-
component { build
|
631
|
-
resource { build(:dummy_resource, component: component) }
|
797
|
+
participatory_space { build(:participatory_process, organization: organization, skip_injection: skip_injection) }
|
798
|
+
component { build(:component, participatory_space: participatory_space, skip_injection: skip_injection) }
|
799
|
+
resource { build(:dummy_resource, component: component, skip_injection: skip_injection) }
|
632
800
|
action { "create" }
|
633
801
|
visibility { "admin-only" }
|
634
802
|
extra do
|
@@ -654,6 +822,9 @@ FactoryBot.define do
|
|
654
822
|
end
|
655
823
|
|
656
824
|
factory :oauth_application, class: "Decidim::OAuthApplication" do
|
825
|
+
transient do
|
826
|
+
skip_injection { false }
|
827
|
+
end
|
657
828
|
organization
|
658
829
|
sequence(:name) { |n| "OAuth application #{n}" }
|
659
830
|
sequence(:organization_name) { |n| "OAuth application owner #{n}" }
|
@@ -664,8 +835,11 @@ FactoryBot.define do
|
|
664
835
|
end
|
665
836
|
|
666
837
|
factory :oauth_access_token, class: "Doorkeeper::AccessToken" do
|
667
|
-
|
668
|
-
|
838
|
+
transient do
|
839
|
+
skip_injection { false }
|
840
|
+
end
|
841
|
+
resource_owner_id { create(:user, organization: application.organization, skip_injection: skip_injection).id }
|
842
|
+
application { build(:oauth_application, skip_injection: skip_injection) }
|
669
843
|
token { SecureRandom.hex(32) }
|
670
844
|
expires_in { 1.month.from_now }
|
671
845
|
created_at { Time.current }
|
@@ -673,7 +847,10 @@ FactoryBot.define do
|
|
673
847
|
end
|
674
848
|
|
675
849
|
factory :searchable_resource, class: "Decidim::SearchableResource" do
|
676
|
-
|
850
|
+
transient do
|
851
|
+
skip_injection { false }
|
852
|
+
end
|
853
|
+
resource { build(:dummy_resource, skip_injection: skip_injection) }
|
677
854
|
resource_id { resource.id }
|
678
855
|
resource_type { resource.class.name }
|
679
856
|
organization { resource.component.organization }
|
@@ -685,6 +862,9 @@ FactoryBot.define do
|
|
685
862
|
end
|
686
863
|
|
687
864
|
factory :content_block, class: "Decidim::ContentBlock" do
|
865
|
+
transient do
|
866
|
+
skip_injection { false }
|
867
|
+
end
|
688
868
|
organization
|
689
869
|
scope_name { :homepage }
|
690
870
|
manifest_name { :hero }
|
@@ -698,24 +878,33 @@ FactoryBot.define do
|
|
698
878
|
end
|
699
879
|
|
700
880
|
factory :hashtag, class: "Decidim::Hashtag" do
|
881
|
+
transient do
|
882
|
+
skip_injection { false }
|
883
|
+
end
|
701
884
|
name { generate(:hashtag_name) }
|
702
885
|
organization
|
703
886
|
end
|
704
887
|
|
705
888
|
factory :metric, class: "Decidim::Metric" do
|
889
|
+
transient do
|
890
|
+
skip_injection { false }
|
891
|
+
end
|
706
892
|
organization
|
707
893
|
day { Time.zone.today }
|
708
894
|
metric_type { "random_metric" }
|
709
895
|
cumulative { 2 }
|
710
896
|
quantity { 1 }
|
711
897
|
category { create :category }
|
712
|
-
participatory_space { create
|
713
|
-
related_object { create
|
898
|
+
participatory_space { create(:participatory_process, organization: organization, skip_injection: skip_injection) }
|
899
|
+
related_object { create(:component, participatory_space: participatory_space, skip_injection: skip_injection) }
|
714
900
|
end
|
715
901
|
|
716
902
|
factory :amendment, class: "Decidim::Amendment" do
|
717
|
-
|
718
|
-
|
903
|
+
transient do
|
904
|
+
skip_injection { false }
|
905
|
+
end
|
906
|
+
amendable { build(:dummy_resource, skip_injection: skip_injection) }
|
907
|
+
emendation { build(:dummy_resource, skip_injection: skip_injection) }
|
719
908
|
amender { emendation.try(:creator_author) || emendation.try(:author) }
|
720
909
|
state { "evaluating" }
|
721
910
|
|
@@ -729,29 +918,44 @@ FactoryBot.define do
|
|
729
918
|
end
|
730
919
|
|
731
920
|
factory :user_report, class: "Decidim::UserReport" do
|
921
|
+
transient do
|
922
|
+
skip_injection { false }
|
923
|
+
end
|
732
924
|
reason { "spam" }
|
733
|
-
moderation { create(:user_moderation, user: user) }
|
925
|
+
moderation { create(:user_moderation, user: user, skip_injection: skip_injection) }
|
734
926
|
user { build(:user) }
|
735
927
|
end
|
736
928
|
|
737
929
|
factory :user_moderation, class: "Decidim::UserModeration" do
|
738
|
-
|
930
|
+
transient do
|
931
|
+
skip_injection { false }
|
932
|
+
end
|
933
|
+
user { build(:user, skip_injection: skip_injection) }
|
739
934
|
end
|
740
935
|
|
741
936
|
factory :endorsement, class: "Decidim::Endorsement" do
|
742
|
-
|
743
|
-
|
937
|
+
transient do
|
938
|
+
skip_injection { false }
|
939
|
+
end
|
940
|
+
resource { build(:dummy_resource, skip_injection: skip_injection) }
|
941
|
+
author { resource.try(:creator_author) || resource.try(:author) || build(:user, organization: resource.organization, skip_injection: skip_injection) }
|
744
942
|
end
|
745
943
|
|
746
944
|
factory :user_group_endorsement, class: "Decidim::Endorsement" do
|
747
|
-
|
748
|
-
|
749
|
-
|
945
|
+
transient do
|
946
|
+
skip_injection { false }
|
947
|
+
end
|
948
|
+
resource { build(:dummy_resource, skip_injection: skip_injection) }
|
949
|
+
author { build(:user, organization: resource.organization, skip_injection: skip_injection) }
|
950
|
+
user_group { create(:user_group, verified_at: Time.current, organization: resource.organization, users: [author], skip_injection: skip_injection) }
|
750
951
|
end
|
751
952
|
|
752
953
|
factory :share_token, class: "Decidim::ShareToken" do
|
753
|
-
|
754
|
-
|
954
|
+
transient do
|
955
|
+
skip_injection { false }
|
956
|
+
end
|
957
|
+
token_for { build(:component, skip_injection: skip_injection) }
|
958
|
+
user { build(:user, organization: token_for.organization, skip_injection: skip_injection) }
|
755
959
|
|
756
960
|
before(:create) do |object|
|
757
961
|
object.organization ||= object.token_for.organization
|
@@ -768,33 +972,48 @@ FactoryBot.define do
|
|
768
972
|
end
|
769
973
|
|
770
974
|
factory :editor_image, class: "Decidim::EditorImage" do
|
975
|
+
transient do
|
976
|
+
skip_injection { false }
|
977
|
+
end
|
771
978
|
organization
|
772
|
-
author { create(:user, :admin, :confirmed, organization: organization) }
|
979
|
+
author { create(:user, :admin, :confirmed, organization: organization, skip_injection: skip_injection) }
|
773
980
|
file { Decidim::Dev.test_file("city.jpeg", "image/jpeg") }
|
774
981
|
end
|
775
982
|
|
776
983
|
factory :reminder, class: "Decidim::Reminder" do
|
777
|
-
|
778
|
-
|
984
|
+
transient do
|
985
|
+
skip_injection { false }
|
986
|
+
end
|
987
|
+
user { build(:user, skip_injection: skip_injection) }
|
988
|
+
component { build(:dummy_component, organization: user.organization, skip_injection: skip_injection) }
|
779
989
|
end
|
780
990
|
|
781
991
|
factory :reminder_record, class: "Decidim::ReminderRecord" do
|
782
|
-
|
783
|
-
|
992
|
+
transient do
|
993
|
+
skip_injection { false }
|
994
|
+
end
|
995
|
+
reminder { create(:reminder, skip_injection: skip_injection) }
|
996
|
+
remindable { build(:dummy_resource, skip_injection: skip_injection) }
|
784
997
|
end
|
785
998
|
|
786
999
|
factory :reminder_delivery, class: "Decidim::ReminderDelivery" do
|
787
|
-
|
1000
|
+
transient do
|
1001
|
+
skip_injection { false }
|
1002
|
+
end
|
1003
|
+
reminder { create(:reminder, skip_injection: skip_injection) }
|
788
1004
|
end
|
789
1005
|
|
790
1006
|
factory :short_link, class: "Decidim::ShortLink" do
|
791
|
-
|
1007
|
+
transient do
|
1008
|
+
skip_injection { false }
|
1009
|
+
end
|
1010
|
+
target { create(:component, manifest_name: "dummy", skip_injection: skip_injection) }
|
792
1011
|
route_name { nil }
|
793
1012
|
params { {} }
|
794
1013
|
|
795
|
-
before(:create) do |object|
|
1014
|
+
before(:create) do |object, evaluator|
|
796
1015
|
object.organization ||= object.target if object.target.is_a?(Decidim::Organization)
|
797
|
-
object.organization ||= object.target.try(:organization) || create(:organization)
|
1016
|
+
object.organization ||= object.target.try(:organization) || create(:organization, skip_injection: evaluator.skip_injection)
|
798
1017
|
object.identifier ||= Decidim::ShortLink.unique_identifier_within(object.organization)
|
799
1018
|
object.mounted_engine_name ||=
|
800
1019
|
if object.target.respond_to?(:participatory_space)
|