decidim-core 0.18.1 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/config/decidim_core_manifest.js +3 -0
- data/app/assets/javascripts/decidim/social_share.js +2 -0
- data/app/assets/stylesheets/decidim/extras/_social_share.css.scss +36 -0
- data/app/assets/stylesheets/decidim/modules/_input-gallery.scss +24 -0
- data/app/assets/stylesheets/decidim/modules/_navbar.scss +1 -1
- data/app/cells/decidim/activities_cell.rb +13 -8
- data/app/cells/decidim/activity_cell.rb +19 -5
- data/app/cells/decidim/address/details.erb +2 -2
- data/app/cells/decidim/amendable/amenders_list/show.erb +1 -1
- data/app/cells/decidim/amendable/amenders_list_cell.rb +5 -1
- data/app/cells/decidim/amendable/announcement_cell.rb +22 -9
- data/app/cells/decidim/amendable/wizard_step_form_cell.rb +121 -0
- data/app/cells/decidim/announcement_cell.rb +1 -0
- data/app/cells/decidim/author_cell.rb +7 -0
- data/app/cells/decidim/card_m_cell.rb +3 -1
- data/app/cells/decidim/coauthorships_cell.rb +3 -1
- data/app/cells/decidim/collapsible_authors_cell.rb +1 -0
- data/app/cells/decidim/collapsible_list_cell.rb +1 -0
- data/app/cells/decidim/content_blocks/highlighted_content_banner_cell.rb +1 -0
- data/app/cells/decidim/content_blocks/last_activity_cell.rb +3 -2
- data/app/cells/decidim/content_blocks/metrics_cell.rb +1 -0
- data/app/cells/decidim/content_blocks/stats_cell.rb +1 -0
- data/app/cells/decidim/content_blocks/sub_hero_cell.rb +1 -0
- data/app/cells/decidim/diff_cell.rb +1 -1
- data/app/cells/decidim/fingerprint/show.erb +1 -1
- data/app/cells/decidim/follow_button_cell.rb +3 -0
- data/app/cells/decidim/members_cell.rb +1 -0
- data/app/cells/decidim/notifications/show.erb +1 -1
- data/app/cells/decidim/profile_cell.rb +1 -0
- data/app/cells/decidim/profile_sidebar_cell.rb +4 -0
- data/app/cells/decidim/search_results_cell.rb +1 -0
- data/app/cells/decidim/search_results_section/show.erb +1 -1
- data/app/cells/decidim/tos_page_cell.rb +1 -0
- data/app/cells/decidim/user_group_pending_invitations_list_cell.rb +1 -0
- data/app/cells/decidim/user_group_pending_requests_list_cell.rb +1 -0
- data/app/cells/decidim/wizard_step_form/wizard_aside.erb +14 -0
- data/app/cells/decidim/wizard_step_form/wizard_header.erb +18 -0
- data/app/cells/decidim/wizard_step_form_cell.rb +112 -0
- data/app/commands/decidim/amendable/accept.rb +1 -1
- data/app/commands/decidim/amendable/create_draft.rb +70 -0
- data/app/commands/decidim/amendable/destroy_draft.rb +40 -0
- data/app/commands/decidim/amendable/promote.rb +13 -11
- data/app/commands/decidim/amendable/publish_draft.rb +76 -0
- data/app/commands/decidim/amendable/update_draft.rb +54 -0
- data/app/commands/decidim/amendable/withdraw.rb +31 -15
- data/app/commands/decidim/create_follow.rb +1 -0
- data/app/commands/decidim/create_omniauth_registration.rb +22 -4
- data/app/commands/decidim/create_registration.rb +5 -0
- data/app/commands/decidim/delete_follow.rb +1 -0
- data/app/commands/decidim/search.rb +1 -0
- data/app/controllers/concerns/decidim/action_authorization.rb +2 -0
- data/app/controllers/concerns/decidim/amendments_controller.rb +148 -28
- data/app/controllers/concerns/decidim/devise_controllers.rb +3 -2
- data/app/controllers/concerns/decidim/force_authentication.rb +38 -0
- data/app/controllers/concerns/decidim/impersonate_users.rb +1 -0
- data/app/controllers/concerns/decidim/locale_switcher.rb +44 -17
- data/app/controllers/concerns/decidim/needs_tos_accepted.rb +8 -0
- data/app/controllers/concerns/decidim/orderable.rb +36 -0
- data/app/controllers/concerns/decidim/participatory_space_context.rb +2 -0
- data/app/controllers/concerns/decidim/safe_redirect.rb +24 -0
- data/app/controllers/decidim/application_controller.rb +19 -2
- data/app/controllers/decidim/devise/confirmations_controller.rb +6 -0
- data/app/controllers/decidim/devise/invitations_controller.rb +8 -4
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +4 -1
- data/app/controllers/decidim/errors_controller.rb +3 -0
- data/app/controllers/decidim/follows_controller.rb +2 -2
- data/app/controllers/decidim/messaging/conversations_controller.rb +2 -2
- data/app/controllers/decidim/profiles_controller.rb +4 -1
- data/app/controllers/decidim/scopes_controller.rb +16 -4
- data/app/events/decidim/amendable/amendment_base_event.rb +4 -0
- data/app/forms/decidim/account_form.rb +1 -1
- data/app/forms/decidim/amendable/create_form.rb +3 -19
- data/app/forms/decidim/amendable/edit_form.rb +22 -0
- data/app/forms/decidim/amendable/form.rb +42 -20
- data/app/forms/decidim/amendable/promote_form.rb +4 -7
- data/app/forms/decidim/amendable/publish_form.rb +21 -0
- data/app/forms/decidim/amendable/reject_form.rb +1 -1
- data/app/forms/decidim/amendable/review_form.rb +9 -4
- data/app/forms/decidim/invite_user_form.rb +1 -0
- data/app/forms/decidim/notifications_settings_form.rb +1 -0
- data/app/forms/decidim/registration_form.rb +4 -3
- data/app/forms/decidim/user_group_form.rb +1 -0
- data/app/forms/decidim/user_interests_form.rb +1 -0
- data/app/helpers/decidim/amendments_helper.rb +33 -19
- data/app/helpers/decidim/cells_helper.rb +2 -0
- data/app/helpers/decidim/layout_helper.rb +1 -0
- data/app/helpers/decidim/map_helper.rb +1 -1
- data/app/helpers/decidim/meta_tags_helper.rb +1 -0
- data/app/helpers/decidim/resource_reference_helper.rb +1 -0
- data/app/jobs/decidim/event_publisher_job.rb +60 -0
- data/app/jobs/decidim/metric_job.rb +1 -0
- data/app/models/decidim/action_log.rb +12 -0
- data/app/models/decidim/amendment.rb +31 -2
- data/app/models/decidim/attachment.rb +2 -0
- data/app/models/decidim/authorization.rb +1 -0
- data/app/models/decidim/category.rb +1 -0
- data/app/models/decidim/component.rb +7 -0
- data/app/models/decidim/content_block.rb +1 -0
- data/app/models/decidim/follow.rb +3 -0
- data/app/models/decidim/identity.rb +1 -0
- data/app/models/decidim/impersonation_log.rb +2 -0
- data/app/models/decidim/newsletter.rb +1 -0
- data/app/models/decidim/participatory_process_user_role.rb +1 -0
- data/app/models/decidim/participatory_space_private_user.rb +1 -0
- data/app/models/decidim/permission_action.rb +2 -0
- data/app/models/decidim/report.rb +1 -0
- data/app/models/decidim/scope.rb +1 -0
- data/app/models/decidim/searchable_resource.rb +1 -1
- data/app/models/decidim/static_page.rb +1 -0
- data/app/models/decidim/user.rb +2 -0
- data/app/permissions/decidim/permissions.rb +18 -14
- data/app/permissions/decidim/user_manager_permissions.rb +9 -2
- data/app/presenters/decidim/admin_log/organization_presenter.rb +1 -0
- data/app/presenters/decidim/admin_log/participatory_space_private_user_presenter.rb +1 -1
- data/app/presenters/decidim/admin_log/user_presenter.rb +1 -1
- data/app/presenters/decidim/hashtag_presenter.rb +1 -1
- data/app/presenters/decidim/log/base_presenter.rb +1 -0
- data/app/presenters/decidim/log/diff_presenter.rb +1 -1
- data/app/presenters/decidim/log/value_types/area_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/area_type_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/currency_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/date_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/locale_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/percentage_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/scope_presenter.rb +1 -0
- data/app/presenters/decidim/log/value_types/scope_type_presenter.rb +1 -0
- data/app/presenters/decidim/metric_charts_presenter.rb +1 -0
- data/app/presenters/decidim/metric_object_presenter.rb +4 -0
- data/app/queries/decidim/metric_manage.rb +3 -0
- data/app/queries/decidim/metric_measure.rb +1 -0
- data/app/queries/decidim/metrics/followers_metric_manage.rb +3 -0
- data/app/queries/decidim/metrics/participants_metric_manage.rb +4 -0
- data/app/queries/decidim/similar_emendations.rb +56 -0
- data/app/resolvers/decidim/core/metric_resolver.rb +1 -0
- data/app/services/decidim/action_authorizer.rb +1 -0
- data/app/services/decidim/action_logger.rb +1 -0
- data/app/services/decidim/activity_search.rb +1 -0
- data/app/services/decidim/email_notification_generator.rb +4 -0
- data/app/services/decidim/notification_generator.rb +2 -0
- data/app/services/decidim/notification_generator_for_recipient.rb +0 -1
- data/app/services/decidim/resource_search.rb +1 -1
- data/app/services/decidim/traceability.rb +1 -0
- data/app/uploaders/decidim/application_uploader.rb +1 -0
- data/app/uploaders/decidim/attachment_uploader.rb +16 -0
- data/app/uploaders/decidim/avatar_uploader.rb +0 -2
- data/app/uploaders/decidim/data_portability_uploader.rb +1 -0
- data/app/uploaders/decidim/homepage_image_uploader.rb +0 -2
- data/app/uploaders/decidim/image_uploader.rb +15 -1
- data/app/uploaders/decidim/oauth_application_logo_uploader.rb +0 -1
- data/app/uploaders/decidim/official_image_footer_uploader.rb +0 -1
- data/app/uploaders/decidim/official_image_header_uploader.rb +0 -1
- data/app/uploaders/decidim/open_data_uploader.rb +1 -0
- data/app/validators/etiquette_validator.rb +5 -0
- data/app/views/decidim/account/delete.html.erb +2 -2
- data/app/views/decidim/account/show.html.erb +1 -1
- data/app/views/decidim/amendments/_edit_form_fields.html.erb +16 -13
- data/app/views/decidim/amendments/_similar_emendation.html.erb +24 -0
- data/app/views/decidim/amendments/compare_draft.html.erb +21 -0
- data/app/views/decidim/amendments/edit_draft.html.erb +31 -0
- data/app/views/decidim/amendments/new.html.erb +5 -17
- data/app/views/decidim/amendments/preview_draft.html.erb +32 -0
- data/app/views/decidim/amendments/review.html.erb +5 -3
- data/app/views/decidim/application/_document.html.erb +1 -1
- data/app/views/decidim/application/_photos.html.erb +1 -1
- data/app/views/decidim/data_portability/show.html.erb +1 -1
- data/app/views/decidim/devise/invitations/edit.html.erb +2 -2
- data/app/views/decidim/devise/sessions/new.html.erb +1 -1
- data/app/views/decidim/doorkeeper/authorizations/new.html.erb +3 -3
- data/app/views/decidim/export_mailer/data_portability_export.html.erb +1 -1
- data/app/views/decidim/searches/index.js.erb +6 -0
- data/app/views/decidim/shared/_address_details.html.erb +2 -2
- data/app/views/decidim/shared/_embed_modal.html.erb +1 -1
- data/app/views/decidim/shared/_share_modal.html.erb +7 -4
- data/app/views/layouts/decidim/_application.html.erb +0 -1
- data/app/views/layouts/decidim/_head.html.erb +13 -12
- data/app/views/layouts/decidim/_logo.html.erb +1 -1
- data/app/views/layouts/decidim/_social_media_links.html.erb +5 -5
- data/app/views/layouts/decidim/_user_menu.html.erb +1 -1
- data/app/views/layouts/decidim/_wrapper.html.erb +2 -2
- data/app/views/layouts/decidim/mailer.html.erb +2 -2
- data/config/locales/ar.yml +27 -17
- data/config/locales/ca.yml +79 -15
- data/config/locales/cs.yml +73 -14
- data/config/locales/de.yml +62 -12
- data/config/locales/en.yml +80 -16
- data/config/locales/eo-UY.yml +16 -0
- data/config/locales/es-MX.yml +73 -11
- data/config/locales/es-PY.yml +73 -11
- data/config/locales/es.yml +79 -15
- data/config/locales/eu.yml +6 -13
- data/config/locales/fi-plain.yml +75 -11
- data/config/locales/fi.yml +80 -16
- data/config/locales/fr.yml +70 -16
- data/config/locales/gl.yml +6 -13
- data/config/locales/hu.yml +80 -17
- data/config/locales/id-ID.yml +6 -12
- data/config/locales/it.yml +56 -14
- data/config/locales/nl.yml +76 -12
- data/config/locales/no.yml +11 -2
- data/config/locales/pl.yml +6 -15
- data/config/locales/pt-BR.yml +6 -13
- data/config/locales/pt.yml +6 -13
- data/config/locales/ru.yml +7 -2
- data/config/locales/sv.yml +34 -18
- data/config/locales/tr-TR.yml +15 -12
- data/config/locales/uk.yml +7 -2
- data/config/routes.rb +7 -0
- data/db/migrate/20180226140756_add_version_to_action_logs.rb +1 -0
- data/db/migrate/20180305132906_rename_features_to_components.rb +1 -0
- data/db/migrate/20190412131728_fix_user_names.rb +1 -1
- data/db/migrate/20190610093742_add_force_users_to_authenticate_before_access_organization.rb +10 -0
- data/db/migrate/20190618075906_add_confidential_to_doorkeeper_application.rb +13 -0
- data/db/migrate/{20190925091507_add_uniq_index_to_decidim_metrics.rb → 20190829092826_add_uniq_index_to_decidim_metrics.rb} +0 -0
- data/lib/decidim/amendable.rb +87 -13
- data/lib/decidim/attributes/localized_date.rb +5 -0
- data/lib/decidim/attributes/time_with_zone.rb +5 -0
- data/lib/decidim/authorable.rb +3 -0
- data/lib/decidim/authorization_form_builder.rb +2 -2
- data/lib/decidim/component_manifest.rb +2 -0
- data/lib/decidim/content_parsers.rb +2 -0
- data/lib/decidim/content_parsers/hashtag_parser.rb +1 -1
- data/lib/decidim/content_parsers/link_parser.rb +10 -0
- data/lib/decidim/content_parsers/newline_parser.rb +20 -0
- data/lib/decidim/content_parsers/user_parser.rb +1 -1
- data/lib/decidim/content_processor.rb +2 -0
- data/lib/decidim/content_renderers.rb +1 -0
- data/lib/decidim/content_renderers/hashtag_renderer.rb +1 -1
- data/lib/decidim/content_renderers/link_renderer.rb +24 -0
- data/lib/decidim/content_renderers/user_renderer.rb +2 -2
- data/lib/decidim/core.rb +11 -0
- data/lib/decidim/core/engine.rb +2 -28
- data/lib/decidim/core/test.rb +4 -1
- data/lib/decidim/core/test/factories.rb +35 -8
- data/lib/decidim/core/test/shared_examples/amendable/create_amendment_draft_examples.rb +50 -0
- data/lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb +39 -0
- data/lib/decidim/core/test/shared_examples/amendable/promote_amendment_examples.rb +27 -3
- data/lib/decidim/core/test/shared_examples/amendable/{create_amendment_examples.rb → publish_amendment_draft_examples.rb} +26 -17
- data/lib/decidim/core/test/shared_examples/amendable/update_amendment_draft_examples.rb +42 -0
- data/lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb +19 -11
- data/lib/decidim/core/test/shared_examples/has_attachment_collections.rb +1 -1
- data/lib/decidim/core/test/shared_examples/has_attachments.rb +1 -1
- data/lib/decidim/core/test/shared_examples/simple_event.rb +4 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/data_portability_file_zipper.rb +3 -0
- data/lib/decidim/events/author_event.rb +1 -0
- data/lib/decidim/events/base_event.rb +12 -22
- data/lib/decidim/events/coauthor_event.rb +1 -0
- data/lib/decidim/events/simple_event.rb +3 -0
- data/lib/decidim/exporters/csv.rb +1 -0
- data/lib/decidim/fingerprintable.rb +1 -0
- data/lib/decidim/followable.rb +8 -0
- data/lib/decidim/form_builder.rb +24 -3
- data/lib/decidim/gamification.rb +4 -0
- data/lib/decidim/gamification/badge_status.rb +1 -0
- data/lib/decidim/has_category.rb +2 -0
- data/lib/decidim/has_component.rb +2 -7
- data/lib/decidim/has_private_users.rb +8 -1
- data/lib/decidim/has_settings.rb +12 -8
- data/lib/decidim/hashtaggable.rb +4 -0
- data/lib/decidim/metric_operation_manifest.rb +1 -0
- data/lib/decidim/nicknamizable.rb +1 -0
- data/lib/decidim/participable.rb +1 -0
- data/lib/decidim/participatory_space_resourceable.rb +1 -0
- data/lib/decidim/randomable.rb +20 -0
- data/lib/decidim/search_resource_fields_mapper.rb +2 -0
- data/lib/decidim/searchable.rb +2 -0
- data/lib/decidim/settings_manifest.rb +10 -1
- data/lib/decidim/stats_registry.rb +1 -0
- data/lib/decidim/view_model.rb +1 -1
- data/lib/tasks/decidim_data_portability_tasks.rake +1 -0
- data/lib/tasks/decidim_metrics_tasks.rake +2 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.no.js +12 -12
- metadata +140 -82
- data/app/commands/decidim/amendable/create.rb +0 -80
data/lib/decidim/core/test.rb
CHANGED
@@ -27,7 +27,10 @@ require "decidim/core/test/shared_examples/searchable_results_examples"
|
|
27
27
|
require "decidim/core/test/shared_examples/has_space_in_mcell_examples"
|
28
28
|
require "decidim/core/test/shared_examples/railtie_examples"
|
29
29
|
require "decidim/core/test/shared_examples/edit_link_shared_examples"
|
30
|
-
require "decidim/core/test/shared_examples/amendable/
|
30
|
+
require "decidim/core/test/shared_examples/amendable/create_amendment_draft_examples"
|
31
|
+
require "decidim/core/test/shared_examples/amendable/update_amendment_draft_examples"
|
32
|
+
require "decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples"
|
33
|
+
require "decidim/core/test/shared_examples/amendable/publish_amendment_draft_examples"
|
31
34
|
require "decidim/core/test/shared_examples/amendable/withdraw_amendment_examples"
|
32
35
|
require "decidim/core/test/shared_examples/amendable/reject_amendment_examples"
|
33
36
|
require "decidim/core/test/shared_examples/amendable/promote_amendment_examples"
|
@@ -41,7 +41,7 @@ FactoryBot.define do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
sequence(:scope_name) do |n|
|
44
|
-
"#{Faker::Lorem.sentence(1, true, 3)} #{n}"
|
44
|
+
"#{Faker::Lorem.sentence(1, true, 3)} #{n}".gsub("s", "z").gsub("S", "Z")
|
45
45
|
end
|
46
46
|
|
47
47
|
sequence(:scope_code) do |n|
|
@@ -87,6 +87,7 @@ FactoryBot.define do
|
|
87
87
|
badges_enabled { true }
|
88
88
|
user_groups_enabled { true }
|
89
89
|
send_welcome_notification { true }
|
90
|
+
force_users_to_authenticate_before_access_organization { false }
|
90
91
|
smtp_settings do
|
91
92
|
{
|
92
93
|
"from" => "test@example.org",
|
@@ -311,6 +312,17 @@ FactoryBot.define do
|
|
311
312
|
participatory_space { create(:participatory_process, organization: organization) }
|
312
313
|
manifest_name { "dummy" }
|
313
314
|
published_at { Time.current }
|
315
|
+
settings do
|
316
|
+
{
|
317
|
+
dummy_global_translatable_text: generate_localized_title
|
318
|
+
}
|
319
|
+
end
|
320
|
+
|
321
|
+
default_step_settings do
|
322
|
+
{
|
323
|
+
dummy_step_translatable_text: generate_localized_title
|
324
|
+
}
|
325
|
+
end
|
314
326
|
|
315
327
|
trait :unpublished do
|
316
328
|
published_at { nil }
|
@@ -319,6 +331,14 @@ FactoryBot.define do
|
|
319
331
|
trait :published do
|
320
332
|
published_at { Time.current }
|
321
333
|
end
|
334
|
+
|
335
|
+
trait :with_amendments_enabled do
|
336
|
+
settings do
|
337
|
+
{
|
338
|
+
amendments_enabled: true
|
339
|
+
}
|
340
|
+
end
|
341
|
+
end
|
322
342
|
end
|
323
343
|
|
324
344
|
factory :scope_type, class: "Decidim::ScopeType" do
|
@@ -366,6 +386,10 @@ FactoryBot.define do
|
|
366
386
|
component { create(:component, manifest_name: "dummy") }
|
367
387
|
author { create(:user, :confirmed, organization: component.organization) }
|
368
388
|
scope { create(:scope, organization: component.organization) }
|
389
|
+
|
390
|
+
trait :published do
|
391
|
+
published_at { Time.current }
|
392
|
+
end
|
369
393
|
end
|
370
394
|
|
371
395
|
factory :resource_link, class: "Decidim::ResourceLink" do
|
@@ -525,14 +549,17 @@ FactoryBot.define do
|
|
525
549
|
end
|
526
550
|
|
527
551
|
factory :amendment, class: "Decidim::Amendment" do
|
528
|
-
amender do
|
529
|
-
build(
|
530
|
-
:user,
|
531
|
-
organization: amendable.try(:organization) || build(:organization)
|
532
|
-
)
|
533
|
-
end
|
534
|
-
state { "evaluating" }
|
535
552
|
amendable { build(:dummy_resource) }
|
536
553
|
emendation { build(:dummy_resource) }
|
554
|
+
amender { emendation.try(:creator_author) || emendation.try(:author) }
|
555
|
+
state { "evaluating" }
|
556
|
+
|
557
|
+
trait :draft do
|
558
|
+
state { "draft" }
|
559
|
+
end
|
560
|
+
|
561
|
+
trait :rejected do
|
562
|
+
state { "rejected" }
|
563
|
+
end
|
537
564
|
end
|
538
565
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
shared_examples "create amendment draft" do
|
4
|
+
context "when the form is valid" do
|
5
|
+
it "broadcasts ok" do
|
6
|
+
expect { command.call }.to broadcast(:ok)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "creates an amendment (draft) and the emendation (not published)" do
|
10
|
+
expect { command.call }
|
11
|
+
.to change(Decidim::Amendment, :count)
|
12
|
+
.by(1)
|
13
|
+
.and change(amendable.class, :count)
|
14
|
+
.by(1)
|
15
|
+
|
16
|
+
expect(Decidim::Amendment.last.draft?).to eq(true)
|
17
|
+
expect(amendable.class.last.published?).to eq(false)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "traces the action without creating a PaperTrail version for the emendation", versioning: true do
|
21
|
+
expect(Decidim.traceability)
|
22
|
+
.to receive(:perform_action!)
|
23
|
+
.with(
|
24
|
+
:create,
|
25
|
+
amendable.class,
|
26
|
+
form.current_user,
|
27
|
+
kind_of(Hash)
|
28
|
+
).and_call_original
|
29
|
+
|
30
|
+
expect { command.call }.to change(Decidim::ActionLog, :count).by(1)
|
31
|
+
expect(amendable.class.last.versions.count).to eq(0)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when the form is invalid" do
|
36
|
+
let(:title) { "Too short" }
|
37
|
+
|
38
|
+
it "broadcasts invalid" do
|
39
|
+
expect { command.call }.to broadcast(:invalid)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "doesn't create an amendment and the emendation" do
|
43
|
+
expect { command.call }
|
44
|
+
.to change(Decidim::Amendment, :count)
|
45
|
+
.by(0)
|
46
|
+
.and change(amendable.class, :count)
|
47
|
+
.by(0)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
shared_examples "destroy amendment draft" do
|
4
|
+
context "when current user is the author of the amendment" do
|
5
|
+
let(:current_user) { amendment.amender }
|
6
|
+
|
7
|
+
describe "and the amendment is a draft" do
|
8
|
+
it "broadcasts ok" do
|
9
|
+
expect { command.call }.to broadcast(:ok)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "destroys the amendment and the emendation" do
|
13
|
+
expect { command.call }
|
14
|
+
.to change(Decidim::Amendment, :count)
|
15
|
+
.by(-1)
|
16
|
+
.and change(amendable.class, :count)
|
17
|
+
.by(-1)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "and the amendment is not a draft" do
|
22
|
+
before do
|
23
|
+
amendment.update(state: "evaluating")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "broadcasts invalid" do
|
27
|
+
expect { command.call }.to broadcast(:invalid)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "when the current user is not the amender" do
|
33
|
+
let!(:current_user) { other_user }
|
34
|
+
|
35
|
+
it "broadcasts invalid" do
|
36
|
+
expect { command.call }.to broadcast(:invalid)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -7,9 +7,7 @@ shared_examples "promote amendment" do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "creates an amendable type resource" do
|
10
|
-
expect { command.call }
|
11
|
-
.to change(amendable.resource_manifest.model_class_name.constantize, :count)
|
12
|
-
.by(1)
|
10
|
+
expect { command.call }.to change(amendable.class, :count).by(1)
|
13
11
|
end
|
14
12
|
|
15
13
|
it "traces the action", versioning: true do
|
@@ -40,4 +38,30 @@ shared_examples "promote amendment" do
|
|
40
38
|
command.call
|
41
39
|
end
|
42
40
|
end
|
41
|
+
|
42
|
+
context "when the form is not valid" do
|
43
|
+
let(:form) { Decidim::Amendable::PromoteForm.from_params(id: nil) }
|
44
|
+
|
45
|
+
it "broadcasts invalid" do
|
46
|
+
expect { command.call }.to broadcast(:invalid)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "when current user is not the author of the amendment" do
|
51
|
+
let(:current_user) { other_user }
|
52
|
+
|
53
|
+
it "broadcasts invalid" do
|
54
|
+
expect { command.call }.to broadcast(:invalid)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "when amendment is not rejected" do
|
59
|
+
before do
|
60
|
+
amendment.update(state: "evaluating")
|
61
|
+
end
|
62
|
+
|
63
|
+
it "broadcasts invalid" do
|
64
|
+
expect { command.call }.to broadcast(:invalid)
|
65
|
+
end
|
66
|
+
end
|
43
67
|
end
|
@@ -1,17 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
shared_examples "
|
4
|
-
|
3
|
+
shared_examples "publish amendment draft" do
|
4
|
+
describe "when the form is valid" do
|
5
5
|
it "broadcasts ok" do
|
6
6
|
expect { command.call }.to broadcast(:ok)
|
7
7
|
end
|
8
8
|
|
9
|
-
it "
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
.by(1)
|
9
|
+
it "publishes the amendment and the emendation" do
|
10
|
+
command.call
|
11
|
+
|
12
|
+
expect(Decidim::Amendment.last.draft?).to eq(false)
|
13
|
+
expect(amendable.class.last.published?).to eq(true)
|
15
14
|
end
|
16
15
|
|
17
16
|
it "traces the action", versioning: true do
|
@@ -19,7 +18,7 @@ shared_examples "create amendment" do
|
|
19
18
|
.to receive(:perform_action!)
|
20
19
|
.with(
|
21
20
|
"publish",
|
22
|
-
form.amendable.
|
21
|
+
form.amendable.class,
|
23
22
|
form.current_user,
|
24
23
|
kind_of(Hash)
|
25
24
|
).and_call_original
|
@@ -42,19 +41,29 @@ shared_examples "create amendment" do
|
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
|
-
context "when the form is
|
46
|
-
let(:
|
44
|
+
context "when the form is not valid" do
|
45
|
+
let(:form) { Decidim::Amendable::PublishForm.from_params(id: nil) }
|
47
46
|
|
48
47
|
it "broadcasts invalid" do
|
49
48
|
expect { command.call }.to broadcast(:invalid)
|
50
49
|
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when current user is not the author of the amendment" do
|
53
|
+
let(:current_user) { other_user }
|
51
54
|
|
52
|
-
it "
|
53
|
-
expect { command.call }
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
it "broadcasts invalid" do
|
56
|
+
expect { command.call }.to broadcast(:invalid)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "when amendment is not a draft" do
|
61
|
+
before do
|
62
|
+
amendment.update(state: "evaluating")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "broadcasts invalid" do
|
66
|
+
expect { command.call }.to broadcast(:invalid)
|
58
67
|
end
|
59
68
|
end
|
60
69
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
shared_examples "update amendment draft" do
|
4
|
+
describe "when the form is valid" do
|
5
|
+
it "broadcasts ok" do
|
6
|
+
expect { command.call }.to broadcast(:ok)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "updates the emendation without creating a PaperTrail version" do
|
10
|
+
expect { command.call }
|
11
|
+
.to change(form.emendation, :title)
|
12
|
+
.and change(form.emendation, :body)
|
13
|
+
expect(amendable.class.last.versions.count).to eq(0)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "when the form is not valid" do
|
18
|
+
let(:title) { "Too short" }
|
19
|
+
|
20
|
+
it "broadcasts invalid" do
|
21
|
+
expect { command.call }.to broadcast(:invalid)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "when the current user is not the amender" do
|
26
|
+
let(:current_user) { other_user }
|
27
|
+
|
28
|
+
it "broadcasts invalid" do
|
29
|
+
expect { command.call }.to broadcast(:invalid)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "when the amendment is not a draft" do
|
34
|
+
before do
|
35
|
+
amendment.update(state: "evaluating")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "broadcasts invalid" do
|
39
|
+
expect { command.call }.to broadcast(:invalid)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -1,29 +1,37 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
shared_examples "withdraw amendment" do
|
4
|
-
context "when current user
|
4
|
+
context "when current user is the author of the amendment" do
|
5
|
+
let(:current_user) { amendment.amender }
|
6
|
+
|
5
7
|
context "and the amendment has no supports" do
|
6
8
|
it "withdraws the amendment" do
|
7
|
-
expect
|
8
|
-
|
9
|
-
end.to change { Decidim::Proposals::Proposal.count }.by(0)
|
10
|
-
expect(emendation.amendment.state).to eq("withdrawn")
|
9
|
+
expect { command.call }.to broadcast(:ok)
|
10
|
+
expect(amendment.state).to eq("withdrawn")
|
11
11
|
expect(emendation.state).to eq("withdrawn")
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
context "and the amendment
|
15
|
+
context "and the amendment has some supports" do
|
16
16
|
before do
|
17
|
-
emendation.votes.create!(author:
|
17
|
+
emendation.votes.create!(author: other_user)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "is not able to withdraw the amendment" do
|
21
|
-
expect
|
22
|
-
|
23
|
-
end.to change { Decidim::Proposals::Proposal.count }.by(0)
|
24
|
-
expect(emendation.amendment.state).not_to eq("withdrawn")
|
21
|
+
expect { command.call }.to broadcast(:invalid)
|
22
|
+
expect(amendment.state).not_to eq("withdrawn")
|
25
23
|
expect(emendation.state).not_to eq("withdrawn")
|
26
24
|
end
|
27
25
|
end
|
28
26
|
end
|
27
|
+
|
28
|
+
context "when current user is not the author of the amendment" do
|
29
|
+
let!(:current_user) { other_user }
|
30
|
+
|
31
|
+
it "is not able to withdraw the amendment" do
|
32
|
+
expect { command.call }.to broadcast(:invalid)
|
33
|
+
expect(amendment.state).not_to eq("withdrawn")
|
34
|
+
expect(emendation.state).not_to eq("withdrawn")
|
35
|
+
end
|
36
|
+
end
|
29
37
|
end
|
@@ -26,7 +26,7 @@ shared_examples_for "has attachment collections" do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
context "
|
29
|
+
context "when are ordered by weight", processing_uploads_for: Decidim::AttachmentUploader do
|
30
30
|
let!(:last_attachment_collection) { create(:attachment_collection, collection_for: collection_for, weight: 2) }
|
31
31
|
let!(:document_one) { create(:attachment, :with_pdf, attached_to: attached_to, attachment_collection: last_attachment_collection) }
|
32
32
|
|
@@ -23,7 +23,7 @@ shared_examples_for "has attachments" do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
context "
|
26
|
+
context "when are ordered by weight", processing_uploads_for: Decidim::AttachmentUploader do
|
27
27
|
let!(:last_document) { create(:attachment, :with_pdf, attached_to: attached_to, weight: 2) }
|
28
28
|
let!(:first_document) { create(:attachment, :with_pdf, attached_to: attached_to, weight: 1) }
|
29
29
|
let!(:last_image) { create(:attachment, attached_to: attached_to, weight: 2) }
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
shared_context "when a simple event" do
|
6
|
+
include Decidim::SanitizeHelper
|
6
7
|
subject { event_instance }
|
7
8
|
|
8
9
|
let(:event_instance) do
|
@@ -40,6 +41,9 @@ shared_context "when a simple event" do
|
|
40
41
|
end
|
41
42
|
end
|
42
43
|
let(:author_presenter) { Decidim::UserPresenter.new(author) }
|
44
|
+
let(:author_name) { decidim_html_escape author.name }
|
45
|
+
let(:author_path) { author_presenter&.profile_path.to_s }
|
46
|
+
let(:author_nickname) { author_presenter&.nickname.to_s }
|
43
47
|
let(:i18n_scope) { event_name }
|
44
48
|
end
|
45
49
|
|
data/lib/decidim/core/version.rb
CHANGED
@@ -38,8 +38,10 @@ module Decidim
|
|
38
38
|
zipfile = Zip::File.open(file_path)
|
39
39
|
@export_images.each do |image_block|
|
40
40
|
next if image_block.last.nil?
|
41
|
+
|
41
42
|
image_block.last.each do |image|
|
42
43
|
next if image.file.nil?
|
44
|
+
|
43
45
|
folder_name = image_block.first.parameterize
|
44
46
|
uploader = Decidim::ApplicationUploader.new(image.model, image.mounted_as)
|
45
47
|
if image.file.respond_to? :file
|
@@ -54,6 +56,7 @@ module Decidim
|
|
54
56
|
end
|
55
57
|
my_image_path = File.open(image.file.file)
|
56
58
|
next unless File.exist?(my_image_path)
|
59
|
+
|
57
60
|
zipfile.add("#{folder_name}/#{image.file.filename}", my_image_path)
|
58
61
|
CarrierWave.clean_cached_files!
|
59
62
|
end
|