decidim-core 0.27.5 → 0.27.6
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/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/paginable.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/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/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/notification_to_mailer_presenter.rb +9 -0
- data/app/services/decidim/events_manager.rb +6 -0
- 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/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 -2
- data/config/locales/bg.yml +74 -0
- data/config/locales/ca.yml +22 -22
- data/config/locales/de.yml +25 -25
- data/config/locales/el.yml +1 -3
- data/config/locales/es-MX.yml +1 -1
- data/config/locales/es-PY.yml +1 -1
- data/config/locales/es.yml +20 -20
- data/config/locales/eu.yml +11 -2
- data/config/locales/fi.yml +3 -3
- data/config/locales/fr-CA.yml +2 -2
- data/config/locales/fr.yml +2 -2
- data/config/locales/gl.yml +3 -0
- data/config/locales/he-IL.yml +1 -0
- data/config/locales/hu.yml +41 -8
- data/config/locales/it.yml +1 -3
- data/config/locales/ja.yml +3 -2
- data/config/locales/lb.yml +1 -3
- data/config/locales/lt.yml +0 -3
- data/config/locales/no.yml +1 -3
- data/config/locales/pl.yml +137 -1
- data/config/locales/pt-BR.yml +113 -21
- data/config/locales/pt.yml +1 -3
- data/config/locales/ro-RO.yml +0 -3
- data/config/locales/ru.yml +9 -0
- data/config/locales/sk.yml +2 -0
- data/config/locales/sv.yml +22 -2
- data/config/locales/tr-TR.yml +1 -3
- data/config/locales/uk.yml +14 -0
- data/config/locales/zh-CN.yml +0 -3
- data/config/locales/zh-TW.yml +0 -3
- 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 +308 -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 +5 -2
- data/lib/decidim/events/simple_event.rb +3 -17
- data/lib/decidim/has_category.rb +1 -1
- data/lib/decidim/has_conversations.rb +91 -0
- 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 +31 -30
- 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,105 @@ 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
|
516
608
|
end
|
517
609
|
|
518
610
|
factory :nested_dummy_resource, class: "Decidim::DummyResources::NestedDummyResource" do
|
611
|
+
transient do
|
612
|
+
skip_injection { false }
|
613
|
+
end
|
519
614
|
title { generate(:name) }
|
520
|
-
dummy_resource { create(:dummy_resource) }
|
615
|
+
dummy_resource { create(:dummy_resource, skip_injection: skip_injection) }
|
521
616
|
end
|
522
617
|
|
523
618
|
factory :coauthorable_dummy_resource, class: "Decidim::DummyResources::CoauthorableDummyResource" do
|
524
|
-
title { generate(:name) }
|
525
|
-
component { create(:component, manifest_name: "dummy") }
|
526
|
-
|
527
619
|
transient do
|
528
|
-
|
620
|
+
skip_injection { false }
|
621
|
+
|
622
|
+
authors_list { [create(:user, organization: component.organization, skip_injection: skip_injection)] }
|
529
623
|
end
|
624
|
+
title { generate(:name) }
|
625
|
+
component { create(:component, manifest_name: "dummy", skip_injection: skip_injection) }
|
530
626
|
|
531
627
|
after :build do |resource, evaluator|
|
532
628
|
evaluator.authors_list.each do |coauthor|
|
533
629
|
resource.coauthorships << if coauthor.is_a?(::Decidim::UserGroup)
|
534
|
-
build(:coauthorship, author: coauthor.users.first, user_group: coauthor, coauthorable: resource,
|
630
|
+
build(:coauthorship, author: coauthor.users.first, user_group: coauthor, coauthorable: resource,
|
631
|
+
organization: evaluator.component.organization, skip_injection: evaluator.skip_injection)
|
535
632
|
else
|
536
|
-
build(:coauthorship, author: coauthor, coauthorable: resource,
|
633
|
+
build(:coauthorship, author: coauthor, coauthorable: resource,
|
634
|
+
organization: evaluator.component.organization, skip_injection: evaluator.skip_injection)
|
537
635
|
end
|
538
636
|
end
|
539
637
|
end
|
540
638
|
end
|
541
639
|
|
542
640
|
factory :resource_link, class: "Decidim::ResourceLink" do
|
641
|
+
transient do
|
642
|
+
skip_injection { false }
|
643
|
+
end
|
543
644
|
name { generate(:slug) }
|
544
|
-
to { build(:dummy_resource) }
|
545
|
-
from { build(:dummy_resource, component: to.component) }
|
645
|
+
to { build(:dummy_resource, skip_injection: skip_injection) }
|
646
|
+
from { build(:dummy_resource, component: to.component, skip_injection: skip_injection) }
|
546
647
|
end
|
547
648
|
|
548
649
|
factory :newsletter, class: "Decidim::Newsletter" do
|
549
650
|
transient do
|
550
|
-
|
651
|
+
skip_injection { false }
|
652
|
+
body { generate_localized_description(:newsletter_body, skip_injection: skip_injection) }
|
551
653
|
end
|
552
654
|
|
553
|
-
author { build(:user, :confirmed, organization: organization) }
|
655
|
+
author { build(:user, :confirmed, organization: organization, skip_injection: skip_injection) }
|
554
656
|
organization
|
555
657
|
|
556
658
|
subject { generate_localized_title }
|
@@ -562,7 +664,8 @@ FactoryBot.define do
|
|
562
664
|
organization: evaluator.organization,
|
563
665
|
scoped_resource_id: newsletter.id,
|
564
666
|
manifest_name: "basic_only_text",
|
565
|
-
settings: evaluator.body.transform_keys { |key| "body_#{key}" }
|
667
|
+
settings: evaluator.body.transform_keys { |key| "body_#{key}" },
|
668
|
+
skip_injection: evaluator.skip_injection
|
566
669
|
)
|
567
670
|
end
|
568
671
|
|
@@ -572,7 +675,10 @@ FactoryBot.define do
|
|
572
675
|
end
|
573
676
|
|
574
677
|
factory :moderation, class: "Decidim::Moderation" do
|
575
|
-
|
678
|
+
transient do
|
679
|
+
skip_injection { false }
|
680
|
+
end
|
681
|
+
reportable { build(:dummy_resource, skip_injection: skip_injection) }
|
576
682
|
participatory_space { reportable.component.participatory_space }
|
577
683
|
|
578
684
|
trait :hidden do
|
@@ -581,35 +687,47 @@ FactoryBot.define do
|
|
581
687
|
end
|
582
688
|
|
583
689
|
factory :report, class: "Decidim::Report" do
|
690
|
+
transient do
|
691
|
+
skip_injection { false }
|
692
|
+
end
|
584
693
|
moderation
|
585
|
-
user { build(:user, organization: moderation.reportable.organization) }
|
694
|
+
user { build(:user, organization: moderation.reportable.organization, skip_injection: skip_injection) }
|
586
695
|
reason { "spam" }
|
587
696
|
end
|
588
697
|
|
589
698
|
factory :impersonation_log, class: "Decidim::ImpersonationLog" do
|
590
|
-
|
591
|
-
|
699
|
+
transient do
|
700
|
+
skip_injection { false }
|
701
|
+
end
|
702
|
+
admin { build(:user, :admin, skip_injection: skip_injection) }
|
703
|
+
user { build(:user, :managed, organization: admin.organization, skip_injection: skip_injection) }
|
592
704
|
started_at { 10.minutes.ago }
|
593
705
|
end
|
594
706
|
|
595
707
|
factory :follow, class: "Decidim::Follow" do
|
708
|
+
transient do
|
709
|
+
skip_injection { false }
|
710
|
+
end
|
596
711
|
user do
|
597
712
|
build(
|
598
713
|
:user,
|
599
|
-
organization: followable.try(:organization) || build(:organization)
|
714
|
+
organization: followable.try(:organization) || build(:organization, skip_injection: skip_injection)
|
600
715
|
)
|
601
716
|
end
|
602
|
-
followable { build(:dummy_resource) }
|
717
|
+
followable { build(:dummy_resource, skip_injection: skip_injection) }
|
603
718
|
end
|
604
719
|
|
605
720
|
factory :notification, class: "Decidim::Notification" do
|
721
|
+
transient do
|
722
|
+
skip_injection { false }
|
723
|
+
end
|
606
724
|
user do
|
607
725
|
build(
|
608
726
|
:user,
|
609
|
-
organization: resource.try(:organization) || build(:organization)
|
727
|
+
organization: resource.try(:organization) || build(:organization, skip_injection: skip_injection)
|
610
728
|
)
|
611
729
|
end
|
612
|
-
resource { build(:dummy_resource) }
|
730
|
+
resource { build(:dummy_resource, skip_injection: skip_injection) }
|
613
731
|
event_name { resource.class.name.underscore.tr("/", ".") }
|
614
732
|
event_class { "Decidim::DummyResourceEvent" }
|
615
733
|
extra do
|
@@ -619,16 +737,60 @@ FactoryBot.define do
|
|
619
737
|
end
|
620
738
|
end
|
621
739
|
|
740
|
+
factory :conversation, class: "Decidim::Messaging::Conversation" do
|
741
|
+
transient do
|
742
|
+
skip_injection { false }
|
743
|
+
end
|
744
|
+
|
745
|
+
originator { build(:user) }
|
746
|
+
interlocutors { [build(:user)] }
|
747
|
+
body { Faker::Lorem.sentence }
|
748
|
+
user
|
749
|
+
|
750
|
+
after(:create) do |object|
|
751
|
+
object.participants ||= [originator + interlocutors].flatten
|
752
|
+
end
|
753
|
+
|
754
|
+
initialize_with { Decidim::Messaging::Conversation.start(originator: originator, interlocutors: interlocutors, body: body, user: user) }
|
755
|
+
end
|
756
|
+
|
757
|
+
factory :message, class: "Decidim::Messaging::Message" do
|
758
|
+
transient do
|
759
|
+
skip_injection { false }
|
760
|
+
end
|
761
|
+
|
762
|
+
body { generate_localized_description(:message_body) }
|
763
|
+
conversation
|
764
|
+
|
765
|
+
before(:create) do |object|
|
766
|
+
object.sender ||= object.conversation.participants.take
|
767
|
+
end
|
768
|
+
end
|
769
|
+
|
770
|
+
factory :push_notification_message, class: "Decidim::PushNotificationMessage" do
|
771
|
+
transient do
|
772
|
+
skip_injection { false }
|
773
|
+
end
|
774
|
+
|
775
|
+
recipient { build(:user) }
|
776
|
+
conversation { create(:conversation) }
|
777
|
+
message { generate_localized_description(:push_notification_message_message) }
|
778
|
+
|
779
|
+
skip_create
|
780
|
+
initialize_with { Decidim::PushNotificationMessage.new(recipient: recipient, conversation: conversation, message: message) }
|
781
|
+
end
|
782
|
+
|
622
783
|
factory :action_log, class: "Decidim::ActionLog" do
|
623
784
|
transient do
|
785
|
+
skip_injection { false }
|
624
786
|
extra_data { {} }
|
625
787
|
end
|
626
788
|
|
627
789
|
organization { user.organization }
|
628
790
|
user
|
629
|
-
participatory_space { build
|
630
|
-
component { build
|
631
|
-
resource { build(:dummy_resource, component: component) }
|
791
|
+
participatory_space { build(:participatory_process, organization: organization, skip_injection: skip_injection) }
|
792
|
+
component { build(:component, participatory_space: participatory_space, skip_injection: skip_injection) }
|
793
|
+
resource { build(:dummy_resource, component: component, skip_injection: skip_injection) }
|
632
794
|
action { "create" }
|
633
795
|
visibility { "admin-only" }
|
634
796
|
extra do
|
@@ -654,6 +816,9 @@ FactoryBot.define do
|
|
654
816
|
end
|
655
817
|
|
656
818
|
factory :oauth_application, class: "Decidim::OAuthApplication" do
|
819
|
+
transient do
|
820
|
+
skip_injection { false }
|
821
|
+
end
|
657
822
|
organization
|
658
823
|
sequence(:name) { |n| "OAuth application #{n}" }
|
659
824
|
sequence(:organization_name) { |n| "OAuth application owner #{n}" }
|
@@ -664,8 +829,11 @@ FactoryBot.define do
|
|
664
829
|
end
|
665
830
|
|
666
831
|
factory :oauth_access_token, class: "Doorkeeper::AccessToken" do
|
667
|
-
|
668
|
-
|
832
|
+
transient do
|
833
|
+
skip_injection { false }
|
834
|
+
end
|
835
|
+
resource_owner_id { create(:user, organization: application.organization, skip_injection: skip_injection).id }
|
836
|
+
application { build(:oauth_application, skip_injection: skip_injection) }
|
669
837
|
token { SecureRandom.hex(32) }
|
670
838
|
expires_in { 1.month.from_now }
|
671
839
|
created_at { Time.current }
|
@@ -673,7 +841,10 @@ FactoryBot.define do
|
|
673
841
|
end
|
674
842
|
|
675
843
|
factory :searchable_resource, class: "Decidim::SearchableResource" do
|
676
|
-
|
844
|
+
transient do
|
845
|
+
skip_injection { false }
|
846
|
+
end
|
847
|
+
resource { build(:dummy_resource, skip_injection: skip_injection) }
|
677
848
|
resource_id { resource.id }
|
678
849
|
resource_type { resource.class.name }
|
679
850
|
organization { resource.component.organization }
|
@@ -685,6 +856,9 @@ FactoryBot.define do
|
|
685
856
|
end
|
686
857
|
|
687
858
|
factory :content_block, class: "Decidim::ContentBlock" do
|
859
|
+
transient do
|
860
|
+
skip_injection { false }
|
861
|
+
end
|
688
862
|
organization
|
689
863
|
scope_name { :homepage }
|
690
864
|
manifest_name { :hero }
|
@@ -698,24 +872,33 @@ FactoryBot.define do
|
|
698
872
|
end
|
699
873
|
|
700
874
|
factory :hashtag, class: "Decidim::Hashtag" do
|
875
|
+
transient do
|
876
|
+
skip_injection { false }
|
877
|
+
end
|
701
878
|
name { generate(:hashtag_name) }
|
702
879
|
organization
|
703
880
|
end
|
704
881
|
|
705
882
|
factory :metric, class: "Decidim::Metric" do
|
883
|
+
transient do
|
884
|
+
skip_injection { false }
|
885
|
+
end
|
706
886
|
organization
|
707
887
|
day { Time.zone.today }
|
708
888
|
metric_type { "random_metric" }
|
709
889
|
cumulative { 2 }
|
710
890
|
quantity { 1 }
|
711
891
|
category { create :category }
|
712
|
-
participatory_space { create
|
713
|
-
related_object { create
|
892
|
+
participatory_space { create(:participatory_process, organization: organization, skip_injection: skip_injection) }
|
893
|
+
related_object { create(:component, participatory_space: participatory_space, skip_injection: skip_injection) }
|
714
894
|
end
|
715
895
|
|
716
896
|
factory :amendment, class: "Decidim::Amendment" do
|
717
|
-
|
718
|
-
|
897
|
+
transient do
|
898
|
+
skip_injection { false }
|
899
|
+
end
|
900
|
+
amendable { build(:dummy_resource, skip_injection: skip_injection) }
|
901
|
+
emendation { build(:dummy_resource, skip_injection: skip_injection) }
|
719
902
|
amender { emendation.try(:creator_author) || emendation.try(:author) }
|
720
903
|
state { "evaluating" }
|
721
904
|
|
@@ -729,29 +912,44 @@ FactoryBot.define do
|
|
729
912
|
end
|
730
913
|
|
731
914
|
factory :user_report, class: "Decidim::UserReport" do
|
915
|
+
transient do
|
916
|
+
skip_injection { false }
|
917
|
+
end
|
732
918
|
reason { "spam" }
|
733
|
-
moderation { create(:user_moderation, user: user) }
|
919
|
+
moderation { create(:user_moderation, user: user, skip_injection: skip_injection) }
|
734
920
|
user { build(:user) }
|
735
921
|
end
|
736
922
|
|
737
923
|
factory :user_moderation, class: "Decidim::UserModeration" do
|
738
|
-
|
924
|
+
transient do
|
925
|
+
skip_injection { false }
|
926
|
+
end
|
927
|
+
user { build(:user, skip_injection: skip_injection) }
|
739
928
|
end
|
740
929
|
|
741
930
|
factory :endorsement, class: "Decidim::Endorsement" do
|
742
|
-
|
743
|
-
|
931
|
+
transient do
|
932
|
+
skip_injection { false }
|
933
|
+
end
|
934
|
+
resource { build(:dummy_resource, skip_injection: skip_injection) }
|
935
|
+
author { resource.try(:creator_author) || resource.try(:author) || build(:user, organization: resource.organization, skip_injection: skip_injection) }
|
744
936
|
end
|
745
937
|
|
746
938
|
factory :user_group_endorsement, class: "Decidim::Endorsement" do
|
747
|
-
|
748
|
-
|
749
|
-
|
939
|
+
transient do
|
940
|
+
skip_injection { false }
|
941
|
+
end
|
942
|
+
resource { build(:dummy_resource, skip_injection: skip_injection) }
|
943
|
+
author { build(:user, organization: resource.organization, skip_injection: skip_injection) }
|
944
|
+
user_group { create(:user_group, verified_at: Time.current, organization: resource.organization, users: [author], skip_injection: skip_injection) }
|
750
945
|
end
|
751
946
|
|
752
947
|
factory :share_token, class: "Decidim::ShareToken" do
|
753
|
-
|
754
|
-
|
948
|
+
transient do
|
949
|
+
skip_injection { false }
|
950
|
+
end
|
951
|
+
token_for { build(:component, skip_injection: skip_injection) }
|
952
|
+
user { build(:user, organization: token_for.organization, skip_injection: skip_injection) }
|
755
953
|
|
756
954
|
before(:create) do |object|
|
757
955
|
object.organization ||= object.token_for.organization
|
@@ -768,33 +966,48 @@ FactoryBot.define do
|
|
768
966
|
end
|
769
967
|
|
770
968
|
factory :editor_image, class: "Decidim::EditorImage" do
|
969
|
+
transient do
|
970
|
+
skip_injection { false }
|
971
|
+
end
|
771
972
|
organization
|
772
|
-
author { create(:user, :admin, :confirmed, organization: organization) }
|
973
|
+
author { create(:user, :admin, :confirmed, organization: organization, skip_injection: skip_injection) }
|
773
974
|
file { Decidim::Dev.test_file("city.jpeg", "image/jpeg") }
|
774
975
|
end
|
775
976
|
|
776
977
|
factory :reminder, class: "Decidim::Reminder" do
|
777
|
-
|
778
|
-
|
978
|
+
transient do
|
979
|
+
skip_injection { false }
|
980
|
+
end
|
981
|
+
user { build(:user, skip_injection: skip_injection) }
|
982
|
+
component { build(:dummy_component, organization: user.organization, skip_injection: skip_injection) }
|
779
983
|
end
|
780
984
|
|
781
985
|
factory :reminder_record, class: "Decidim::ReminderRecord" do
|
782
|
-
|
783
|
-
|
986
|
+
transient do
|
987
|
+
skip_injection { false }
|
988
|
+
end
|
989
|
+
reminder { create(:reminder, skip_injection: skip_injection) }
|
990
|
+
remindable { build(:dummy_resource, skip_injection: skip_injection) }
|
784
991
|
end
|
785
992
|
|
786
993
|
factory :reminder_delivery, class: "Decidim::ReminderDelivery" do
|
787
|
-
|
994
|
+
transient do
|
995
|
+
skip_injection { false }
|
996
|
+
end
|
997
|
+
reminder { create(:reminder, skip_injection: skip_injection) }
|
788
998
|
end
|
789
999
|
|
790
1000
|
factory :short_link, class: "Decidim::ShortLink" do
|
791
|
-
|
1001
|
+
transient do
|
1002
|
+
skip_injection { false }
|
1003
|
+
end
|
1004
|
+
target { create(:component, manifest_name: "dummy", skip_injection: skip_injection) }
|
792
1005
|
route_name { nil }
|
793
1006
|
params { {} }
|
794
1007
|
|
795
|
-
before(:create) do |object|
|
1008
|
+
before(:create) do |object, evaluator|
|
796
1009
|
object.organization ||= object.target if object.target.is_a?(Decidim::Organization)
|
797
|
-
object.organization ||= object.target.try(:organization) || create(:organization)
|
1010
|
+
object.organization ||= object.target.try(:organization) || create(:organization, skip_injection: evaluator.skip_injection)
|
798
1011
|
object.identifier ||= Decidim::ShortLink.unique_identifier_within(object.organization)
|
799
1012
|
object.mounted_engine_name ||=
|
800
1013
|
if object.target.respond_to?(:participatory_space)
|