decidim 0.0.1.alpha9 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.babelrc +16 -0
- data/.codeclimate.yml +16 -2
- data/.eslintignore +11 -0
- data/.eslintrc.json +275 -11
- data/.gitattributes +1 -0
- data/.gitignore +8 -0
- data/.hound.yml +2 -4
- data/.rubocop.yml +8 -4
- data/.ruby-version +1 -1
- data/.travis.yml +7 -8
- data/Dockerfile +16 -5
- data/Gemfile +4 -6
- data/Gemfile.lock +148 -70
- data/{LICENSE.txt → LICENSE-AGPLv3.txt} +42 -0
- data/README.md +28 -10
- data/Rakefile +53 -2
- data/codecov.yml +14 -6
- data/crowdin.yaml +1 -2
- data/decidim-admin/README.md +33 -8
- data/decidim-admin/Rakefile +0 -25
- data/decidim-admin/app/assets/javascripts/decidim/admin/application.js.es6 +17 -10
- data/decidim-admin/app/assets/javascripts/decidim/admin/sort_steps.js.es6 +20 -11
- data/decidim-admin/app/assets/javascripts/decidim/admin/tab_focus.js.es6 +22 -0
- data/decidim-admin/app/assets/stylesheets/decidim/admin/_forms.scss +10 -0
- data/decidim-admin/app/assets/stylesheets/decidim/admin/_layout.scss +11 -0
- data/decidim-admin/app/assets/stylesheets/decidim/admin/_tables.scss +4 -0
- data/decidim-admin/app/assets/stylesheets/decidim/admin/application.scss +8 -2
- data/decidim-admin/app/commands/decidim/admin/activate_participatory_process_step.rb +1 -1
- data/decidim-admin/app/commands/decidim/admin/create_category.rb +44 -0
- data/decidim-admin/app/commands/decidim/admin/create_feature.rb +48 -0
- data/decidim-admin/app/commands/decidim/admin/create_participatory_process.rb +3 -6
- data/decidim-admin/app/commands/decidim/admin/create_participatory_process_admin.rb +51 -0
- data/decidim-admin/app/commands/decidim/admin/create_participatory_process_attachment.rb +44 -0
- data/decidim-admin/app/commands/decidim/admin/create_participatory_process_step.rb +3 -3
- data/decidim-admin/app/commands/decidim/admin/create_scope.rb +38 -0
- data/decidim-admin/app/commands/decidim/admin/create_static_page.rb +40 -0
- data/decidim-admin/app/commands/decidim/admin/destroy_category.rb +36 -0
- data/decidim-admin/app/commands/decidim/admin/destroy_feature.rb +39 -0
- data/decidim-admin/app/commands/decidim/admin/publish_participatory_process.rb +1 -1
- data/decidim-admin/app/commands/decidim/admin/reorder_participatory_process_steps.rb +5 -2
- data/decidim-admin/app/commands/decidim/admin/unpublish_participatory_process.rb +1 -1
- data/decidim-admin/app/commands/decidim/admin/update_category.rb +48 -0
- data/decidim-admin/app/commands/decidim/admin/update_organization.rb +49 -0
- data/decidim-admin/app/commands/decidim/admin/update_participatory_process.rb +2 -2
- data/decidim-admin/app/commands/decidim/admin/update_participatory_process_attachment.rb +49 -0
- data/decidim-admin/app/commands/decidim/admin/update_participatory_process_step.rb +1 -1
- data/decidim-admin/app/commands/decidim/admin/update_scope.rb +43 -0
- data/decidim-admin/app/commands/decidim/admin/update_static_page.rb +45 -0
- data/decidim-admin/app/constraints/decidim/admin/organization_dashboard_constraint.rb +5 -1
- data/decidim-admin/app/controllers/decidim/admin/application_controller.rb +8 -0
- data/decidim-admin/app/controllers/decidim/admin/categories_controller.rb +90 -0
- data/decidim-admin/app/controllers/decidim/admin/concerns/participatory_process_admin.rb +31 -0
- data/decidim-admin/app/controllers/decidim/admin/features_controller.rb +74 -0
- data/decidim-admin/app/controllers/decidim/admin/organization_controller.rb +40 -0
- data/decidim-admin/app/controllers/decidim/admin/participatory_process_attachments_controller.rb +84 -0
- data/decidim-admin/app/controllers/decidim/admin/participatory_process_publications_controller.rb +2 -7
- data/decidim-admin/app/controllers/decidim/admin/participatory_process_step_activations_controller.rb +6 -8
- data/decidim-admin/app/controllers/decidim/admin/participatory_process_step_ordering_controller.rb +2 -4
- data/decidim-admin/app/controllers/decidim/admin/participatory_process_steps_controller.rb +13 -11
- data/decidim-admin/app/controllers/decidim/admin/participatory_process_user_roles_controller.rb +54 -0
- data/decidim-admin/app/controllers/decidim/admin/participatory_processes_controller.rb +11 -6
- data/decidim-admin/app/controllers/decidim/admin/scopes_controller.rb +79 -0
- data/decidim-admin/app/controllers/decidim/admin/static_pages_controller.rb +94 -0
- data/decidim-admin/app/forms/decidim/admin/category_form.rb +37 -0
- data/decidim-admin/app/forms/decidim/admin/feature_form.rb +16 -0
- data/decidim-admin/app/forms/decidim/admin/organization_form.rb +31 -0
- data/decidim-admin/app/forms/decidim/admin/participatory_process_attachment_form.rb +19 -0
- data/decidim-admin/app/forms/decidim/admin/participatory_process_form.rb +4 -7
- data/decidim-admin/app/forms/decidim/admin/participatory_process_step_form.rb +12 -2
- data/decidim-admin/app/forms/decidim/admin/participatory_process_user_role_form.rb +15 -0
- data/decidim-admin/app/forms/decidim/admin/scope_form.rb +24 -0
- data/decidim-admin/app/forms/decidim/admin/static_page_form.rb +30 -0
- data/decidim-admin/app/helpers/decidim/admin/application_helper.rb +1 -0
- data/decidim-admin/app/helpers/decidim/admin/aria_selected_link_to_helper.rb +28 -0
- data/decidim-admin/app/helpers/decidim/admin/attributes_display_helper.rb +13 -5
- data/decidim-admin/app/models/decidim/admin/abilities/admin_user.rb +34 -0
- data/decidim-admin/app/models/decidim/admin/abilities/base.rb +19 -0
- data/decidim-admin/app/models/decidim/admin/abilities/participatory_process_admin.rb +51 -0
- data/decidim-admin/app/models/decidim/admin/participatory_process_user_role.rb +14 -0
- data/decidim-admin/app/queries/decidim/admin/manageable_participatory_processes_for_user.rb +41 -0
- data/decidim-admin/app/queries/decidim/admin/process_admin_roles_for_process.rb +35 -0
- data/decidim-admin/app/views/decidim/admin/categories/_form.html.erb +12 -0
- data/decidim-admin/app/views/decidim/admin/categories/edit.html.erb +9 -0
- data/decidim-admin/app/views/decidim/admin/categories/index.html.erb +44 -0
- data/decidim-admin/app/views/decidim/admin/categories/new.html.erb +9 -0
- data/decidim-admin/app/views/decidim/admin/categories/show.html.erb +14 -0
- data/decidim-admin/app/views/decidim/admin/features/_feature.html.erb +20 -0
- data/decidim-admin/app/views/decidim/admin/features/_form.html.erb +3 -0
- data/decidim-admin/app/views/decidim/admin/features/index.html.erb +23 -0
- data/decidim-admin/app/views/decidim/admin/features/new.html.erb +9 -0
- data/decidim-admin/app/views/decidim/admin/organization/_form.html.erb +23 -0
- data/decidim-admin/app/views/decidim/admin/organization/edit.html.erb +11 -0
- data/decidim-admin/app/views/decidim/admin/participatory_process_attachments/_form.html.erb +11 -0
- data/decidim-admin/app/views/decidim/admin/participatory_process_attachments/edit.html.erb +9 -0
- data/decidim-admin/app/views/decidim/admin/participatory_process_attachments/index.html.erb +37 -0
- data/decidim-admin/app/views/decidim/admin/participatory_process_attachments/new.html.erb +9 -0
- data/decidim-admin/app/views/decidim/admin/participatory_process_attachments/show.html.erb +25 -0
- data/decidim-admin/app/views/decidim/admin/participatory_process_steps/_form.html.erb +2 -2
- data/decidim-admin/app/views/decidim/admin/participatory_process_steps/edit.html.erb +1 -3
- data/decidim-admin/app/views/decidim/admin/participatory_process_steps/{_table.html.erb → index.html.erb} +15 -11
- data/decidim-admin/app/views/decidim/admin/participatory_process_steps/new.html.erb +1 -3
- data/decidim-admin/app/views/decidim/admin/participatory_process_steps/show.html.erb +1 -4
- data/decidim-admin/app/views/decidim/admin/participatory_process_user_roles/index.html.erb +34 -0
- data/decidim-admin/app/views/decidim/admin/participatory_processes/_form.html.erb +2 -2
- data/decidim-admin/app/views/decidim/admin/participatory_processes/edit.html.erb +13 -3
- data/decidim-admin/app/views/decidim/admin/participatory_processes/index.html.erb +5 -14
- data/decidim-admin/app/views/decidim/admin/participatory_processes/show.html.erb +19 -36
- data/decidim-admin/app/views/decidim/admin/scopes/_form.html.erb +3 -0
- data/decidim-admin/app/views/decidim/admin/scopes/edit.html.erb +11 -0
- data/decidim-admin/app/views/decidim/admin/scopes/index.html.erb +38 -0
- data/decidim-admin/app/views/decidim/admin/scopes/new.html.erb +11 -0
- data/decidim-admin/app/views/decidim/admin/static_pages/_form.html.erb +13 -0
- data/decidim-admin/app/views/decidim/admin/static_pages/edit.html.erb +11 -0
- data/decidim-admin/app/views/decidim/admin/static_pages/index.html.erb +40 -0
- data/decidim-admin/app/views/decidim/admin/static_pages/new.html.erb +11 -0
- data/decidim-admin/app/views/decidim/admin/static_pages/show.html.erb +22 -0
- data/decidim-admin/app/views/layouts/decidim/admin/_application.html.erb +40 -0
- data/decidim-admin/app/views/layouts/decidim/admin/_sidebar.html.erb +5 -2
- data/decidim-admin/app/views/layouts/decidim/admin/application.html.erb +3 -40
- data/decidim-admin/app/views/layouts/decidim/admin/participatory_process.html.erb +54 -0
- data/decidim-admin/config/i18n-tasks.yml +3 -2
- data/decidim-admin/config/locales/ca.yml +138 -6
- data/decidim-admin/config/locales/en.yml +191 -13
- data/decidim-admin/config/locales/es.yml +139 -7
- data/decidim-admin/config/routes.rb +23 -1
- data/decidim-admin/db/migrate/20161102144648_add_admin_participatory_process_user_roles.rb +15 -0
- data/decidim-admin/db/seeds.rb +21 -0
- data/decidim-admin/decidim-admin.gemspec +6 -11
- data/decidim-admin/lib/decidim/admin.rb +1 -0
- data/decidim-admin/lib/decidim/admin/engine.rb +10 -3
- data/decidim-admin/lib/decidim/admin/features.rb +10 -0
- data/decidim-admin/lib/decidim/admin/features/base_controller.rb +33 -0
- data/decidim-admin/spec/commands/create_category_spec.rb +61 -0
- data/decidim-admin/spec/commands/create_feature_spec.rb +60 -0
- data/decidim-admin/spec/commands/create_participatory_process_admin_spec.rb +42 -0
- data/decidim-admin/spec/commands/create_participatory_process_spec.rb +37 -0
- data/decidim-admin/spec/commands/create_scope_spec.rb +24 -0
- data/decidim-admin/spec/commands/create_static_page_spec.rb +42 -0
- data/decidim-admin/spec/commands/destroy_category_spec.rb +46 -0
- data/decidim-admin/spec/commands/destroy_feature_spec.rb +31 -0
- data/decidim-admin/spec/commands/update_category_spec.rb +64 -0
- data/decidim-admin/spec/commands/update_organization_spec.rb +73 -0
- data/decidim-admin/spec/commands/update_scope_spec.rb +24 -0
- data/decidim-admin/spec/commands/update_static_page_spec.rb +50 -0
- data/decidim-admin/spec/controllers/static_pages_controller_spec.rb +50 -0
- data/decidim-admin/spec/factories.rb +8 -0
- data/decidim-admin/spec/features/admin_invite_spec.rb +6 -2
- data/decidim-admin/spec/features/admin_manages_features_spec.rb +75 -0
- data/decidim-admin/spec/features/admin_manages_organization_scopes_spec.rb +80 -0
- data/decidim-admin/spec/features/admin_manages_organization_spec.rb +38 -0
- data/decidim-admin/spec/features/admin_manages_participatory_process_admins_spec.rb +10 -0
- data/decidim-admin/spec/features/admin_manages_participatory_process_attachments_spec.rb +10 -0
- data/decidim-admin/spec/features/admin_manages_participatory_process_categories_spec.rb +18 -0
- data/decidim-admin/spec/features/admin_manages_participatory_process_steps_spec.rb +10 -0
- data/decidim-admin/spec/features/admin_manages_participatory_processes_spec.rb +95 -0
- data/decidim-admin/spec/features/participatory_process_admin_manages_participatory_process_admins_spec.rb +27 -0
- data/decidim-admin/spec/features/participatory_process_admin_manages_participatory_process_attachments_spec.rb +13 -0
- data/decidim-admin/spec/features/participatory_process_admin_manages_participatory_process_steps_spec.rb +12 -0
- data/decidim-admin/spec/features/participatory_process_admin_manages_participatory_processes_spec.rb +36 -0
- data/decidim-admin/spec/features/process_admin_manages_participatory_process_categories_spec.rb +20 -0
- data/decidim-admin/spec/features/static_pages_spec.rb +120 -0
- data/decidim-admin/spec/forms/category_form_spec.rb +94 -0
- data/decidim-admin/spec/forms/organization_form_spec.rb +60 -0
- data/decidim-admin/spec/forms/participatory_process_form_spec.rb +19 -6
- data/decidim-admin/spec/forms/participatory_process_step_form_spec.rb +21 -1
- data/decidim-admin/spec/forms/participatory_process_user_role_form_spec.rb +29 -0
- data/decidim-admin/spec/forms/scope_form_spec.rb +60 -0
- data/decidim-admin/spec/forms/static_page_form_spec.rb +97 -0
- data/decidim-admin/spec/helpers/aria_selected_link_to_helper_spec.rb +46 -0
- data/decidim-admin/spec/models/abilities/admin_user_spec.rb +62 -0
- data/decidim-admin/spec/models/abilities/participatory_process_admin_spec.rb +50 -0
- data/decidim-admin/spec/models/participatory_process_user_role_spec.rb +21 -0
- data/decidim-admin/spec/queries/manageable_participatory_processes_for_user_spec.rb +30 -0
- data/decidim-admin/spec/queries/process_admin_roles_for_process_spec.rb +17 -0
- data/decidim-admin/spec/shared/manage_process_admins_examples.rb +56 -0
- data/decidim-admin/spec/shared/manage_process_attachments_examples.rb +105 -0
- data/decidim-admin/spec/shared/manage_process_categories_examples.rb +129 -0
- data/decidim-admin/spec/shared/manage_process_steps_examples.rb +153 -0
- data/decidim-admin/spec/shared/manage_processes_examples.rb +139 -0
- data/decidim-admin/spec/shared/participatory_admin_shared_context.rb +19 -0
- data/decidim-admin/spec/spec_helper.rb +4 -0
- data/decidim-admin/spec/support/processes_menu_links_helpers.rb +12 -0
- data/decidim-admin/spec/views/decidim/static_pages/_form.html.erb_spec.rb +35 -0
- data/decidim-admin/vendor/assets/javascripts/html.sortable.js +691 -0
- data/decidim-api/README.md +11 -10
- data/decidim-api/Rakefile +0 -25
- data/decidim-api/app/assets/config/decidim_api_manifest.js +1 -0
- data/decidim-api/app/assets/javascripts/decidim/api/docs.js.es6 +23 -0
- data/decidim-api/app/controllers/decidim/api/documentation_controller.rb +10 -0
- data/decidim-api/app/controllers/decidim/api/queries_controller.rb +3 -2
- data/decidim-api/app/views/decidim/api/documentation/show.html.erb +10 -0
- data/decidim-api/app/views/layouts/decidim/api/documentation.html.erb +9 -0
- data/decidim-api/config/routes.rb +4 -3
- data/decidim-api/decidim-api.gemspec +6 -9
- data/decidim-api/lib/decidim/api.rb +7 -0
- data/decidim-api/lib/decidim/api/engine.rb +14 -0
- data/decidim-api/lib/decidim/api/graphiql-initial-query.txt +11 -0
- data/decidim-api/{app/schemas → lib}/decidim/api/schema.rb +1 -0
- data/decidim-api/lib/decidim/api/test/type_context.rb +41 -0
- data/decidim-api/{app/types/decidim/api/localized_string_type.rb → lib/decidim/api/types/localized_string.rb} +1 -1
- data/decidim-api/lib/decidim/api/types/mutation.rb +10 -0
- data/decidim-api/lib/decidim/api/types/query.rb +10 -0
- data/decidim-api/{app/types/decidim/api/translated_field_type.rb → lib/decidim/api/types/translated_field.rb} +2 -2
- data/decidim-api/spec/factories.rb +1 -0
- data/decidim-api/spec/features/documentation_spec.rb +22 -0
- data/decidim-api/spec/features/graphiql_spec.rb +22 -0
- data/decidim-api/spec/types/localized_string_type_spec.rb +2 -1
- data/decidim-api/spec/types/mutation_type_spec.rb +38 -0
- data/decidim-api/spec/types/query_type_spec.rb +2 -1
- data/decidim-api/spec/types/translated_field_type_spec.rb +2 -1
- data/decidim-api/vendor/assets/javascripts/decidim/api/graphql-docs.js +3518 -0
- data/decidim-api/vendor/assets/javascripts/decidim/api/react-dom.js +42 -0
- data/decidim-api/vendor/assets/javascripts/decidim/api/react.js +20595 -0
- data/decidim-comments/.gitignore +2 -0
- data/decidim-comments/Gemfile +6 -0
- data/decidim-comments/README.md +42 -0
- data/decidim-comments/Rakefile +2 -0
- data/decidim-comments/app/assets/config/decidim_comments_manifest.js +1 -0
- data/decidim-comments/app/assets/javascripts/decidim/comments/bundle.js +0 -0
- data/decidim-comments/app/assets/javascripts/decidim/comments/comments.js.erb +8 -0
- data/decidim-comments/app/commands/decidim/comments/create_comment.rb +40 -0
- data/decidim-comments/app/forms/decidim/comments/comment_form.rb +16 -0
- data/decidim-comments/app/frontend/application/apollo_client.js +16 -0
- data/decidim-comments/app/frontend/application/application.component.jsx +37 -0
- data/decidim-comments/app/frontend/application/application.component.test.jsx +33 -0
- data/decidim-comments/app/frontend/application/icon.component.jsx +21 -0
- data/decidim-comments/app/frontend/application/icon.component.test.jsx +43 -0
- data/decidim-comments/app/frontend/comments/add_comment_form.component.jsx +250 -0
- data/decidim-comments/app/frontend/comments/add_comment_form.component.test.jsx +173 -0
- data/decidim-comments/app/frontend/comments/add_comment_form.mutation.graphql +8 -0
- data/decidim-comments/app/frontend/comments/comment.component.jsx +202 -0
- data/decidim-comments/app/frontend/comments/comment.component.test.jsx +125 -0
- data/decidim-comments/app/frontend/comments/comment.fragment.graphql +12 -0
- data/decidim-comments/app/frontend/comments/comment_data.fragment.graphql +11 -0
- data/decidim-comments/app/frontend/comments/comment_order_selector.component.jsx +28 -0
- data/decidim-comments/app/frontend/comments/comment_order_selector.component.test.jsx +9 -0
- data/decidim-comments/app/frontend/comments/comment_thread.component.jsx +64 -0
- data/decidim-comments/app/frontend/comments/comment_thread.component.test.jsx +71 -0
- data/decidim-comments/app/frontend/comments/comment_thread.fragment.graphql +9 -0
- data/decidim-comments/app/frontend/comments/comments.component.jsx +139 -0
- data/decidim-comments/app/frontend/comments/comments.component.test.jsx +106 -0
- data/decidim-comments/app/frontend/comments/comments.query.graphql +10 -0
- data/decidim-comments/app/frontend/comments/featured_comment.component.jsx +23 -0
- data/decidim-comments/app/frontend/comments/featured_comment.component.test.jsx +15 -0
- data/decidim-comments/app/frontend/entry.js +24 -0
- data/decidim-comments/app/frontend/entry.test.js +29 -0
- data/decidim-comments/app/frontend/support/asset_url.js +11 -0
- data/decidim-comments/app/frontend/support/generate_comments_data.js +29 -0
- data/decidim-comments/app/frontend/support/generate_current_user_data.js +13 -0
- data/decidim-comments/app/frontend/support/load_translations.js +23 -0
- data/decidim-comments/app/frontend/support/require_all.js +10 -0
- data/decidim-comments/app/frontend/support/resolve_graphql_query.js +37 -0
- data/decidim-comments/app/frontend/support/stub_component.js +29 -0
- data/decidim-comments/app/helpers/decidim/comments/comments_helper.rb +51 -0
- data/decidim-comments/app/models/decidim/comments/comment.rb +55 -0
- data/decidim-comments/app/types/decidim/comments/add_comment_type.rb +12 -0
- data/decidim-comments/app/types/decidim/comments/author_type.rb +15 -0
- data/decidim-comments/app/types/decidim/comments/comment_type.rb +28 -0
- data/decidim-comments/bin/rails +14 -0
- data/decidim-comments/config/i18n-tasks.yml +124 -0
- data/decidim-comments/config/locales/ca.yml +35 -0
- data/decidim-comments/config/locales/en.yml +36 -0
- data/decidim-comments/config/locales/es.yml +35 -0
- data/decidim-comments/db/migrate/20161130143508_create_comments.rb +11 -0
- data/decidim-comments/db/migrate/20161214082645_add_depth_to_comments.rb +5 -0
- data/decidim-comments/db/migrate/20161216102820_add_alignment_to_comments.rb +5 -0
- data/decidim-comments/db/seeds.rb +11 -0
- data/decidim-comments/decidim-comments.gemspec +25 -0
- data/decidim-comments/lib/decidim/comments.rb +10 -0
- data/decidim-comments/lib/decidim/comments/engine.rb +34 -0
- data/decidim-comments/lib/decidim/comments/mutation_extensions.rb +36 -0
- data/decidim-comments/lib/decidim/comments/query_extensions.rb +33 -0
- data/decidim-comments/package.json +21 -0
- data/decidim-comments/spec/commands/create_comment_spec.rb +64 -0
- data/decidim-comments/spec/factories.rb +9 -0
- data/decidim-comments/spec/features/comments_spec.rb +97 -0
- data/decidim-comments/spec/forms/comment_form_spec.rb +48 -0
- data/decidim-comments/spec/helpers/comments_helper_spec.rb +48 -0
- data/decidim-comments/spec/models/comment_spec.rb +64 -0
- data/decidim-comments/spec/spec_helper.rb +2 -0
- data/decidim-comments/spec/support/dummy.rb +20 -0
- data/decidim-comments/spec/types/author_type_spec.rb +21 -0
- data/decidim-comments/spec/types/comment_type_spec.rb +51 -0
- data/decidim-comments/spec/types/query_type_spec.rb +49 -0
- data/decidim-dev/decidim-dev.gemspec +11 -7
- data/decidim-dev/lib/decidim/common_rake.rb +20 -6
- data/decidim-dev/lib/decidim/dummy_authorization_handler.rb +9 -2
- data/decidim-dev/lib/decidim/test/base_spec_helper.rb +25 -6
- data/decidim-dev/lib/decidim/test/i18n_spec.rb +1 -1
- data/decidim-dev/lib/decidim/test/rspec_support/capybara.rb +66 -5
- data/decidim-dev/lib/decidim/test/rspec_support/database_cleaner.rb +2 -2
- data/decidim-dev/lib/decidim/test/rspec_support/feature.rb +22 -0
- data/decidim-dev/lib/decidim/test/rspec_support/feature_context.rb +44 -0
- data/decidim-dev/lib/decidim/test/rspec_support/helpers.rb +42 -0
- data/decidim-dev/lib/decidim/test/rspec_support/translation_helpers.rb +63 -0
- data/decidim-dev/spec/support/Exampledocument.docx +0 -0
- data/decidim-dev/spec/support/Exampledocument.odt +0 -0
- data/decidim-dev/spec/support/Exampledocument.pdf +0 -0
- data/decidim-dev/spec/support/avatar.svg +14 -0
- data/decidim-dev/spec/support/malicious.jpg +0 -0
- data/decidim-meetings/.gitignore +7 -0
- data/decidim-meetings/README.md +23 -0
- data/decidim-meetings/Rakefile +2 -0
- data/decidim-meetings/app/commands/decidim/meetings/admin/create_meeting.rb +40 -0
- data/decidim-meetings/app/commands/decidim/meetings/admin/update_meeting.rb +44 -0
- data/decidim-meetings/app/controllers/decidim/meetings/admin/application_controller.rb +14 -0
- data/decidim-meetings/app/controllers/decidim/meetings/admin/meetings_controller.rb +69 -0
- data/decidim-meetings/app/controllers/decidim/meetings/application_controller.rb +13 -0
- data/decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb +24 -0
- data/decidim-meetings/app/forms/decidim/meetings/admin/meeting_form.rb +30 -0
- data/decidim-meetings/app/models/decidim/meetings/application_record.rb +9 -0
- data/decidim-meetings/app/models/decidim/meetings/meeting.rb +12 -0
- data/decidim-meetings/app/views/decidim/meetings/admin/meetings/_form.html.erb +32 -0
- data/decidim-meetings/app/views/decidim/meetings/admin/meetings/edit.html.erb +9 -0
- data/decidim-meetings/app/views/decidim/meetings/admin/meetings/index.html.erb +39 -0
- data/decidim-meetings/app/views/decidim/meetings/admin/meetings/new.html.erb +9 -0
- data/decidim-meetings/app/views/decidim/meetings/meetings/_address_details.html.erb +5 -0
- data/decidim-meetings/app/views/decidim/meetings/meetings/index.html.erb +30 -0
- data/decidim-meetings/app/views/decidim/meetings/meetings/show.html.erb +39 -0
- data/decidim-meetings/bin/rails +14 -0
- data/decidim-meetings/config/i18n-tasks.yml +4 -0
- data/decidim-meetings/config/locales/ca.yml +44 -0
- data/decidim-meetings/config/locales/en.yml +45 -0
- data/decidim-meetings/config/locales/es.yml +44 -0
- data/decidim-meetings/db/migrate/20161130121354_create_meetings.rb +18 -0
- data/decidim-meetings/decidim-meetings.gemspec +21 -0
- data/decidim-meetings/lib/decidim/meetings.rb +11 -0
- data/decidim-meetings/lib/decidim/meetings/admin.rb +9 -0
- data/decidim-meetings/lib/decidim/meetings/admin_engine.rb +22 -0
- data/decidim-meetings/lib/decidim/meetings/feature.rb +42 -0
- data/decidim-meetings/lib/decidim/meetings/list_engine.rb +16 -0
- data/decidim-meetings/spec/commands/create_meeting_spec.rb +38 -0
- data/decidim-meetings/spec/commands/update_meeting_spec.rb +36 -0
- data/decidim-meetings/spec/factories.rb +16 -0
- data/decidim-meetings/spec/features/admin_manages_meetings_spec.rb +16 -0
- data/decidim-meetings/spec/features/explore_meetings_spec.rb +54 -0
- data/decidim-meetings/spec/features/process_admin_manages_meetings_spec.rb +17 -0
- data/decidim-meetings/spec/forms/meeting_form_spec.rb +115 -0
- data/decidim-meetings/spec/models/meeting_spec.rb +10 -0
- data/decidim-meetings/spec/shared/admin_shared_context.rb +9 -0
- data/decidim-meetings/spec/shared/manage_meetings_examples.rb +118 -0
- data/decidim-meetings/spec/spec_helper.rb +2 -0
- data/decidim-pages/.gitignore +3 -0
- data/decidim-pages/README.md +24 -0
- data/decidim-pages/Rakefile +2 -0
- data/decidim-pages/app/commands/decidim/pages/admin/update_page.rb +39 -0
- data/decidim-pages/app/commands/decidim/pages/create_page.rb +21 -0
- data/decidim-pages/app/commands/decidim/pages/destroy_page.rb +17 -0
- data/decidim-pages/app/controllers/decidim/pages/admin/application_controller.rb +13 -0
- data/decidim-pages/app/controllers/decidim/pages/admin/pages_controller.rb +35 -0
- data/decidim-pages/app/controllers/decidim/pages/application_controller.rb +16 -0
- data/decidim-pages/app/forms/decidim/pages/admin/page_form.rb +17 -0
- data/decidim-pages/app/helpers/decidim/pages/application_helper.rb +10 -0
- data/decidim-pages/app/models/decidim/pages/application_record.rb +9 -0
- data/decidim-pages/app/models/decidim/pages/page.rb +12 -0
- data/decidim-pages/app/views/decidim/pages/admin/pages/_form.html.erb +5 -0
- data/decidim-pages/app/views/decidim/pages/admin/pages/edit.html.erb +9 -0
- data/decidim-pages/app/views/decidim/pages/application/show.html.erb +16 -0
- data/decidim-pages/bin/rails +14 -0
- data/decidim-pages/config/i18n-tasks.yml +4 -0
- data/decidim-pages/config/locales/ca.yml +19 -0
- data/decidim-pages/config/locales/en.yml +20 -0
- data/decidim-pages/config/locales/es.yml +19 -0
- data/decidim-pages/db/migrate/20161116121353_create_decidim_pages.rb +11 -0
- data/decidim-pages/db/migrate/20161214150429_add_commentable_to_pages.rb +5 -0
- data/decidim-pages/decidim-pages.gemspec +21 -0
- data/decidim-pages/lib/decidim/pages.rb +12 -0
- data/decidim-pages/lib/decidim/pages/admin.rb +9 -0
- data/decidim-pages/lib/decidim/pages/admin_engine.rb +21 -0
- data/decidim-pages/lib/decidim/pages/engine.rb +15 -0
- data/decidim-pages/lib/decidim/pages/feature.rb +41 -0
- data/decidim-pages/lib/tasks/decidim/pages_tasks.rake +1 -0
- data/decidim-pages/spec/commands/create_page_spec.rb +46 -0
- data/decidim-pages/spec/commands/destroy_page_spec.rb +24 -0
- data/decidim-pages/spec/commands/update_page_spec.rb +57 -0
- data/decidim-pages/spec/factories.rb +10 -0
- data/decidim-pages/spec/features/admin_spec.rb +71 -0
- data/decidim-pages/spec/features/page_show_spec.rb +67 -0
- data/decidim-pages/spec/forms/page_form_spec.rb +63 -0
- data/decidim-pages/spec/models/page_spec.rb +18 -0
- data/decidim-pages/spec/spec_helper.rb +2 -0
- data/decidim-proposals/.gitignore +3 -0
- data/decidim-proposals/README.md +24 -0
- data/decidim-proposals/Rakefile +2 -0
- data/decidim-proposals/app/commands/decidim/proposals/admin/create_proposal.rb +43 -0
- data/decidim-proposals/app/commands/decidim/proposals/create_proposal.rb +42 -0
- data/decidim-proposals/app/controllers/decidim/proposals/admin/application_controller.rb +14 -0
- data/decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb +37 -0
- data/decidim-proposals/app/controllers/decidim/proposals/application_controller.rb +13 -0
- data/decidim-proposals/app/controllers/decidim/proposals/proposals_controller.rb +41 -0
- data/decidim-proposals/app/forms/decidim/proposals/admin/proposal_form.rb +38 -0
- data/decidim-proposals/app/forms/decidim/proposals/proposal_form.rb +37 -0
- data/decidim-proposals/app/helpers/decidim/proposals/application_helper.rb +10 -0
- data/decidim-proposals/app/models/decidim/proposals/application_record.rb +9 -0
- data/decidim-proposals/app/models/decidim/proposals/proposal.rb +53 -0
- data/decidim-proposals/app/services/decidim/proposals/proposal_search.rb +36 -0
- data/decidim-proposals/app/views/decidim/proposals/admin/proposals/_form.html.erb +19 -0
- data/decidim-proposals/app/views/decidim/proposals/admin/proposals/index.html.erb +34 -0
- data/decidim-proposals/app/views/decidim/proposals/admin/proposals/new.html.erb +9 -0
- data/decidim-proposals/app/views/decidim/proposals/proposals/_proposal.html.erb +34 -0
- data/decidim-proposals/app/views/decidim/proposals/proposals/index.html.erb +23 -0
- data/decidim-proposals/app/views/decidim/proposals/proposals/new.html.erb +40 -0
- data/decidim-proposals/app/views/decidim/proposals/proposals/show.html.erb +37 -0
- data/decidim-proposals/bin/rails +14 -0
- data/decidim-proposals/config/i18n-tasks.yml +4 -0
- data/decidim-proposals/config/locales/ca.yml +46 -0
- data/decidim-proposals/config/locales/en.yml +47 -0
- data/decidim-proposals/config/locales/es.yml +46 -0
- data/decidim-proposals/db/migrate/20161212110850_create_decidim_proposals.rb +14 -0
- data/decidim-proposals/decidim-proposals.gemspec +22 -0
- data/decidim-proposals/lib/decidim/proposals.rb +12 -0
- data/decidim-proposals/lib/decidim/proposals/admin.rb +9 -0
- data/decidim-proposals/lib/decidim/proposals/admin_engine.rb +20 -0
- data/decidim-proposals/lib/decidim/proposals/engine.rb +18 -0
- data/decidim-proposals/lib/decidim/proposals/feature.rb +35 -0
- data/decidim-proposals/spec/commands/decidim/proposals/create_proposal_spec.rb +58 -0
- data/decidim-proposals/spec/factories.rb +18 -0
- data/decidim-proposals/spec/features/admin_manages_proposals_spec.rb +16 -0
- data/decidim-proposals/spec/features/process_admin_manages_proposals_spec.rb +17 -0
- data/decidim-proposals/spec/features/proposals_spec.rb +117 -0
- data/decidim-proposals/spec/forms/decidim/proposals/proposal_form_spec.rb +104 -0
- data/decidim-proposals/spec/lib/decidim/proposals/feature_spec.rb +31 -0
- data/decidim-proposals/spec/models/decidim/proposals/proposal_spec.rb +30 -0
- data/decidim-proposals/spec/services/decidim/proposals/proposal_search_spec.rb +62 -0
- data/decidim-proposals/spec/shared/admin_shared_context.rb +11 -0
- data/decidim-proposals/spec/shared/manage_proposals_examples.rb +40 -0
- data/decidim-proposals/spec/spec_helper.rb +2 -0
- data/decidim-system/Rakefile +0 -25
- data/decidim-system/app/assets/javascripts/decidim/system/application.js.es6 +6 -5
- data/decidim-system/app/assets/stylesheets/decidim/system/application.scss +7 -2
- data/decidim-system/app/commands/decidim/system/create_admin.rb +1 -1
- data/decidim-system/app/commands/decidim/system/create_default_pages.rb +43 -0
- data/decidim-system/app/commands/decidim/system/register_organization.rb +4 -2
- data/decidim-system/app/commands/decidim/system/update_admin.rb +1 -1
- data/decidim-system/app/commands/decidim/system/update_organization.rb +1 -2
- data/decidim-system/app/controllers/decidim/system/admins_controller.rb +4 -4
- data/decidim-system/app/controllers/decidim/system/application_controller.rb +1 -0
- data/decidim-system/app/controllers/decidim/system/organizations_controller.rb +4 -4
- data/decidim-system/app/forms/decidim/system/admin_form.rb +1 -1
- data/decidim-system/app/forms/decidim/system/register_organization_form.rb +6 -5
- data/decidim-system/app/forms/decidim/system/update_organization_form.rb +1 -3
- data/decidim-system/app/helpers/decidim/system/application_helper.rb +2 -0
- data/decidim-system/app/views/decidim/system/organizations/edit.html.erb +0 -4
- data/decidim-system/app/views/decidim/system/organizations/new.html.erb +23 -3
- data/decidim-system/config/i18n-tasks.yml +3 -1
- data/decidim-system/config/locales/ca.yml +15 -10
- data/decidim-system/config/locales/en.yml +6 -0
- data/decidim-system/config/locales/es.yml +11 -6
- data/decidim-system/db/seeds.rb +5 -2
- data/decidim-system/decidim-system.gemspec +6 -10
- data/decidim-system/lib/decidim/system/engine.rb +7 -2
- data/decidim-system/spec/commands/decidim/system/create_default_pages_spec.rb +30 -0
- data/decidim-system/spec/commands/decidim/system/register_organization_spec.rb +9 -3
- data/decidim-system/spec/features/organizations_spec.rb +4 -3
- data/decidim.gemspec +7 -8
- data/docs/features_and_components.md +45 -0
- data/docs/how_to_create_a_plugin.md +183 -0
- data/jsconfig.json +3 -0
- data/karma.conf.js +43 -0
- data/lib/decidim.rb +4 -0
- data/lib/generators/decidim/app_builder.rb +2 -0
- data/lib/generators/decidim/demo_generator.rb +27 -0
- data/lib/generators/decidim/docker_generator.rb +65 -0
- data/lib/generators/decidim/install_generator.rb +4 -25
- data/lib/generators/decidim/templates/Dockerfile.dev.erb +21 -0
- data/lib/generators/decidim/templates/app.json.erb +4 -1
- data/lib/generators/decidim/templates/initializer.rb +3 -0
- data/package.json +53 -8
- data/run_ci.sh +3 -0
- data/webpack.config.js +66 -0
- data/yarn.lock +4665 -456
- metadata +437 -35
- data/decidim-admin/LICENSE.txt +0 -619
- data/decidim-admin/app/models/decidim/admin/abilities/admin.rb +0 -21
- data/decidim-admin/spec/features/manage_participatory_process_steps_spec.rb +0 -151
- data/decidim-admin/spec/features/manage_participatory_processes_spec.rb +0 -227
- data/decidim-admin/spec/models/abilities/admin_spec.rb +0 -25
- data/decidim-admin/vendor/assets/javascripts/html.sortable.min.js +0 -2
- data/decidim-api/LICENSE.txt +0 -619
- data/decidim-api/app/types/decidim/api/process_step_type.rb +0 -26
- data/decidim-api/app/types/decidim/api/process_type.rb +0 -18
- data/decidim-api/app/types/decidim/api/query_type.rb +0 -19
- data/decidim-api/spec/schemas/schema_spec.rb +0 -38
- data/decidim-api/spec/support/type_helpers.rb +0 -46
- data/decidim-api/spec/types/process_step_type_spec.rb +0 -50
- data/decidim-api/spec/types/process_type_spec.rb +0 -39
- data/decidim-system/LICENSE.txt +0 -619
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
module Decidim
|
5
|
+
module Comments
|
6
|
+
describe CreateComment, :db do
|
7
|
+
describe "call" do
|
8
|
+
let(:organization) { create(:organization) }
|
9
|
+
let(:author) { create(:user, organization: organization) }
|
10
|
+
let(:commentable) { create :participatory_process, organization: organization }
|
11
|
+
let(:body) { ::Faker::Lorem.paragraph }
|
12
|
+
let(:alignment) { 1 }
|
13
|
+
let(:form_params) do
|
14
|
+
{
|
15
|
+
"comment" => {
|
16
|
+
"body" => body,
|
17
|
+
"alignment" => alignment
|
18
|
+
}
|
19
|
+
}
|
20
|
+
end
|
21
|
+
let(:form) do
|
22
|
+
CommentForm.from_params(
|
23
|
+
form_params
|
24
|
+
)
|
25
|
+
end
|
26
|
+
let(:command) { described_class.new(form, author, commentable) }
|
27
|
+
|
28
|
+
describe "when the form is not valid" do
|
29
|
+
before do
|
30
|
+
expect(form).to receive(:invalid?).and_return(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "broadcasts invalid" do
|
34
|
+
expect { command.call }.to broadcast(:invalid)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "doesn't create a comment" do
|
38
|
+
expect do
|
39
|
+
command.call
|
40
|
+
end.to_not change { Comment.count }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "when the form is valid" do
|
45
|
+
it "broadcasts ok" do
|
46
|
+
expect { command.call }.to broadcast(:ok)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "creates a new comment" do
|
50
|
+
expect(Comment).to receive(:create!).with({
|
51
|
+
author: author,
|
52
|
+
commentable: commentable,
|
53
|
+
body: body,
|
54
|
+
alignment: alignment
|
55
|
+
}).and_call_original
|
56
|
+
expect do
|
57
|
+
command.call
|
58
|
+
end.to change { Comment.count }.by(1)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require_relative "../../decidim-core/spec/factories"
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :comment, class: Decidim::Comments::Comment do
|
5
|
+
author { build(:user, organization: commentable.organization) }
|
6
|
+
commentable { build(:participatory_process) }
|
7
|
+
body { Faker::Lorem.paragraph }
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe "Comments", type: :feature do
|
5
|
+
let!(:organization) { create(:organization) }
|
6
|
+
let!(:user) { create(:user, :confirmed, organization: organization) }
|
7
|
+
let!(:participatory_process) { create(:participatory_process, organization: organization) }
|
8
|
+
let!(:comments) {
|
9
|
+
3.times.map do
|
10
|
+
create(:comment, commentable: participatory_process)
|
11
|
+
end
|
12
|
+
}
|
13
|
+
|
14
|
+
before do
|
15
|
+
switch_to_host(organization.host)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "user should see a list of comments" do
|
19
|
+
visit decidim.dummy_path(participatory_process)
|
20
|
+
|
21
|
+
expect(page).to have_selector("#comments")
|
22
|
+
expect(page).to have_selector("article.comment", count: comments.length)
|
23
|
+
|
24
|
+
within "#comments" do
|
25
|
+
comments.each do |comment|
|
26
|
+
expect(page).to have_content comment.author.name
|
27
|
+
expect(page).to have_content comment.body
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "when not authenticated" do
|
33
|
+
it "user should not see the form to add comments" do
|
34
|
+
visit decidim.dummy_path(participatory_process)
|
35
|
+
expect(page).to_not have_selector(".add-comment form")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when authenticated" do
|
40
|
+
before do
|
41
|
+
login_as user, scope: :user
|
42
|
+
end
|
43
|
+
|
44
|
+
it "user should not see the form to add comments" do
|
45
|
+
visit decidim.dummy_path(participatory_process)
|
46
|
+
expect(page).to have_selector(".add-comment form")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "user can add a new comment" do
|
50
|
+
visit decidim.dummy_path(participatory_process)
|
51
|
+
expect(page).to have_selector(".add-comment form")
|
52
|
+
|
53
|
+
within ".add-comment form" do
|
54
|
+
fill_in "add-comment-#{participatory_process.class.name}-#{participatory_process.id}", with: "This is a new comment"
|
55
|
+
click_button "Send"
|
56
|
+
end
|
57
|
+
|
58
|
+
within "#comments" do
|
59
|
+
expect(page).to have_content user.name
|
60
|
+
expect(page).to have_content "This is a new comment"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it "user can reply a comment" do
|
65
|
+
comment = create(:comment, commentable: participatory_process)
|
66
|
+
visit decidim.dummy_path(participatory_process)
|
67
|
+
|
68
|
+
expect(page).to have_selector(".comment__reply")
|
69
|
+
|
70
|
+
within "#comments #comment_#{comment.id}" do
|
71
|
+
click_button "Reply"
|
72
|
+
fill_in "add-comment-#{comment.class.name}-#{comment.id}", with: "This is a reply"
|
73
|
+
click_button "Send"
|
74
|
+
|
75
|
+
expect(page).to have_content "This is a reply"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "when arguable option is enabled" do
|
80
|
+
it "user can comment in favor" do
|
81
|
+
visit decidim.dummy_path(participatory_process, arguable: true)
|
82
|
+
expect(page).to have_selector(".add-comment form")
|
83
|
+
|
84
|
+
click_button "I am in favor"
|
85
|
+
|
86
|
+
within ".add-comment form" do
|
87
|
+
fill_in "add-comment-#{participatory_process.class.name}-#{participatory_process.id}", with: "I am in favor about this!"
|
88
|
+
click_button "Send"
|
89
|
+
end
|
90
|
+
|
91
|
+
within "#comments" do
|
92
|
+
expect(page).to have_selector 'span.success.label', text: "In favor"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
module Decidim
|
5
|
+
module Comments
|
6
|
+
describe CommentForm do
|
7
|
+
let(:body) { "This is a new comment" }
|
8
|
+
let(:alignment) { 1 }
|
9
|
+
|
10
|
+
let(:attributes) do
|
11
|
+
{
|
12
|
+
"comment" => {
|
13
|
+
"body" => body,
|
14
|
+
"alignment" => alignment
|
15
|
+
}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
subject do
|
20
|
+
described_class.from_params(
|
21
|
+
attributes
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when everything is OK" do
|
26
|
+
it { is_expected.to be_valid }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when body is blank" do
|
30
|
+
let(:body) { "" }
|
31
|
+
|
32
|
+
it { is_expected.not_to be_valid }
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when alignment is not present" do
|
36
|
+
let(:alignment) { nil }
|
37
|
+
|
38
|
+
it { is_expected.to be_valid }
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when alignment is present and it is different from 0, 1 and -1" do
|
42
|
+
let(:alignment) { 2 }
|
43
|
+
|
44
|
+
it { is_expected.not_to be_valid }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
module Decidim
|
5
|
+
module Comments
|
6
|
+
describe CommentsHelper do
|
7
|
+
class DummyCommentable
|
8
|
+
def id
|
9
|
+
1
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:commentable) { DummyCommentable.new }
|
14
|
+
|
15
|
+
describe "comments_for" do
|
16
|
+
it "should render the react component `Comments` with the correct data" do
|
17
|
+
expect(helper)
|
18
|
+
.to receive(:react_comments_component)
|
19
|
+
.with("comments-for-DummyCommentable-1", {
|
20
|
+
commentableType: "Decidim::Comments::DummyCommentable",
|
21
|
+
commentableId: "1",
|
22
|
+
options: {},
|
23
|
+
locale: I18n.locale
|
24
|
+
})
|
25
|
+
.and_call_original
|
26
|
+
|
27
|
+
helper.comments_for(commentable)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should accept an optional hash of options" do
|
31
|
+
expect(helper)
|
32
|
+
.to receive(:react_comments_component)
|
33
|
+
.with("comments-for-DummyCommentable-1", {
|
34
|
+
commentableType: "Decidim::Comments::DummyCommentable",
|
35
|
+
commentableId: "1",
|
36
|
+
options: {
|
37
|
+
arguable: true
|
38
|
+
},
|
39
|
+
locale: I18n.locale
|
40
|
+
})
|
41
|
+
.and_call_original
|
42
|
+
|
43
|
+
helper.comments_for(commentable, arguable: true)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
module Decidim
|
5
|
+
module Comments
|
6
|
+
describe Comment do
|
7
|
+
let!(:commentable) { create(:participatory_process) }
|
8
|
+
let!(:comment) { create(:comment, commentable: commentable) }
|
9
|
+
let!(:replies) { 3.times.map { create(:comment, commentable: comment) } }
|
10
|
+
|
11
|
+
it "is valid" do
|
12
|
+
expect(comment).to be_valid
|
13
|
+
end
|
14
|
+
|
15
|
+
it "has an associated author" do
|
16
|
+
expect(comment.author).to be_a(Decidim::User)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "has an associated commentable" do
|
20
|
+
expect(comment.commentable).to be_a(Decidim::ParticipatoryProcess)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has a replies association" do
|
24
|
+
expect(comment.replies).to match_array(replies)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "is not valid if its parent is a comment and cannot have replies" do
|
28
|
+
expect(comment).to receive(:can_have_replies?).and_return false
|
29
|
+
expect(replies[0]).not_to be_valid
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should compute its depth before saving the model" do
|
33
|
+
expect(comment.depth).to eq(0)
|
34
|
+
comment.replies.each do |reply|
|
35
|
+
expect(reply.depth).to eq(1)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "is not valid if the author organization is different" do
|
40
|
+
foreign_user = build(:user)
|
41
|
+
comment = build(:comment, author: foreign_user)
|
42
|
+
|
43
|
+
expect(comment).to_not be_valid
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#can_have_replies?" do
|
47
|
+
it "should return true if the comment's depth is below MAX_DEPTH" do
|
48
|
+
comment.depth = Comment::MAX_DEPTH - 1
|
49
|
+
expect(comment.can_have_replies?).to be_truthy
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return false if the comment's depth is equal or greater than MAX_DEPTH" do
|
53
|
+
comment.depth = Comment::MAX_DEPTH
|
54
|
+
expect(comment.can_have_replies?).to be_falsy
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "is not valid if alignment is not 0, 1 or -1" do
|
59
|
+
comment.alignment = 2
|
60
|
+
expect(comment).not_to be_valid
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Decidim::Core::Engine.routes.draw do
|
2
|
+
mount Decidim::Api::Engine => "/api"
|
3
|
+
|
4
|
+
get '/dummy/:id' => 'dummy#show', as: :dummy
|
5
|
+
end
|
6
|
+
|
7
|
+
class Decidim::DummyController < Decidim::ApplicationController
|
8
|
+
helper Decidim::Comments::CommentsHelper
|
9
|
+
skip_authorization_check
|
10
|
+
|
11
|
+
def show
|
12
|
+
@participatory_process = Decidim::ParticipatoryProcess.find(params[:id])
|
13
|
+
@options = params.slice(:arguable)
|
14
|
+
@options.each { |key, val| @options[key] = val === 'true' }
|
15
|
+
render inline: %{
|
16
|
+
<%= javascript_include_tag 'application' %>
|
17
|
+
<%= comments_for(@participatory_process, @options) %>
|
18
|
+
}.html_safe
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
require "decidim/api/test/type_context"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Comments
|
7
|
+
describe AuthorType do
|
8
|
+
include_context "graphql type"
|
9
|
+
|
10
|
+
let(:model) { FactoryGirl.create(:user) }
|
11
|
+
|
12
|
+
describe "avatarUrl" do
|
13
|
+
let (:query) { "{ avatarUrl }" }
|
14
|
+
|
15
|
+
it "returns the user avatar url" do
|
16
|
+
expect(response).to include("avatarUrl" => model.avatar.url)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "spec_helper"
|
3
|
+
require "decidim/api/test/type_context"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Comments
|
7
|
+
describe CommentType do
|
8
|
+
include_context "graphql type"
|
9
|
+
|
10
|
+
let(:model) { FactoryGirl.create(:comment) }
|
11
|
+
|
12
|
+
describe "createdAt" do
|
13
|
+
let(:query) { "{ createdAt }" }
|
14
|
+
|
15
|
+
it "returns its created_at field" do
|
16
|
+
expect(response).to include("createdAt" => model.created_at.to_s)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "canHaveReplies" do
|
21
|
+
let (:query) { "{ canHaveReplies }" }
|
22
|
+
|
23
|
+
it "returns the return value of can_have_replies? method" do
|
24
|
+
expect(response).to include("canHaveReplies" => model.can_have_replies?)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "replies" do
|
29
|
+
let!(:random_comment) { FactoryGirl.create(:comment) }
|
30
|
+
let!(:replies) { 3.times.map { FactoryGirl.create(:comment, commentable: model) } }
|
31
|
+
|
32
|
+
let(:query) { "{ replies { id } }" }
|
33
|
+
|
34
|
+
it "return comment's replies comments data" do
|
35
|
+
replies.each do |reply|
|
36
|
+
expect(response["replies"]).to include("id" => reply.id.to_s)
|
37
|
+
end
|
38
|
+
expect(response["replies"]).to_not include("id" => random_comment.id.to_s)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "alignment" do
|
43
|
+
let(:query) { "{ alignment }" }
|
44
|
+
|
45
|
+
it "returns the alignment field" do
|
46
|
+
expect(response).to include("alignment" => model.alignment)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "spec_helper"
|
3
|
+
require "decidim/api/test/type_context"
|
4
|
+
|
5
|
+
describe Decidim::Api::QueryType do
|
6
|
+
include_context "graphql type"
|
7
|
+
|
8
|
+
describe "currentUser" do
|
9
|
+
let(:query) { "{ currentUser { name } } " }
|
10
|
+
|
11
|
+
context "When the user is logged in" do
|
12
|
+
it "return current user data" do
|
13
|
+
expect(response["currentUser"]).to include("name" => current_user.name)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "When the user is not logged in" do
|
18
|
+
let!(:current_user) { nil }
|
19
|
+
|
20
|
+
it "return a nil object" do
|
21
|
+
expect(response["currentUser"]).to be_nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "comments" do
|
27
|
+
let!(:participatory_process_1) { create(:participatory_process, organization: current_organization) }
|
28
|
+
let!(:comment_1) { create(:comment, commentable: participatory_process_1) }
|
29
|
+
let!(:comment_2) { create(:comment, commentable: participatory_process_1) }
|
30
|
+
let!(:participatory_process_2) { create(:participatory_process, organization: current_organization) }
|
31
|
+
let!(:comment_3) { create(:comment, commentable: participatory_process_2) }
|
32
|
+
|
33
|
+
let(:query) { "{ comments(commentableId: \"#{participatory_process_1.id}\", commentableType: \"Decidim::ParticipatoryProcess\") { id } }" }
|
34
|
+
|
35
|
+
it "returns comments from a commentable resource" do
|
36
|
+
expect(response["comments"]).to include("id" => comment_1.id.to_s)
|
37
|
+
expect(response["comments"]).to include("id" => comment_2.id.to_s)
|
38
|
+
expect(response["comments"]).to_not include("id" => comment_3.id.to_s)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns comments ordered by creation date" do
|
42
|
+
comment_2.update_attribute(:created_at, 2.days.ago)
|
43
|
+
comment_1.update_attribute(:created_at, 1.days.ago)
|
44
|
+
|
45
|
+
expect(response["comments"][0]["id"]).to eq comment_2.id.to_s
|
46
|
+
expect(response["comments"][1]["id"]).to eq comment_1.id.to_s
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|