decidim-restfull-core 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/app/commands/decidim/rest_full/core/create_api_client.rb +40 -0
- data/app/commands/decidim/rest_full/core/impersonate_resource_owner_from_credentials.rb +151 -0
- data/app/commands/decidim/rest_full/core/syncronize_unconfirmed_host.rb +45 -0
- data/app/controllers/concerns/decidim/api/rest_full/async_api_job_enqueuing.rb +69 -0
- data/app/controllers/concerns/decidim/api/rest_full/collection_pagination.rb +78 -0
- data/app/controllers/concerns/decidim/api/rest_full/collection_pagination_meta.rb +25 -0
- data/app/controllers/concerns/decidim/api/rest_full/conditional_get_rendering.rb +49 -0
- data/app/controllers/concerns/decidim/api/rest_full/extended_data_endpoints.rb +96 -0
- data/app/controllers/concerns/decidim/api/rest_full/job_response_linking.rb +31 -0
- data/app/controllers/decidim/api/rest_full/application_controller.rb +245 -0
- data/app/controllers/decidim/api/rest_full/attachments/attachments_controller.rb +81 -0
- data/app/controllers/decidim/api/rest_full/components/component_extended_data_controller.rb +31 -0
- data/app/controllers/decidim/api/rest_full/components/components_controller.rb +68 -0
- data/app/controllers/decidim/api/rest_full/core/resources_controller.rb +142 -0
- data/app/controllers/decidim/api/rest_full/core.rb +11 -0
- data/app/controllers/decidim/api/rest_full/jobs/jobs_controller.rb +109 -0
- data/app/controllers/decidim/api/rest_full/organizations/organization_extended_data_controller.rb +31 -0
- data/app/controllers/decidim/api/rest_full/organizations/organizations_controller.rb +234 -0
- data/app/controllers/decidim/api/rest_full/roles/roles_controller.rb +125 -0
- data/app/controllers/decidim/api/rest_full/spaces/space_extended_data_controller.rb +29 -0
- data/app/controllers/decidim/api/rest_full/spaces/spaces_controller.rb +225 -0
- data/app/controllers/decidim/api/rest_full/users/magic_links_controller.rb +81 -0
- data/app/controllers/decidim/api/rest_full/users/user_extended_data_controller.rb +92 -0
- data/app/controllers/decidim/api/rest_full/users/users_controller.rb +40 -0
- data/app/controllers/decidim/api/rest_full/webhooks/webhook_events_controller.rb +33 -0
- data/app/controllers/decidim/api/rest_full/webhooks/webhook_registrations_controller.rb +106 -0
- data/app/controllers/decidim/rest_full/pages_controller.rb +9 -0
- data/app/controllers/decidim/rest_full/system/api_clients_controller.rb +69 -0
- data/app/controllers/decidim/rest_full/system/permissions_controller.rb +30 -0
- data/app/controllers/decidim/rest_full/system/webhook_registrations_controller.rb +49 -0
- data/app/forms/decidim/rest_full/core/admin/config_form.rb +49 -0
- data/app/forms/decidim/rest_full/core/api_client_form.rb +20 -0
- data/app/forms/decidim/rest_full/core/api_permissions.rb +18 -0
- data/app/forms/decidim/rest_full/core/magic_link_redirect_url_form.rb +114 -0
- data/app/forms/decidim/rest_full/core/webhook_event_form.rb +35 -0
- data/app/forms/decidim/rest_full/core/webhook_registration_form.rb +49 -0
- data/app/jobs/decidim/rest_full/application_job.rb +10 -0
- data/app/jobs/decidim/rest_full/core/space_webhook_job.rb +60 -0
- data/app/jobs/decidim/rest_full/core/syncronize_unconfirmed_host_job.rb +18 -0
- data/app/jobs/decidim/rest_full/core/webhook_job.rb +13 -0
- data/app/jobs/decidim/rest_full/execute_api_job_job.rb +55 -0
- data/app/models/decidim/rest_full/api_job.rb +74 -0
- data/app/models/decidim/rest_full/core/ability.rb +195 -0
- data/app/models/decidim/rest_full/core/api_client.rb +56 -0
- data/app/models/decidim/rest_full/core/magic_token.rb +45 -0
- data/app/models/decidim/rest_full/core/permission.rb +15 -0
- data/app/models/decidim/rest_full/core/resource_extended_data.rb +16 -0
- data/app/models/decidim/rest_full/core/webhook_registration.rb +61 -0
- data/app/overrides/system_host_input.rb +40 -0
- data/app/serializers/decidim/api/rest_full/core/application_serializer.rb +19 -0
- data/app/serializers/decidim/api/rest_full/core/assembly_serializer.rb +13 -0
- data/app/serializers/decidim/api/rest_full/core/attachment_serializer.rb +76 -0
- data/app/serializers/decidim/api/rest_full/core/awesome_iframe_component_serializer.rb +12 -0
- data/app/serializers/decidim/api/rest_full/core/awesome_map_component_serializer.rb +12 -0
- data/app/serializers/decidim/api/rest_full/core/component_serializer.rb +97 -0
- data/app/serializers/decidim/api/rest_full/core/helpers/resource_links_helper.rb +48 -0
- data/app/serializers/decidim/api/rest_full/core/magic_link_redirect_serializer.rb +43 -0
- data/app/serializers/decidim/api/rest_full/core/magic_link_serializer.rb +44 -0
- data/app/serializers/decidim/api/rest_full/core/organization_serializer.rb +60 -0
- data/app/serializers/decidim/api/rest_full/core/organization_webhook_serializer.rb +21 -0
- data/app/serializers/decidim/api/rest_full/core/page_component_serializer.rb +20 -0
- data/app/serializers/decidim/api/rest_full/core/page_serializer.rb +12 -0
- data/app/serializers/decidim/api/rest_full/core/participatory_process_serializer.rb +13 -0
- data/app/serializers/decidim/api/rest_full/core/resource_serializer.rb +84 -0
- data/app/serializers/decidim/api/rest_full/core/role_serializer.rb +21 -0
- data/app/serializers/decidim/api/rest_full/core/serializer_lookup.rb +55 -0
- data/app/serializers/decidim/api/rest_full/core/space_serializer.rb +117 -0
- data/app/serializers/decidim/api/rest_full/core/space_webhook_serializer.rb +64 -0
- data/app/serializers/decidim/api/rest_full/core/user_serializer.rb +43 -0
- data/app/serializers/decidim/api/rest_full/core/user_webhook_serializer.rb +21 -0
- data/app/serializers/decidim/api/rest_full/core/webhook_registration_serializer.rb +25 -0
- data/app/serializers/decidim/api/rest_full/core/webhook_serializer.rb +68 -0
- data/app/serializers/decidim/api/rest_full/core.rb +10 -0
- data/app/services/decidim/rest_full/core/api_system_operations.rb +505 -0
- data/app/services/decidim/rest_full/core/fire_webhook.rb +114 -0
- data/app/services/decidim/rest_full/core/participatory_process_step_activated_webhook_handler.rb +39 -0
- data/app/services/decidim/rest_full/participatory_space_visibility.rb +64 -0
- data/app/views/decidim/rest_full/core/admin/_organization_settings_tab.html.erb +35 -0
- data/app/views/decidim/rest_full/pages/show.html.erb +60 -0
- data/app/views/decidim/rest_full/system/api_clients/_edit_info_tab.erb +261 -0
- data/app/views/decidim/rest_full/system/api_clients/_edit_webhook_tab.erb +74 -0
- data/app/views/decidim/rest_full/system/api_clients/_form.html.erb +23 -0
- data/app/views/decidim/rest_full/system/api_clients/_permissions_scope.html.erb +22 -0
- data/app/views/decidim/rest_full/system/api_clients/edit.html.erb +53 -0
- data/app/views/decidim/rest_full/system/api_clients/index.html.erb +37 -0
- data/app/views/decidim/rest_full/system/api_clients/new.html.erb +13 -0
- data/app/views/decidim/rest_full/system/api_clients/show.html.erb +10 -0
- data/config/i18n-tasks.yml +381 -0
- data/config/locales/decidim_rest_full.en.yml +184 -0
- data/config/routes.rb +116 -0
- data/db/migrate/20241125061513_create_api_client_permissions.rb +12 -0
- data/db/migrate/20250112155305_create_proposal_application_id.rb +11 -0
- data/db/migrate/20250131155931_add_users_magic_token.rb +14 -0
- data/db/migrate/20250609083335_create_webhooks_table.rb +16 -0
- data/db/migrate/20250609091039_add_is_event_to_api_client_permissions.rb +7 -0
- data/db/migrate/20250624080106_create_organization_extended_data.rb +11 -0
- data/db/migrate/20260321120000_add_redirect_url_to_decidim_rest_full_user_magic_tokens.rb +7 -0
- data/db/migrate/20260511120000_create_decidim_rest_full_api_jobs.rb +23 -0
- data/db/migrate/20260515120000_add_poll_and_oauth_context_to_rest_full_api_jobs.rb +38 -0
- data/db/migrate/20260516153000_remove_poll_secret_from_decidim_rest_full_api_jobs.rb +7 -0
- data/db/migrate/20260516160000_add_org_status_index_to_rest_full_api_jobs.rb +9 -0
- data/db/migrate/20260805070000_create_resource_extended_data.rb +44 -0
- data/lib/decidim/rest_full/api_execution_context.rb +58 -0
- data/lib/decidim/rest_full/api_job_command_runner.rb +48 -0
- data/lib/decidim/rest_full/api_job_payload.rb +19 -0
- data/lib/decidim/rest_full/cli/base.rb +84 -0
- data/lib/decidim/rest_full/cli/create.rb +122 -0
- data/lib/decidim/rest_full/cli/delete.rb +48 -0
- data/lib/decidim/rest_full/cli/get.rb +53 -0
- data/lib/decidim/rest_full/cli/grant.rb +58 -0
- data/lib/decidim/rest_full/cli/revoke.rb +53 -0
- data/lib/decidim/rest_full/cli.rb +70 -0
- data/lib/decidim/rest_full/core/apartment_tenant_switch.rb +23 -0
- data/lib/decidim/rest_full/core/api_exception.rb +179 -0
- data/lib/decidim/rest_full/core/attachments_operations.rb +232 -0
- data/lib/decidim/rest_full/core/configuration.rb +116 -0
- data/lib/decidim/rest_full/core/definition_registry.rb +509 -0
- data/lib/decidim/rest_full/core/doorkeeper_config.rb +130 -0
- data/lib/decidim/rest_full/core/engine.rb +167 -0
- data/lib/decidim/rest_full/core/extended_data_at_path.rb +22 -0
- data/lib/decidim/rest_full/core/gem_spec_paths.rb +56 -0
- data/lib/decidim/rest_full/core/has_extended_data.rb +70 -0
- data/lib/decidim/rest_full/core/http_cache/collection_fingerprint.rb +97 -0
- data/lib/decidim/rest_full/core/http_cache/fingerprint_contributor_registry.rb +53 -0
- data/lib/decidim/rest_full/core/http_cache/request_oauth_context.rb +34 -0
- data/lib/decidim/rest_full/core/http_cache/resource_show_fingerprint.rb +74 -0
- data/lib/decidim/rest_full/core/menu.rb +18 -0
- data/lib/decidim/rest_full/core/module_availability.rb +181 -0
- data/lib/decidim/rest_full/core/open_api_definition_paths.rb +59 -0
- data/lib/decidim/rest_full/core/overrides/application_mailer_override.rb +50 -0
- data/lib/decidim/rest_full/core/overrides/organization_client_ids_override.rb +17 -0
- data/lib/decidim/rest_full/core/overrides/update_organization_command_override.rb +27 -0
- data/lib/decidim/rest_full/core/overrides/update_organization_form_override.rb +46 -0
- data/lib/decidim/rest_full/core/overrides/user_extended_data_ransack.rb +15 -0
- data/lib/decidim/rest_full/core/overrides/user_magic_token_override.rb +27 -0
- data/lib/decidim/rest_full/core/permission_registry.rb +65 -0
- data/lib/decidim/rest_full/core/ransackers.rb +99 -0
- data/lib/decidim/rest_full/core/rest_enhancement_builder.rb +115 -0
- data/lib/decidim/rest_full/core/rest_enhancement_registration.rb +21 -0
- data/lib/decidim/rest_full/core/roles/role_id_codec.rb +50 -0
- data/lib/decidim/rest_full/core/roles/roles_aggregator.rb +203 -0
- data/lib/decidim/rest_full/core/roles/roles_writer.rb +343 -0
- data/lib/decidim/rest_full/core/route_registry.rb +123 -0
- data/lib/decidim/rest_full/core/serializer_additions_registry.rb +100 -0
- data/lib/decidim/rest_full/core/settings_tab.rb +22 -0
- data/lib/decidim/rest_full/core/swagger_spec_paths.rb +61 -0
- data/lib/decidim/rest_full/core/tokens_availability.rb +23 -0
- data/lib/decidim/rest_full/core/webhook_dispatcher.rb +55 -0
- data/lib/decidim/rest_full/core/webhook_event_catalog.rb +136 -0
- data/lib/decidim/rest_full/extension.rb +276 -0
- data/lib/decidim/rest_full/rest_full.rb +12 -0
- data/lib/decidim/rest_full/routes.rb +58 -0
- data/lib/decidim/rest_full/routing.rb +53 -0
- data/lib/decidim/rest_full/sync_runner.rb +14 -0
- data/lib/decidim/rest_full/test/apartment.rb +52 -0
- data/lib/decidim/rest_full/test/definitions/README.md +96 -0
- data/lib/decidim/rest_full/test/definitions/attachment.rb +64 -0
- data/lib/decidim/rest_full/test/definitions/collection_meta.rb +20 -0
- data/lib/decidim/rest_full/test/definitions/component.rb +99 -0
- data/lib/decidim/rest_full/test/definitions/component_type.rb +8 -0
- data/lib/decidim/rest_full/test/definitions/core.rb +16 -0
- data/lib/decidim/rest_full/test/definitions/creation_date.rb +11 -0
- data/lib/decidim/rest_full/test/definitions/edition_date.rb +11 -0
- data/lib/decidim/rest_full/test/definitions/error.rb +40 -0
- data/lib/decidim/rest_full/test/definitions/filter_param.rb +105 -0
- data/lib/decidim/rest_full/test/definitions/grant_param.rb +82 -0
- data/lib/decidim/rest_full/test/definitions/health.rb +12 -0
- data/lib/decidim/rest_full/test/definitions/introspect_data.rb +67 -0
- data/lib/decidim/rest_full/test/definitions/job.rb +130 -0
- data/lib/decidim/rest_full/test/definitions/locales_param.rb +19 -0
- data/lib/decidim/rest_full/test/definitions/magic_link.rb +37 -0
- data/lib/decidim/rest_full/test/definitions/magic_link_redirect.rb +32 -0
- data/lib/decidim/rest_full/test/definitions/manifests.rb +28 -0
- data/lib/decidim/rest_full/test/definitions/oauth_token_response.rb +18 -0
- data/lib/decidim/rest_full/test/definitions/organization.rb +75 -0
- data/lib/decidim/rest_full/test/definitions/organization_extended_data.rb +19 -0
- data/lib/decidim/rest_full/test/definitions/publication_date.rb +11 -0
- data/lib/decidim/rest_full/test/definitions/relationship_identifier.rb +29 -0
- data/lib/decidim/rest_full/test/definitions/resource_extended_data.rb +20 -0
- data/lib/decidim/rest_full/test/definitions/role.rb +61 -0
- data/lib/decidim/rest_full/test/definitions/shared.rb +22 -0
- data/lib/decidim/rest_full/test/definitions/space.rb +112 -0
- data/lib/decidim/rest_full/test/definitions/tags/attachments_tag.rb +26 -0
- data/lib/decidim/rest_full/test/definitions/tags/component_tag.rb +26 -0
- data/lib/decidim/rest_full/test/definitions/tags/jobs_tag.rb +20 -0
- data/lib/decidim/rest_full/test/definitions/tags/oauth_tag.rb +28 -0
- data/lib/decidim/rest_full/test/definitions/tags/organization_extended_data_tag.rb +22 -0
- data/lib/decidim/rest_full/test/definitions/tags/organizations_tag.rb +24 -0
- data/lib/decidim/rest_full/test/definitions/tags/roles_tag.rb +14 -0
- data/lib/decidim/rest_full/test/definitions/tags/space_tag.rb +22 -0
- data/lib/decidim/rest_full/test/definitions/tags/users_tag.rb +14 -0
- data/lib/decidim/rest_full/test/definitions/tags/webhooks_tag.rb +31 -0
- data/lib/decidim/rest_full/test/definitions/tags.rb +12 -0
- data/lib/decidim/rest_full/test/definitions/time_zone.rb +10 -0
- data/lib/decidim/rest_full/test/definitions/translated_prop.rb +11 -0
- data/lib/decidim/rest_full/test/definitions/user.rb +93 -0
- data/lib/decidim/rest_full/test/definitions/user_extended_data.rb +14 -0
- data/lib/decidim/rest_full/test/definitions/webhook.rb +95 -0
- data/lib/decidim/rest_full/test/definitions.rb +15 -0
- data/lib/decidim/rest_full/test/factories/api_client.rb +16 -0
- data/lib/decidim/rest_full/test/factories/magic_token.rb +13 -0
- data/lib/decidim/rest_full/test/factories/webhook_registration.rb +10 -0
- data/lib/decidim/rest_full/test/factories.rb +5 -0
- data/lib/decidim/rest_full/test/global_context.rb +11 -0
- data/lib/decidim/rest_full/test/on_api_endpoint_methods.rb +190 -0
- data/lib/decidim/rest_full/test/open_api_tag_registry.rb +25 -0
- data/lib/decidim/rest_full/test/openapi_specs.rb +107 -0
- data/lib/decidim/rest_full/test/shared_examples/has_extended_data.rb +41 -0
- data/lib/decidim/rest_full/test/shared_examples.rb +345 -0
- data/lib/decidim/rest_full/version.rb +27 -0
- data/lib/decidim/rest_full.rb +99 -0
- data/lib/decidim-restfull-core.rb +3 -0
- data/lib/tasks/decidim/rest_full/fire_webhook.rake +52 -0
- data/lib/tasks/decidim/rest_full/integrator_sandbox.rake +37 -0
- data/lib/tasks/decidim/rest_full/rest_full_upgrade.rake +64 -0
- data/lib/tasks/decidim/rest_full/rest_full_webpacker.rake +58 -0
- data/spec/commands/decidim/rest_full/core/impersonate_resource_owner_from_credentials_spec.rb +159 -0
- data/spec/commands/decidim/rest_full/core/syncronize_unconfirmed_host_spec.rb +117 -0
- data/spec/controllers/concerns/decidim/api/rest_full/collection_pagination_spec.rb +128 -0
- data/spec/decidim/rest_full/core/configuration_engine_disabled_routes_spec.rb +24 -0
- data/spec/forms/decidim/rest_full/core/magic_link_redirect_url_form_spec.rb +69 -0
- data/spec/forms/decidim/rest_full/core/webhook_registration_form_spec.rb +42 -0
- data/spec/jobs/decidim/rest_full/core/space_webhook_job_spec.rb +62 -0
- data/spec/jobs/decidim/rest_full/core/syncronize_unconfirmed_host_job_spec.rb +34 -0
- data/spec/jobs/decidim/rest_full/core/webhook_job_spec.rb +29 -0
- data/spec/jobs/decidim/rest_full/execute_api_job_job_spec.rb +45 -0
- data/spec/lib/decidim/rest_full/core/apartment_tenant_switch_spec.rb +26 -0
- data/spec/lib/decidim/rest_full/core/api_exception/bad_request_spec.rb +62 -0
- data/spec/lib/decidim/rest_full/core/definition_registry_add_resource_relationships_spec.rb +19 -0
- data/spec/lib/decidim/rest_full/core/gem_spec_paths_spec.rb +27 -0
- data/spec/lib/decidim/rest_full/core/http_cache/collection_fingerprint_spec.rb +59 -0
- data/spec/lib/decidim/rest_full/core/http_cache/fingerprint_contributor_registry_spec.rb +60 -0
- data/spec/lib/decidim/rest_full/core/http_cache/resource_show_fingerprint_spec.rb +33 -0
- data/spec/lib/decidim/rest_full/core/module_availability_spec.rb +130 -0
- data/spec/lib/decidim/rest_full/core/open_api_definition_paths_spec.rb +54 -0
- data/spec/lib/decidim/rest_full/core/optional_feature_gems_spec.rb +172 -0
- data/spec/lib/decidim/rest_full/core/roles/role_id_codec_spec.rb +62 -0
- data/spec/lib/decidim/rest_full/core/roles/roles_aggregator_spec.rb +53 -0
- data/spec/lib/decidim/rest_full/core/roles/roles_writer_spec.rb +38 -0
- data/spec/lib/decidim/rest_full/core/route_registry_spec.rb +90 -0
- data/spec/lib/decidim/rest_full/core/serializer_additions_registry_spec.rb +100 -0
- data/spec/lib/decidim/rest_full/core/settings_tab_spec.rb +15 -0
- data/spec/lib/decidim/rest_full/core/swagger_spec_paths_spec.rb +50 -0
- data/spec/lib/decidim/rest_full/core/webhook_dispatcher_proposal_published_spec.rb +63 -0
- data/spec/lib/decidim/rest_full/core/webhook_event_catalog_spec.rb +34 -0
- data/spec/lib/decidim/rest_full/routing_spec.rb +62 -0
- data/spec/lib/decidim/rest_full/test/apartment_spec.rb +17 -0
- data/spec/models/decidim/rest_full/api_job_spec.rb +51 -0
- data/spec/models/decidim/rest_full/application_mailer_override_spec.rb +60 -0
- data/spec/models/decidim/rest_full/core/has_extended_data_spec.rb +16 -0
- data/spec/models/decidim/rest_full/core/magic_token_spec.rb +68 -0
- data/spec/models/decidim/rest_full/core/webhook_registration_spec.rb +161 -0
- data/spec/models/decidim/rest_full/user_magic_token_spec.rb +51 -0
- data/spec/requests/decidim/api/rest_full/application_controller_introspect_spec.rb +85 -0
- data/spec/requests/decidim/api/rest_full/application_controller_ropc_spec.rb +299 -0
- data/spec/requests/decidim/api/rest_full/application_controller_token_spec.rb +57 -0
- data/spec/requests/decidim/api/rest_full/attachments/attachments_controller_direct_upload_spec.rb +39 -0
- data/spec/requests/decidim/api/rest_full/attachments/attachments_controller_index_spec.rb +41 -0
- data/spec/requests/decidim/api/rest_full/attachments/attachments_controller_show_spec.rb +34 -0
- data/spec/requests/decidim/api/rest_full/components/component_extended_data_controller_spec.rb +78 -0
- data/spec/requests/decidim/api/rest_full/components/components_controller_search_spec.rb +197 -0
- data/spec/requests/decidim/api/rest_full/components/components_controller_search_sql_spec.rb +48 -0
- data/spec/requests/decidim/api/rest_full/jobs/api_jobs_async_and_conditional_get_spec.rb +209 -0
- data/spec/requests/decidim/api/rest_full/jobs/jobs_controller_destroy_spec.rb +58 -0
- data/spec/requests/decidim/api/rest_full/jobs/jobs_controller_index_spec.rb +126 -0
- data/spec/requests/decidim/api/rest_full/jobs/jobs_controller_show_spec.rb +89 -0
- data/spec/requests/decidim/api/rest_full/module_availability_gate_spec.rb +77 -0
- data/spec/requests/decidim/api/rest_full/organizations/organization_extended_data_controller_index_spec.rb +88 -0
- data/spec/requests/decidim/api/rest_full/organizations/organization_extended_data_controller_update_spec.rb +194 -0
- data/spec/requests/decidim/api/rest_full/organizations/organizations_controller_index_spec.rb +57 -0
- data/spec/requests/decidim/api/rest_full/organizations/organizations_controller_show_spec.rb +66 -0
- data/spec/requests/decidim/api/rest_full/organizations/organizations_controller_update_spec.rb +120 -0
- data/spec/requests/decidim/api/rest_full/roles/roles_controller_create_spec.rb +230 -0
- data/spec/requests/decidim/api/rest_full/roles/roles_controller_destroy_spec.rb +52 -0
- data/spec/requests/decidim/api/rest_full/roles/roles_controller_index_spec.rb +127 -0
- data/spec/requests/decidim/api/rest_full/roles/roles_controller_show_spec.rb +215 -0
- data/spec/requests/decidim/api/rest_full/routes_boot_spec.rb +58 -0
- data/spec/requests/decidim/api/rest_full/scenarios/upsert_user_by_phone_and_set_locale_spec.rb +69 -0
- data/spec/requests/decidim/api/rest_full/spaces/space_extended_data_controller_spec.rb +78 -0
- data/spec/requests/decidim/api/rest_full/spaces/spaces_controller_index_spec.rb +167 -0
- data/spec/requests/decidim/api/rest_full/spaces/spaces_controller_search_spec.rb +280 -0
- data/spec/requests/decidim/api/rest_full/spaces/spaces_controller_show_spec.rb +98 -0
- data/spec/requests/decidim/api/rest_full/users/magic_links_controller_create_spec.rb +124 -0
- data/spec/requests/decidim/api/rest_full/users/magic_links_controller_show_spec.rb +84 -0
- data/spec/requests/decidim/api/rest_full/users/user_extended_data_controller_index_spec.rb +74 -0
- data/spec/requests/decidim/api/rest_full/users/user_extended_data_controller_update_spec.rb +192 -0
- data/spec/requests/decidim/api/rest_full/users/users_controller_index_spec.rb +182 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_events_controller_show_spec.rb +52 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_create_spec.rb +95 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_destroy_spec.rb +34 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_index_spec.rb +43 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_show_spec.rb +51 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_update_spec.rb +57 -0
- data/spec/requests/decidim/rest_full/system/api_clients_controller_spec.rb +69 -0
- data/spec/serializers/decidim/api/rest_full/core/organization_webhook_serializer_spec.rb +18 -0
- data/spec/serializers/decidim/api/rest_full/core/space_webhook_serializer_spec.rb +44 -0
- data/spec/serializers/decidim/api/rest_full/core/user_webhook_serializer_spec.rb +19 -0
- data/spec/services/decidim/rest_full/core/api_system_operations_resource_extended_data_update_spec.rb +35 -0
- data/spec/services/decidim/rest_full/core/fire_webhook_spec.rb +59 -0
- data/spec/services/decidim/rest_full/core/participatory_process_step_activated_webhook_handler_spec.rb +57 -0
- metadata +482 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::RestFull::ExecuteApiJobJob do
|
|
6
|
+
let!(:organization) { create(:organization, available_locales: ["en"]) }
|
|
7
|
+
let!(:user) { create(:user, organization:, confirmed_at: Time.zone.now) }
|
|
8
|
+
let!(:participatory_process) { create(:participatory_process, organization:) }
|
|
9
|
+
let!(:proposal_component) do
|
|
10
|
+
create(:component, participatory_space: participatory_process, manifest_name: "proposals", published_at: Time.zone.now)
|
|
11
|
+
end
|
|
12
|
+
let!(:api_client) do
|
|
13
|
+
c = create(:api_client, organization:, scopes: ["proposals"])
|
|
14
|
+
c.permissions = [Decidim::RestFull::Core::Permission.new(permission: "proposals.draft")]
|
|
15
|
+
c.save!
|
|
16
|
+
c
|
|
17
|
+
end
|
|
18
|
+
let!(:token) { create(:oauth_access_token, scopes: "proposals", resource_owner_id: user.id, application: api_client) }
|
|
19
|
+
|
|
20
|
+
it "runs draft create and marks job completed" do
|
|
21
|
+
Decidim::Proposals::Proposal.where(decidim_component_id: proposal_component.id).delete_all
|
|
22
|
+
|
|
23
|
+
job = Decidim::RestFull::ApiJob.compat_create!(
|
|
24
|
+
decidim_organization_id: organization.id,
|
|
25
|
+
doorkeeper_access_token_id: token.id,
|
|
26
|
+
oauth_application_id: token.application_id,
|
|
27
|
+
resource_owner_id: token.resource_owner_id,
|
|
28
|
+
command_key: "draft_proposals#create",
|
|
29
|
+
status: "pending",
|
|
30
|
+
payload: {
|
|
31
|
+
"path" => {
|
|
32
|
+
"component_id" => proposal_component.id,
|
|
33
|
+
"space_manifest" => "participatory_processes",
|
|
34
|
+
"space_id" => participatory_process.id
|
|
35
|
+
},
|
|
36
|
+
"data" => { "component_id" => proposal_component.id }
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
described_class.perform_now(job.id)
|
|
41
|
+
job.reload
|
|
42
|
+
expect(job.status).to eq("completed")
|
|
43
|
+
expect(job.result["data"]).to be_a(Hash)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::RestFull::Core::ApartmentTenantSwitch do
|
|
6
|
+
describe ".call" do
|
|
7
|
+
it "yields without switching when ros-apartment is not the branch" do
|
|
8
|
+
skip "ros-apartment loaded" if Gem.loaded_specs.has_key?("ros-apartment")
|
|
9
|
+
|
|
10
|
+
expect(described_class.call("example.org") { :ok }).to eq(:ok)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "does not yield for an unknown host when ros-apartment is loaded" do
|
|
14
|
+
skip "ros-apartment not in bundle" unless Gem.loaded_specs.has_key?("ros-apartment")
|
|
15
|
+
|
|
16
|
+
expect(described_class.call("missing-tenant.example.org") { :leaked }).to be_nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "does not prepend CurrentOrganizationApartment" do
|
|
20
|
+
skip "ros-apartment not in bundle" unless Gem.loaded_specs.has_key?("ros-apartment")
|
|
21
|
+
|
|
22
|
+
names = Decidim::Middleware::CurrentOrganization.ancestors.map(&:name)
|
|
23
|
+
expect(names).not_to include("Decidim::RestFull::Core::CurrentOrganizationApartment")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
module Decidim
|
|
6
|
+
module RestFull
|
|
7
|
+
module Core
|
|
8
|
+
module ApiExceptionBadRequestSpec
|
|
9
|
+
class SampleForm
|
|
10
|
+
include ActiveModel::Model
|
|
11
|
+
|
|
12
|
+
attr_accessor :title, :body
|
|
13
|
+
|
|
14
|
+
validates :title, :body, presence: true
|
|
15
|
+
validates :title, length: { minimum: 15 }, allow_blank: true
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
RSpec.describe Decidim::RestFull::Core::ApiException::BadRequest do
|
|
23
|
+
let(:form_class) { Decidim::RestFull::Core::ApiExceptionBadRequestSpec::SampleForm }
|
|
24
|
+
|
|
25
|
+
describe ".from_errors" do
|
|
26
|
+
it "maps ActiveModel errors to error_details and joins descriptions" do
|
|
27
|
+
record = form_class.new(title: "Hi", body: "")
|
|
28
|
+
expect(record).not_to be_valid
|
|
29
|
+
|
|
30
|
+
exception = described_class.from_errors(record.errors)
|
|
31
|
+
|
|
32
|
+
expect(exception.message).to eq(record.errors.map(&:full_message).join(". "))
|
|
33
|
+
expect(exception.error_details).to all(include(:code, :field, :description))
|
|
34
|
+
expect(exception.error_details.map { |d| d[:field] }).to include("title", "body")
|
|
35
|
+
expect(exception.error_details.map { |d| d[:code] }).to include("blank", "too_short")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "infers too_much_caps when type is a translated string (DecidimAwesome)" do
|
|
39
|
+
record = form_class.new(title: "ok", body: "ok")
|
|
40
|
+
record.valid?
|
|
41
|
+
record.errors.add(:title, "Is using too many capital letters (over 25% of the text)")
|
|
42
|
+
|
|
43
|
+
exception = described_class.from_errors(record.errors)
|
|
44
|
+
|
|
45
|
+
expect(exception.error_details).to include(
|
|
46
|
+
a_hash_including(code: "too_much_caps", field: "title")
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe ".from_form" do
|
|
52
|
+
it "limits details to selected attributes" do
|
|
53
|
+
record = form_class.new(title: "", body: "")
|
|
54
|
+
expect(record).not_to be_valid
|
|
55
|
+
|
|
56
|
+
exception = described_class.from_form(record, only: [:title])
|
|
57
|
+
|
|
58
|
+
expect(exception.error_details.map { |d| d[:field] }).to all(eq("title"))
|
|
59
|
+
expect(exception.error_details).to include(a_hash_including(code: "blank", field: "title"))
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::RestFull::Core::DefinitionRegistry do
|
|
6
|
+
describe ".add_resource_relationships" do
|
|
7
|
+
it "raises when the resource schema is missing" do
|
|
8
|
+
expect do
|
|
9
|
+
described_class.add_resource_relationships(:missing_resource, foo: { type: :object })
|
|
10
|
+
end.to raise_error(ArgumentError, /not registered/)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "raises when the relationship key already exists" do
|
|
14
|
+
expect do
|
|
15
|
+
described_class.add_resource_relationships(:proposal, state: { type: :object })
|
|
16
|
+
end.to raise_error(ArgumentError, /already exists/)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "decidim/rest_full/core/gem_spec_paths"
|
|
5
|
+
|
|
6
|
+
module Decidim
|
|
7
|
+
module RestFull
|
|
8
|
+
module Core
|
|
9
|
+
RSpec.describe GemSpecPaths do
|
|
10
|
+
it "lists every monorepo feature gem" do
|
|
11
|
+
expect(described_class::GEMS).to include(
|
|
12
|
+
"decidim-restfull-core",
|
|
13
|
+
"decidim-restfull-proposals",
|
|
14
|
+
"decidim-restfull-forms"
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "resolves request spec globs under the monorepo root" do
|
|
19
|
+
glob = described_class.request_spec_glob("decidim-restfull-core")
|
|
20
|
+
expect(glob).to eq(
|
|
21
|
+
File.join(described_class.spec_dir("decidim-restfull-core"), "requests/**/*_spec.rb")
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "decidim/rest_full/core/http_cache/collection_fingerprint"
|
|
5
|
+
|
|
6
|
+
module Decidim
|
|
7
|
+
module RestFull
|
|
8
|
+
module Core
|
|
9
|
+
module HttpCache
|
|
10
|
+
RSpec.describe CollectionFingerprint do
|
|
11
|
+
let(:organization) { build_stubbed(:organization, id: 7) }
|
|
12
|
+
let(:relation) { instance_double(ActiveRecord::Relation) }
|
|
13
|
+
let(:updated_at) { Time.zone.parse("2024-06-01 10:00:00") }
|
|
14
|
+
|
|
15
|
+
before do
|
|
16
|
+
allow(relation).to receive(:is_a?).with(ActiveRecord::Relation).and_return(true)
|
|
17
|
+
allow(relation).to receive(:maximum).with(:updated_at).and_return(updated_at)
|
|
18
|
+
allow(relation).to receive(:count).and_raise("COUNT must not be used in CollectionFingerprint")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def build_fp(**overrides)
|
|
22
|
+
described_class.new(
|
|
23
|
+
described_class::RequestContext.new(
|
|
24
|
+
{
|
|
25
|
+
profile: :resource_index,
|
|
26
|
+
organization:,
|
|
27
|
+
relation:,
|
|
28
|
+
client_id: "client-1",
|
|
29
|
+
act_as: nil,
|
|
30
|
+
locales: %w(en fr),
|
|
31
|
+
page: 1,
|
|
32
|
+
per_page: 20,
|
|
33
|
+
order: "published_at",
|
|
34
|
+
order_direction: "asc",
|
|
35
|
+
request_filter: { "state_eq" => "accepted" },
|
|
36
|
+
extra: nil
|
|
37
|
+
}.merge(overrides)
|
|
38
|
+
)
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "builds etag without calling relation.count" do
|
|
43
|
+
fp = build_fp
|
|
44
|
+
expect(fp.last_modified).to eq(updated_at)
|
|
45
|
+
expect(fp.etag).to match(/\A"[0-9a-f]{64}"\z/)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "changes etag when page changes" do
|
|
49
|
+
expect(build_fp(page: 1).etag).not_to eq(build_fp(page: 2).etag)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "changes etag when order changes" do
|
|
53
|
+
expect(build_fp(order: "published_at").etag).not_to eq(build_fp(order: "rand").etag)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::RestFull::Core::HttpCache::FingerprintContributorRegistry do
|
|
6
|
+
before { described_class.reset! }
|
|
7
|
+
|
|
8
|
+
describe ".max_updated_at_for" do
|
|
9
|
+
it "returns the maximum cache_time across contributors" do
|
|
10
|
+
t1 = Time.zone.parse("2020-01-01 10:00:00")
|
|
11
|
+
t2 = Time.zone.parse("2020-01-02 10:00:00")
|
|
12
|
+
proposal = instance_double(Decidim::Proposals::Proposal, id: 1)
|
|
13
|
+
organization = instance_double(Decidim::Organization, id: 1)
|
|
14
|
+
|
|
15
|
+
described_class.register(
|
|
16
|
+
:proposal_show,
|
|
17
|
+
extension_name: :a,
|
|
18
|
+
cache_time: ->(_p) { t1 }
|
|
19
|
+
)
|
|
20
|
+
described_class.register(
|
|
21
|
+
:proposal_show,
|
|
22
|
+
extension_name: :b,
|
|
23
|
+
cache_time: ->(_p) { t2 }
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
max_ts = described_class.max_updated_at_for(
|
|
27
|
+
:proposal_show,
|
|
28
|
+
proposal:,
|
|
29
|
+
organization:
|
|
30
|
+
)
|
|
31
|
+
expect(max_ts).to eq(t2)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe ".etag_segments_for" do
|
|
36
|
+
it "concatenates etag_segment values" do
|
|
37
|
+
proposal = instance_double(Decidim::Proposals::Proposal, id: 1)
|
|
38
|
+
organization = instance_double(Decidim::Organization, id: 1)
|
|
39
|
+
|
|
40
|
+
described_class.register(
|
|
41
|
+
:proposal_show,
|
|
42
|
+
extension_name: :a,
|
|
43
|
+
etag_segment: ->(_p) { "seg-a" }
|
|
44
|
+
)
|
|
45
|
+
described_class.register(
|
|
46
|
+
:proposal_show,
|
|
47
|
+
extension_name: :b,
|
|
48
|
+
etag_segment: ->(_p) { "seg-b" }
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
expect(
|
|
52
|
+
described_class.etag_segments_for(
|
|
53
|
+
:proposal_show,
|
|
54
|
+
proposal:,
|
|
55
|
+
organization:
|
|
56
|
+
)
|
|
57
|
+
).to eq(%w(seg-a seg-b))
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "decidim/rest_full/core/http_cache/resource_show_fingerprint"
|
|
5
|
+
|
|
6
|
+
module Decidim
|
|
7
|
+
module RestFull
|
|
8
|
+
module Core
|
|
9
|
+
module HttpCache
|
|
10
|
+
RSpec.describe ResourceShowFingerprint do
|
|
11
|
+
let(:organization) { build_stubbed(:organization, id: 1) }
|
|
12
|
+
let(:record) { build_stubbed(:assembly, id: 42, updated_at: Time.zone.parse("2024-01-02 12:00:00")) }
|
|
13
|
+
|
|
14
|
+
it "builds etag and last_modified from the record" do
|
|
15
|
+
fp = described_class.new(
|
|
16
|
+
described_class::RequestContext.new(
|
|
17
|
+
profile: :resource_show,
|
|
18
|
+
organization:,
|
|
19
|
+
record:,
|
|
20
|
+
client_id: "client-1",
|
|
21
|
+
act_as: nil,
|
|
22
|
+
locales: %w(en)
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
expect(fp.last_modified).to eq(record.updated_at)
|
|
26
|
+
expect(fp.etag).to start_with('"')
|
|
27
|
+
expect(fp.etag).to end_with('"')
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Decidim::RestFull::Core::ModuleAvailability do
|
|
6
|
+
subject { described_class }
|
|
7
|
+
|
|
8
|
+
let(:organization) { create(:organization) }
|
|
9
|
+
|
|
10
|
+
def stub_config(hash)
|
|
11
|
+
allow(described_class).to receive(:raw_config).with(organization).and_return(hash.with_indifferent_access)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe ".enabled?" do
|
|
15
|
+
it "defaults to true when no Toggle row" do
|
|
16
|
+
stub_config({})
|
|
17
|
+
expect(subject.enabled?(organization)).to be(true)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "is false when master enabled is false" do
|
|
21
|
+
stub_config(enabled: false)
|
|
22
|
+
expect(subject.enabled?(organization)).to be(false)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe ".module_enabled?" do
|
|
27
|
+
it "defaults feature modules to true when master is on and key missing" do
|
|
28
|
+
stub_config(enabled: true)
|
|
29
|
+
expect(subject.module_enabled?(organization, :blogs)).to be(true)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "is false when master is off even if feature is true" do
|
|
33
|
+
stub_config(enabled: false, blogs_enabled: true)
|
|
34
|
+
expect(subject.module_enabled?(organization, :blogs)).to be(false)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "is false when feature flag is off" do
|
|
38
|
+
stub_config(enabled: true, blogs_enabled: false)
|
|
39
|
+
expect(subject.module_enabled?(organization, :blogs)).to be(false)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "is false when the feature gem is not installed" do
|
|
43
|
+
stub_config(enabled: true, proposals_enabled: true)
|
|
44
|
+
allow(Decidim::Toggle).to receive(:gem_present?).with("decidim-restfull-proposals").and_return(false)
|
|
45
|
+
expect(subject.module_enabled?(organization, :proposals)).to be(false)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe ".feature_gem_present?" do
|
|
50
|
+
it "treats attachments as always present (core)" do
|
|
51
|
+
expect(subject.feature_gem_present?(:attachments)).to be(true)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "delegates to Decidim::Toggle.gem_present? for feature gems" do
|
|
55
|
+
allow(Decidim::Toggle).to receive(:gem_present?).with("decidim-restfull-blogs").and_return(false)
|
|
56
|
+
expect(subject.feature_gem_present?(:blogs)).to be(false)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe ".available_feature_modules" do
|
|
61
|
+
it "omits features whose gem is absent" do
|
|
62
|
+
allow(Decidim::Toggle).to receive(:gem_present?).and_return(true)
|
|
63
|
+
allow(Decidim::Toggle).to receive(:gem_present?).with("decidim-restfull-proposals").and_return(false)
|
|
64
|
+
|
|
65
|
+
expect(subject.available_feature_modules).not_to include(:proposals)
|
|
66
|
+
expect(subject.available_feature_modules).to include(:attachments)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe ".scope_enabled?" do
|
|
71
|
+
it "hides all scopes when master is off" do
|
|
72
|
+
stub_config(enabled: false)
|
|
73
|
+
expect(subject.scope_enabled?(organization, :public)).to be(false)
|
|
74
|
+
expect(subject.scope_enabled?(organization, :blogs)).to be(false)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "keeps core scopes when master is on" do
|
|
78
|
+
stub_config(enabled: true)
|
|
79
|
+
expect(subject.scope_enabled?(organization, :public)).to be(true)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "hides blogs scope when blogs is off" do
|
|
83
|
+
stub_config(enabled: true, blogs_enabled: false)
|
|
84
|
+
expect(subject.scope_enabled?(organization, :blogs)).to be(false)
|
|
85
|
+
expect(subject.scope_enabled?(organization, :public)).to be(true)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "keeps surveys scope when forms is on and surveys is off" do
|
|
89
|
+
stub_config(enabled: true, surveys_enabled: false, forms_enabled: true)
|
|
90
|
+
expect(subject.scope_enabled?(organization, :surveys)).to be(true)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe ".register_feature! / .register_controller_path!" do
|
|
95
|
+
after do
|
|
96
|
+
described_class.feature_gems.delete(:widgets)
|
|
97
|
+
described_class.feature_modules.delete(:widgets)
|
|
98
|
+
described_class.controller_path_features.delete("widgets")
|
|
99
|
+
described_class.scope_features.delete(:widgets)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "lets external modules map controller segments to a Toggle feature" do
|
|
103
|
+
described_class.register_feature!(:widgets, gem: "decidim-restfull-widgets")
|
|
104
|
+
described_class.register_controller_path!("widgets", feature: :widgets)
|
|
105
|
+
described_class.register_scope_feature!(:widgets, :widgets)
|
|
106
|
+
|
|
107
|
+
expect(described_class.feature_gems[:widgets]).to eq("decidim-restfull-widgets")
|
|
108
|
+
expect(described_class.controller_path_features["widgets"]).to eq(:widgets)
|
|
109
|
+
expect(described_class.scope_features[:widgets]).to eq(:widgets)
|
|
110
|
+
expect(described_class.feature_modules).to include(:widgets)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "resolves feature_for_controller from registered segments" do
|
|
114
|
+
described_class.register_feature!(:widgets, gem: nil)
|
|
115
|
+
described_class.register_controller_path!("widgets", feature: :widgets)
|
|
116
|
+
controller = instance_double(ActionController::Base, controller_path: "decidim/api/rest_full/widgets")
|
|
117
|
+
|
|
118
|
+
expect(described_class.feature_for_controller(controller)).to eq(:widgets)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
describe ".advertised_scopes filtering" do
|
|
123
|
+
it "filters DoorkeeperConfig.advertised_scopes_for" do
|
|
124
|
+
stub_config(enabled: true, blogs_enabled: false)
|
|
125
|
+
scopes = Decidim::RestFull::Core::DoorkeeperConfig.advertised_scopes_for(organization)
|
|
126
|
+
expect(scopes).not_to include(:blogs)
|
|
127
|
+
expect(scopes).to include(:public)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
module Decidim
|
|
6
|
+
module RestFull
|
|
7
|
+
module Core
|
|
8
|
+
RSpec.describe OpenApiDefinitionPaths do
|
|
9
|
+
around do |example|
|
|
10
|
+
described_class.reset!
|
|
11
|
+
old = ENV.fetch("DECIDIM_REST_FULL_OPENAPI_DEFINITION_PATHS", nil)
|
|
12
|
+
ENV.delete("DECIDIM_REST_FULL_OPENAPI_DEFINITION_PATHS")
|
|
13
|
+
example.run
|
|
14
|
+
ENV["DECIDIM_REST_FULL_OPENAPI_DEFINITION_PATHS"] = old
|
|
15
|
+
described_class.reset!
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "loads a registered barrel file" do
|
|
19
|
+
barrel = File.join(
|
|
20
|
+
"decidim-restfull-surveys",
|
|
21
|
+
"lib/decidim/rest_full/surveys/test_definitions.rb"
|
|
22
|
+
)
|
|
23
|
+
full = File.join(GemSpecPaths.monorepo_root, barrel)
|
|
24
|
+
skip "surveys definitions barrel missing" unless File.file?(full)
|
|
25
|
+
|
|
26
|
+
described_class.register(barrel)
|
|
27
|
+
expect { described_class.load_all! }.not_to raise_error
|
|
28
|
+
expect(described_class).to be_loaded
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "expands globs to definition barrels" do
|
|
32
|
+
described_class.register(
|
|
33
|
+
File.join("decidim-restfull-surveys", "lib/decidim/rest_full/surveys/test_definitions.rb")
|
|
34
|
+
)
|
|
35
|
+
paths = described_class.expand_paths(described_class.extra)
|
|
36
|
+
expect(paths).not_to be_empty
|
|
37
|
+
expect(paths.join).to include("surveys/test_definitions.rb")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "merges env paths when files exist" do
|
|
41
|
+
barrel = Dir.glob(
|
|
42
|
+
File.join(GemSpecPaths.monorepo_root, "decidim-restfull-*/lib/decidim/rest_full/*/test_definitions.rb")
|
|
43
|
+
).first
|
|
44
|
+
skip "no feature test_definitions barrels in tree" unless barrel
|
|
45
|
+
|
|
46
|
+
rel = barrel.delete_prefix("#{GemSpecPaths.monorepo_root}/")
|
|
47
|
+
ENV["DECIDIM_REST_FULL_OPENAPI_DEFINITION_PATHS"] = rel
|
|
48
|
+
paths = described_class.expand_paths(described_class.env_paths)
|
|
49
|
+
expect(paths).to eq([barrel])
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|