decidim 0.0.2 → 0.0.3
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/.travis.yml +12 -0
- data/Dockerfile +2 -0
- data/Gemfile.lock +80 -54
- data/README.md +15 -2
- data/decidim-admin/app/assets/javascripts/decidim/admin/application.js.es6 +3 -2
- data/decidim-admin/app/assets/javascripts/decidim/admin/tab_focus.js.es6 +1 -1
- data/decidim-admin/app/assets/stylesheets/decidim/admin/_foundation_and_overrides.scss +1 -1
- data/decidim-admin/app/commands/decidim/admin/{create_participatory_process_attachment.rb → create_attachment.rb} +6 -7
- data/decidim-admin/app/commands/decidim/admin/create_participatory_process.rb +12 -3
- data/decidim-admin/app/commands/decidim/admin/{update_participatory_process_attachment.rb → update_attachment.rb} +7 -6
- data/decidim-admin/app/commands/decidim/admin/update_feature.rb +2 -1
- data/decidim-admin/app/commands/decidim/admin/update_organization.rb +1 -0
- data/decidim-admin/app/commands/decidim/admin/update_participatory_process.rb +16 -4
- data/decidim-admin/app/constraints/decidim/admin/organization_dashboard_constraint.rb +1 -1
- data/decidim-admin/app/controllers/decidim/admin/application_controller.rb +2 -2
- data/decidim-admin/app/controllers/decidim/admin/concerns/has_attachments.rb +116 -0
- data/decidim-admin/app/controllers/decidim/admin/participatory_process_attachments_controller.rb +5 -67
- data/decidim-admin/app/controllers/decidim/admin/users_controller.rb +5 -5
- data/decidim-admin/app/forms/decidim/admin/{participatory_process_attachment_form.rb → attachment_form.rb} +2 -2
- data/decidim-admin/app/forms/decidim/admin/feature_form.rb +1 -0
- data/decidim-admin/app/forms/decidim/admin/organization_form.rb +1 -0
- data/decidim-admin/app/forms/decidim/admin/participatory_process_form.rb +8 -1
- data/decidim-admin/app/helpers/decidim/admin/application_helper.rb +1 -0
- data/decidim-admin/app/helpers/decidim/admin/feature_settings_helper.rb +29 -0
- data/decidim-admin/app/models/decidim/admin/abilities/admin_user.rb +4 -4
- data/decidim-admin/app/models/decidim/admin/abilities/base.rb +3 -3
- data/decidim-admin/app/models/decidim/admin/abilities/participatory_process_admin.rb +15 -7
- data/decidim-admin/app/views/decidim/admin/{participatory_process_attachments → attachments}/_form.html.erb +0 -0
- data/decidim-admin/app/views/decidim/admin/attachments/edit.html.erb +9 -0
- data/decidim-admin/app/views/decidim/admin/attachments/index.html.erb +37 -0
- data/decidim-admin/app/views/decidim/admin/attachments/new.html.erb +9 -0
- data/decidim-admin/app/views/decidim/admin/attachments/show.html.erb +25 -0
- data/decidim-admin/app/views/decidim/admin/features/_form.html.erb +1 -0
- data/decidim-admin/app/views/decidim/admin/features/_settings_fields.html.erb +6 -3
- data/decidim-admin/app/views/decidim/admin/organization/_form.html.erb +4 -0
- data/decidim-admin/app/views/decidim/admin/participatory_processes/_form.html.erb +16 -0
- data/decidim-admin/app/views/decidim/admin/participatory_processes/show.html.erb +11 -1
- data/decidim-admin/app/views/layouts/decidim/admin/_header.html.erb +2 -2
- data/decidim-admin/app/views/layouts/decidim/admin/_sidebar.html.erb +1 -1
- data/decidim-admin/app/views/layouts/decidim/admin/participatory_process.html.erb +2 -2
- data/decidim-admin/config/locales/ca.yml +29 -27
- data/decidim-admin/config/locales/en.yml +29 -27
- data/decidim-admin/config/locales/es.yml +29 -27
- data/decidim-admin/config/routes.rb +1 -1
- data/decidim-admin/db/migrate/20170128112958_change_user_groups_verified_to_timestamp.rb +9 -0
- data/decidim-admin/decidim-admin.gemspec +0 -1
- data/decidim-admin/lib/decidim/admin/engine.rb +2 -2
- data/decidim-admin/lib/decidim/admin/test/manage_attachments_examples.rb +103 -0
- data/decidim-admin/spec/commands/create_category_spec.rb +1 -1
- data/decidim-admin/spec/commands/create_feature_spec.rb +1 -1
- data/decidim-admin/spec/commands/create_participatory_process_spec.rb +32 -2
- data/decidim-admin/spec/commands/create_static_page_spec.rb +1 -1
- data/decidim-admin/spec/commands/destroy_category_spec.rb +1 -1
- data/decidim-admin/spec/commands/destroy_feature_spec.rb +2 -2
- data/decidim-admin/spec/commands/destroy_participatory_process_step_spec.rb +1 -1
- data/decidim-admin/spec/commands/update_category_spec.rb +1 -1
- data/decidim-admin/spec/commands/update_feature_spec.rb +3 -1
- data/decidim-admin/spec/commands/update_organization_spec.rb +12 -2
- data/decidim-admin/spec/commands/update_static_page_spec.rb +1 -1
- data/decidim-admin/spec/features/admin_manages_organization_admins_spec.rb +1 -1
- data/decidim-admin/spec/features/admin_manages_organization_scopes_spec.rb +1 -1
- data/decidim-admin/spec/features/admin_manages_participatory_processes_spec.rb +1 -1
- data/decidim-admin/spec/features/static_pages_spec.rb +1 -1
- data/decidim-admin/spec/forms/participatory_process_form_spec.rb +32 -2
- data/decidim-admin/spec/forms/participatory_process_step_form_spec.rb +3 -3
- data/decidim-admin/spec/forms/scope_form_spec.rb +2 -2
- data/decidim-admin/spec/forms/static_page_form_spec.rb +2 -2
- data/decidim-admin/spec/helpers/feature_settings_helper_spec.rb +56 -0
- data/decidim-admin/spec/models/abilities/admin_user_spec.rb +7 -6
- data/decidim-admin/spec/models/abilities/participatory_process_admin_spec.rb +5 -8
- data/decidim-admin/spec/shared/manage_process_admins_examples.rb +1 -1
- data/decidim-admin/spec/shared/manage_process_attachments_examples.rb +4 -94
- data/decidim-admin/spec/shared/manage_process_categories_examples.rb +2 -1
- data/decidim-admin/spec/shared/manage_process_steps_examples.rb +1 -1
- data/decidim-admin/spec/shared/manage_processes_examples.rb +4 -3
- data/decidim-admin/spec/views/decidim/static_pages/_form.html.erb_spec.rb +2 -2
- data/decidim-api/app/views/layouts/decidim/api/documentation.html.erb +1 -1
- data/decidim-api/decidim-api.gemspec +1 -1
- data/decidim-api/lib/decidim/api.rb +1 -0
- data/decidim-api/lib/decidim/api/schema.rb +5 -0
- data/decidim-api/lib/decidim/api/test/type_context.rb +1 -0
- data/decidim-api/lib/decidim/api/types/author_interface.rb +13 -0
- data/decidim-api/spec/types/query_type_spec.rb +1 -1
- data/decidim-api/spec/types/translated_field_type_spec.rb +1 -1
- data/decidim-budgets/.gitignore +7 -0
- data/decidim-budgets/README.md +23 -0
- data/decidim-budgets/Rakefile +2 -0
- data/decidim-budgets/app/assets/config/decidim_budgets_manifest.js +1 -0
- data/decidim-budgets/app/assets/images/decidim/budgets/icon.svg +4 -0
- data/decidim-budgets/app/assets/javascripts/decidim/budgets/projects.js.es6 +28 -0
- data/decidim-budgets/app/assets/stylesheets/decidim/budgets/_budgets.scss +1 -0
- data/decidim-budgets/app/assets/stylesheets/decidim/budgets/budget/_budget-list.scss +32 -0
- data/decidim-budgets/app/assets/stylesheets/decidim/budgets/budget/_budget-meter.scss +78 -0
- data/decidim-budgets/app/assets/stylesheets/decidim/budgets/budget/_progress.scss +17 -0
- data/decidim-budgets/app/commands/decidim/budgets/add_line_item.rb +43 -0
- data/decidim-budgets/app/commands/decidim/budgets/admin/create_project.rb +52 -0
- data/decidim-budgets/app/commands/decidim/budgets/admin/update_project.rb +56 -0
- data/decidim-budgets/app/commands/decidim/budgets/cancel_order.rb +36 -0
- data/decidim-budgets/app/commands/decidim/budgets/checkout.rb +34 -0
- data/decidim-budgets/app/commands/decidim/budgets/remove_line_item.rb +35 -0
- data/decidim-budgets/app/controllers/concerns/decidim/budgets/needs_current_order.rb +27 -0
- data/decidim-budgets/app/controllers/decidim/budgets/admin/application_controller.rb +14 -0
- data/decidim-budgets/app/controllers/decidim/budgets/admin/projects_controller.rb +69 -0
- data/decidim-budgets/app/controllers/decidim/budgets/application_controller.rb +13 -0
- data/decidim-budgets/app/controllers/decidim/budgets/line_items_controller.rb +43 -0
- data/decidim-budgets/app/controllers/decidim/budgets/orders_controller.rb +38 -0
- data/decidim-budgets/app/controllers/decidim/budgets/projects_controller.rb +44 -0
- data/decidim-budgets/app/forms/decidim/budgets/admin/project_form.rb +44 -0
- data/decidim-budgets/app/helpers/decidim/budgets/application_helper.rb +12 -0
- data/decidim-budgets/app/helpers/decidim/budgets/projects_helper.rb +29 -0
- data/decidim-budgets/app/models/decidim/budgets/application_record.rb +9 -0
- data/decidim-budgets/app/models/decidim/budgets/line_item.rb +20 -0
- data/decidim-budgets/app/models/decidim/budgets/order.rb +52 -0
- data/decidim-budgets/app/models/decidim/budgets/project.rb +15 -0
- data/decidim-budgets/app/services/decidim/budgets/project_search.rb +58 -0
- data/decidim-budgets/app/views/decidim/budgets/admin/projects/_form.html.erb +31 -0
- data/decidim-budgets/app/views/decidim/budgets/admin/projects/edit.html.erb +9 -0
- data/decidim-budgets/app/views/decidim/budgets/admin/projects/index.html.erb +27 -0
- data/{decidim-admin/app/views/decidim/admin/participatory_process_attachments → decidim-budgets/app/views/decidim/budgets/admin/projects}/new.html.erb +0 -0
- data/decidim-budgets/app/views/decidim/budgets/line_items/update_budget.js.erb +21 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/_budget_confirm.html.erb +30 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/_budget_excess.html.erb +14 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/_budget_summary.html.erb +46 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/_count.html.erb +1 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/_filters.html.erb +24 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/_linked_projects.html.erb +12 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/_order_progress.html.erb +34 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/_order_selected_projects.html.erb +25 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/_order_total_budget.html.erb +1 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/_project.html.erb +40 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/_project_budget_button.html.erb +9 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/_projects.html.erb +8 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/_tags.html.erb +10 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/index.html.erb +26 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/index.js.erb +2 -0
- data/decidim-budgets/app/views/decidim/budgets/projects/show.html.erb +48 -0
- data/decidim-budgets/bin/rails +14 -0
- data/decidim-budgets/config/i18n-tasks.yml +4 -0
- data/decidim-budgets/config/locales/ca.yml +84 -0
- data/decidim-budgets/config/locales/en.yml +95 -0
- data/decidim-budgets/config/locales/es.yml +84 -0
- data/decidim-budgets/db/migrate/20170127114122_create_projects.rb +15 -0
- data/decidim-budgets/db/migrate/20170130095615_create_orders.rb +13 -0
- data/decidim-budgets/db/migrate/20170130101825_create_line_items.rb +10 -0
- data/decidim-budgets/decidim-budgets.gemspec +24 -0
- data/decidim-budgets/lib/decidim/budgets.rb +11 -0
- data/decidim-budgets/lib/decidim/budgets/admin.rb +9 -0
- data/decidim-budgets/lib/decidim/budgets/admin_engine.rb +22 -0
- data/decidim-budgets/lib/decidim/budgets/feature.rb +59 -0
- data/decidim-budgets/lib/decidim/budgets/list_engine.rb +30 -0
- data/decidim-budgets/lib/decidim/budgets/test/factories.rb +43 -0
- data/decidim-budgets/spec/commands/add_line_item_spec.rb +48 -0
- data/decidim-budgets/spec/commands/cancel_order_spec.rb +42 -0
- data/decidim-budgets/spec/commands/checkout_spec.rb +45 -0
- data/decidim-budgets/spec/commands/create_project_spec.rb +72 -0
- data/decidim-budgets/spec/commands/remove_line_item_spec.rb +31 -0
- data/decidim-budgets/spec/commands/update_project_spec.rb +65 -0
- data/decidim-budgets/spec/factories.rb +4 -0
- data/decidim-budgets/spec/features/admin_manages_projects_spec.rb +16 -0
- data/decidim-budgets/spec/features/orders_spec.rb +149 -0
- data/decidim-budgets/spec/features/process_admin_manages_projects_spec.rb +17 -0
- data/decidim-budgets/spec/forms/project_form_spec.rb +115 -0
- data/decidim-budgets/spec/models/line_item_spec.rb +35 -0
- data/decidim-budgets/spec/models/order_spec.rb +45 -0
- data/decidim-budgets/spec/models/project_spec.rb +30 -0
- data/decidim-budgets/spec/services/project_search_spec.rb +97 -0
- data/decidim-budgets/spec/shared/admin_shared_context.rb +11 -0
- data/decidim-budgets/spec/shared/manage_projects_examples.rb +104 -0
- data/decidim-budgets/spec/spec_helper.rb +2 -0
- data/decidim-comments/app/assets/javascripts/decidim/comments/bundle.js +0 -0
- data/decidim-comments/app/commands/decidim/comments/create_comment.rb +2 -1
- data/decidim-comments/app/forms/decidim/comments/comment_form.rb +1 -0
- data/decidim-comments/app/frontend/application/apollo_client.js +1 -1
- data/decidim-comments/app/frontend/application/application.component.jsx +1 -1
- data/decidim-comments/app/frontend/comments/add_comment_form.component.jsx +76 -20
- data/decidim-comments/app/frontend/comments/add_comment_form.component.test.jsx +77 -22
- data/decidim-comments/app/frontend/comments/add_comment_form.fragment.graphql +6 -0
- data/decidim-comments/app/frontend/comments/add_comment_form.mutation.graphql +2 -2
- data/decidim-comments/app/frontend/comments/comment.component.jsx +15 -15
- data/decidim-comments/app/frontend/comments/comment.component.test.jsx +42 -41
- data/decidim-comments/app/frontend/comments/comment_order_selector.component.jsx +1 -1
- data/decidim-comments/app/frontend/comments/comment_thread.component.jsx +7 -7
- data/decidim-comments/app/frontend/comments/comment_thread.component.test.jsx +21 -19
- data/decidim-comments/app/frontend/comments/comments.component.jsx +21 -17
- data/decidim-comments/app/frontend/comments/comments.component.test.jsx +47 -32
- data/decidim-comments/app/frontend/comments/comments.query.graphql +6 -3
- data/decidim-comments/app/frontend/comments/down_vote_button.component.jsx +21 -10
- data/decidim-comments/app/frontend/comments/up_vote_button.component.jsx +23 -12
- data/decidim-comments/app/frontend/comments/vote_button.component.jsx +15 -7
- data/decidim-comments/app/frontend/comments/vote_button_component.test.jsx +7 -2
- data/decidim-comments/app/frontend/entry.js +1 -8
- data/decidim-comments/app/frontend/support/generate_user_data.js +13 -0
- data/decidim-comments/app/frontend/support/generate_user_group_data.js +14 -0
- data/decidim-comments/app/helpers/decidim/comments/comments_helper.rb +10 -15
- data/decidim-comments/app/models/decidim/comments/comment.rb +5 -7
- data/decidim-comments/app/types/decidim/comments/comment_type.rb +5 -1
- data/decidim-comments/config/locales/ca.yml +5 -1
- data/decidim-comments/config/locales/en.yml +4 -1
- data/decidim-comments/config/locales/es.yml +5 -1
- data/decidim-comments/db/migrate/20170123102043_add_user_group_id_to_comments.rb +5 -0
- data/decidim-comments/decidim-comments.gemspec +0 -1
- data/decidim-comments/lib/decidim/comments/engine.rb +0 -1
- data/decidim-comments/lib/decidim/comments/mutation_extensions.rb +2 -1
- data/decidim-comments/spec/commands/create_comment_spec.rb +6 -3
- data/decidim-comments/spec/commands/vote_comment_spec.rb +4 -4
- data/decidim-comments/spec/features/comments_spec.rb +27 -3
- data/decidim-comments/spec/forms/comment_form_spec.rb +6 -3
- data/decidim-comments/spec/models/comment_spec.rb +25 -32
- data/decidim-comments/spec/queries/comments_with_replies_spec.rb +2 -2
- data/decidim-comments/spec/types/comment_type_spec.rb +2 -2
- data/decidim-comments/spec/types/query_type_spec.rb +5 -5
- data/decidim-dev/app/views/decidim/dummy_resource/_linked_dummys.html.erb +5 -0
- data/decidim-dev/config/locales/en.yml +5 -0
- data/decidim-dev/decidim-dev.gemspec +3 -3
- data/decidim-dev/lib/decidim/dev/assets/avatar.jpg +0 -0
- data/decidim-dev/lib/decidim/dev/assets/icon.png +0 -0
- data/decidim-dev/lib/decidim/dev/test/base_spec_helper.rb +1 -0
- data/decidim-dev/lib/decidim/dev/test/rspec_support/action_mailer.rb +1 -1
- data/decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb +9 -5
- data/decidim-dev/lib/decidim/dev/test/rspec_support/feature.rb +24 -0
- data/decidim-meetings/app/assets/config/decidim_meetings_manifest.js +2 -0
- data/decidim-meetings/app/assets/javascripts/decidim/meetings/map.js.es6.erb +92 -0
- data/decidim-meetings/app/assets/stylesheets/decidim/meetings/map.css +1 -0
- data/decidim-meetings/app/commands/decidim/meetings/admin/close_meeting.rb +53 -0
- data/decidim-meetings/app/commands/decidim/meetings/admin/create_meeting.rb +15 -3
- data/decidim-meetings/app/commands/decidim/meetings/admin/update_meeting.rb +15 -3
- data/decidim-meetings/app/controllers/decidim/meetings/admin/application_controller.rb +9 -0
- data/decidim-meetings/app/controllers/decidim/meetings/admin/attachments_controller.rb +29 -0
- data/decidim-meetings/app/controllers/decidim/meetings/admin/meeting_closes_controller.rb +38 -0
- data/decidim-meetings/app/controllers/decidim/meetings/admin/meetings_controller.rb +0 -12
- data/decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb +11 -9
- data/decidim-meetings/app/forms/decidim/meetings/admin/close_meeting_form.rb +31 -0
- data/decidim-meetings/app/forms/decidim/meetings/admin/meeting_form.rb +0 -2
- data/decidim-meetings/app/helpers/decidim/meetings/admin/application_helper.rb +12 -0
- data/decidim-meetings/app/helpers/decidim/meetings/application_helper.rb +1 -0
- data/decidim-meetings/app/helpers/decidim/meetings/map_helper.rb +46 -0
- data/decidim-meetings/app/models/decidim/meetings/meeting.rb +11 -15
- data/decidim-meetings/app/services/decidim/meetings/meeting_search.rb +0 -1
- data/decidim-meetings/app/services/decidim/meetings/static_map_generator.rb +50 -0
- data/decidim-meetings/app/views/decidim/meetings/admin/meeting_closes/_form.html.erb +23 -0
- data/decidim-meetings/app/views/decidim/meetings/admin/meeting_closes/edit.html.erb +9 -0
- data/decidim-meetings/app/views/decidim/meetings/admin/meetings/_form.html.erb +2 -6
- data/decidim-meetings/app/views/decidim/meetings/admin/meetings/index.html.erb +14 -0
- data/decidim-meetings/app/views/decidim/meetings/meetings/_datetime.html.erb +8 -0
- data/decidim-meetings/app/views/decidim/meetings/meetings/_filters.html.erb +2 -2
- data/decidim-meetings/app/views/decidim/meetings/meetings/_filters_small_view.html.erb +18 -0
- data/decidim-meetings/app/views/decidim/meetings/meetings/_linked_meetings.html.erb +22 -0
- data/decidim-meetings/app/views/decidim/meetings/meetings/_meetings.html.erb +3 -10
- data/decidim-meetings/app/views/decidim/meetings/meetings/index.html.erb +42 -0
- data/decidim-meetings/app/views/decidim/meetings/meetings/index.js.erb +6 -0
- data/decidim-meetings/app/views/decidim/meetings/meetings/show.html.erb +33 -7
- data/decidim-meetings/bin/rails +1 -1
- data/decidim-meetings/config/i18n-tasks.yml +2 -0
- data/decidim-meetings/config/locales/ca.yml +37 -4
- data/decidim-meetings/config/locales/en.yml +34 -1
- data/decidim-meetings/config/locales/es.yml +36 -3
- data/decidim-meetings/db/migrate/20170110142105_close_a_meeting.rb +9 -0
- data/decidim-meetings/db/migrate/20170123151650_add_latitude_and_longitude_to_meetings.rb +6 -0
- data/decidim-meetings/db/migrate/20170129153716_remove_short_description_from_meetings.rb +5 -0
- data/decidim-meetings/decidim-meetings.gemspec +7 -0
- data/decidim-meetings/lib/decidim/meetings/admin_engine.rb +31 -1
- data/decidim-meetings/lib/decidim/meetings/feature.rb +20 -6
- data/decidim-meetings/lib/decidim/meetings/list_engine.rb +10 -1
- data/decidim-meetings/lib/decidim/meetings/seeds/Exampledocument.pdf +0 -0
- data/decidim-meetings/lib/decidim/meetings/seeds/city.jpeg +0 -0
- data/decidim-meetings/lib/decidim/meetings/test/factories.rb +23 -0
- data/decidim-meetings/spec/commands/close_meeting_spec.rb +78 -0
- data/decidim-meetings/spec/commands/create_meeting_spec.rb +22 -3
- data/decidim-meetings/spec/commands/update_meeting_spec.rb +32 -3
- data/decidim-meetings/spec/controllers/meetings_controller_spec.rb +41 -0
- data/decidim-meetings/spec/factories.rb +3 -13
- data/decidim-meetings/spec/features/admin_manages_meetings_attachments_spec.rb +10 -0
- data/decidim-meetings/spec/features/explore_meetings_spec.rb +55 -1
- data/decidim-meetings/spec/features/process_admin_manages_meetings_attachments_spec.rb +12 -0
- data/decidim-meetings/spec/forms/close_meeting_form_spec.rb +90 -0
- data/decidim-meetings/spec/forms/meeting_form_spec.rb +1 -7
- data/decidim-meetings/spec/models/meeting_spec.rb +42 -24
- data/decidim-meetings/spec/services/meeting_search_spec.rb +1 -17
- data/decidim-meetings/spec/services/static_map_generator_spec.rb +33 -0
- data/decidim-meetings/spec/shared/manage_attachments_examples.rb +17 -0
- data/decidim-meetings/spec/shared/manage_meetings_examples.rb +58 -8
- data/decidim-meetings/spec/spec_helper.rb +5 -0
- data/decidim-meetings/spec/support/geocoder.rb +7 -0
- data/decidim-meetings/vendor/assets/javascripts/leaflet-svg-icon.js +179 -0
- data/decidim-meetings/vendor/assets/javascripts/leaflet-tilelayer-here.js +166 -0
- data/decidim-meetings/vendor/assets/javascripts/leaflet.js +9 -0
- data/decidim-meetings/vendor/assets/stylesheets/leaflet.css +624 -0
- data/decidim-pages/app/models/decidim/pages/page.rb +10 -1
- data/decidim-pages/app/views/decidim/pages/application/show.html.erb +2 -1
- data/decidim-pages/spec/commands/create_page_spec.rb +2 -2
- data/decidim-pages/spec/commands/destroy_page_spec.rb +1 -1
- data/decidim-pages/spec/commands/update_page_spec.rb +1 -1
- data/decidim-pages/spec/factories.rb +1 -1
- data/decidim-pages/spec/features/admin_spec.rb +1 -0
- data/decidim-pages/spec/models/page_spec.rb +15 -0
- data/decidim-proposals/app/assets/stylesheets/decidim/proposals/social_share.css.scss +5 -0
- data/decidim-proposals/app/commands/decidim/proposals/admin/answer_proposal.rb +43 -0
- data/decidim-proposals/app/commands/decidim/proposals/create_proposal.rb +1 -0
- data/decidim-proposals/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb +37 -0
- data/decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb +1 -0
- data/decidim-proposals/app/controllers/decidim/proposals/proposal_votes_controller.rb +18 -7
- data/decidim-proposals/app/controllers/decidim/proposals/proposals_controller.rb +8 -7
- data/decidim-proposals/app/forms/decidim/proposals/admin/proposal_answer_form.rb +18 -0
- data/decidim-proposals/app/forms/decidim/proposals/proposal_form.rb +1 -0
- data/decidim-proposals/app/helpers/decidim/proposals/application_helper.rb +17 -0
- data/decidim-proposals/app/helpers/decidim/proposals/proposal_votes_helper.rb +19 -0
- data/decidim-proposals/app/models/decidim/proposals/abilities/current_user.rb +59 -0
- data/decidim-proposals/app/models/decidim/proposals/proposal.rb +30 -33
- data/decidim-proposals/app/models/decidim/proposals/proposal_vote.rb +2 -0
- data/decidim-proposals/app/services/decidim/proposals/proposal_search.rb +11 -0
- data/decidim-proposals/app/views/decidim/proposals/admin/proposal_answers/edit.html.erb +15 -0
- data/decidim-proposals/app/views/decidim/proposals/admin/proposals/index.html.erb +8 -0
- data/decidim-proposals/app/views/decidim/proposals/proposal_votes/update_buttons_and_counters.js.erb +20 -0
- data/decidim-proposals/app/views/decidim/proposals/proposals/_filters.html.erb +3 -1
- data/decidim-proposals/app/views/decidim/proposals/proposals/_filters_small_view.html.erb +18 -0
- data/decidim-proposals/app/views/decidim/proposals/proposals/_linked_proposals.html.erb +27 -0
- data/decidim-proposals/app/views/decidim/proposals/proposals/_proposal.html.erb +3 -2
- data/decidim-proposals/app/views/decidim/proposals/proposals/_proposal_badge.html.erb +3 -0
- data/decidim-proposals/app/views/decidim/proposals/proposals/_remaining_votes_count.html.erb +1 -0
- data/decidim-proposals/app/views/decidim/proposals/proposals/_share.html.erb +1 -1
- data/decidim-proposals/app/views/decidim/proposals/proposals/_vote_button.html.erb +16 -4
- data/decidim-proposals/app/views/decidim/proposals/proposals/_votes_limit.html.erb +23 -0
- data/decidim-proposals/app/views/decidim/proposals/proposals/index.html.erb +13 -3
- data/decidim-proposals/app/views/decidim/proposals/proposals/new.html.erb +6 -0
- data/decidim-proposals/app/views/decidim/proposals/proposals/show.html.erb +15 -2
- data/decidim-proposals/config/i18n-tasks.yml +3 -0
- data/decidim-proposals/config/locales/ca.yml +54 -1
- data/decidim-proposals/config/locales/en.yml +54 -0
- data/decidim-proposals/config/locales/es.yml +54 -1
- data/decidim-proposals/db/migrate/20170120151202_add_user_group_id_to_proposals.rb +5 -0
- data/decidim-proposals/db/migrate/20170131092413_add_answers_to_proposals.rb +7 -0
- data/decidim-proposals/decidim-proposals.gemspec +3 -0
- data/decidim-proposals/lib/decidim/proposals/admin_engine.rb +3 -1
- data/decidim-proposals/lib/decidim/proposals/engine.rb +7 -1
- data/decidim-proposals/lib/decidim/proposals/feature.rb +28 -1
- data/decidim-proposals/lib/decidim/proposals/test/factories.rb +83 -0
- data/decidim-proposals/spec/commands/decidim/proposals/admin_create_proposal_spec.rb +14 -0
- data/decidim-proposals/spec/commands/decidim/proposals/answer_proposal_spec.rb +53 -0
- data/decidim-proposals/spec/commands/decidim/proposals/create_proposal_spec.rb +3 -56
- data/decidim-proposals/spec/controllers/decidim/admin/proposal_answers_controller_spec.rb +45 -0
- data/decidim-proposals/spec/controllers/decidim/proposal_votes_controller_spec.rb +113 -0
- data/decidim-proposals/spec/controllers/decidim/proposals_controller_spec.rb +53 -0
- data/decidim-proposals/spec/factories.rb +1 -23
- data/decidim-proposals/spec/features/proposals_spec.rb +201 -38
- data/decidim-proposals/spec/features/vote_proposal_spec.rb +83 -11
- data/decidim-proposals/spec/forms/decidim/proposals/admin_proposal_form_spec.rb +13 -0
- data/decidim-proposals/spec/forms/decidim/proposals/proposal_answer_form_spec.rb +50 -0
- data/decidim-proposals/spec/forms/decidim/proposals/proposal_form_spec.rb +5 -93
- data/decidim-proposals/spec/helpers/application_helper_spec.rb +33 -0
- data/decidim-proposals/spec/helpers/proposal_votes_helper_spec.rb +53 -0
- data/decidim-proposals/spec/lib/decidim/proposals/feature_spec.rb +1 -1
- data/decidim-proposals/spec/models/decidim/proposals/proposal_spec.rb +21 -19
- data/decidim-proposals/spec/models/decidim/proposals/proposal_vote_spec.rb +19 -1
- data/decidim-proposals/spec/services/decidim/proposals/proposal_search_spec.rb +66 -25
- data/decidim-proposals/spec/shared/create_proposal_examples.rb +69 -0
- data/decidim-proposals/spec/shared/manage_proposals_examples.rb +49 -0
- data/decidim-proposals/spec/shared/proposal_form_examples.rb +100 -0
- data/decidim-results/.gitignore +7 -0
- data/decidim-results/README.md +23 -0
- data/decidim-results/Rakefile +2 -0
- data/decidim-results/app/assets/images/decidim/results/icon.svg +1 -0
- data/decidim-results/app/commands/decidim/results/admin/create_result.rb +65 -0
- data/decidim-results/app/commands/decidim/results/admin/update_result.rb +69 -0
- data/decidim-results/app/controllers/decidim/results/admin/application_controller.rb +14 -0
- data/decidim-results/app/controllers/decidim/results/admin/results_controller.rb +69 -0
- data/decidim-results/app/controllers/decidim/results/application_controller.rb +13 -0
- data/decidim-results/app/controllers/decidim/results/results_controller.rb +42 -0
- data/decidim-results/app/forms/decidim/results/admin/result_form.rb +40 -0
- data/decidim-results/app/helpers/decidim/results/application_helper.rb +11 -0
- data/decidim-results/app/models/decidim/results/application_record.rb +9 -0
- data/decidim-results/app/models/decidim/results/result.rb +15 -0
- data/decidim-results/app/services/decidim/results/result_search.rb +44 -0
- data/decidim-results/app/services/decidim/results/result_stats_calculator.rb +51 -0
- data/decidim-results/app/views/decidim/results/admin/results/_form.html.erb +23 -0
- data/decidim-results/app/views/decidim/results/admin/results/edit.html.erb +9 -0
- data/decidim-results/app/views/decidim/results/admin/results/index.html.erb +27 -0
- data/decidim-results/app/views/decidim/results/admin/results/new.html.erb +9 -0
- data/decidim-results/app/views/decidim/results/results/_count.html.erb +1 -0
- data/decidim-results/app/views/decidim/results/results/_filters.html.erb +22 -0
- data/decidim-results/app/views/decidim/results/results/_linked_results.html.erb +12 -0
- data/decidim-results/app/views/decidim/results/results/_results.html.erb +16 -0
- data/decidim-results/app/views/decidim/results/results/_tags.html.erb +10 -0
- data/decidim-results/app/views/decidim/results/results/index.html.erb +22 -0
- data/decidim-results/app/views/decidim/results/results/index.js.erb +2 -0
- data/decidim-results/app/views/decidim/results/results/show.html.erb +52 -0
- data/decidim-results/bin/rails +14 -0
- data/decidim-results/config/i18n-tasks.yml +5 -0
- data/decidim-results/config/locales/ca.yml +61 -0
- data/decidim-results/config/locales/en.yml +62 -0
- data/decidim-results/config/locales/es.yml +61 -0
- data/decidim-results/db/migrate/20170116104125_create_results.rb +14 -0
- data/decidim-results/db/migrate/20170129164553_remove_short_description_from_results.rb +5 -0
- data/decidim-results/decidim-results.gemspec +26 -0
- data/decidim-results/lib/decidim/results.rb +11 -0
- data/decidim-results/lib/decidim/results/admin.rb +9 -0
- data/decidim-results/lib/decidim/results/admin_engine.rb +22 -0
- data/decidim-results/lib/decidim/results/feature.rb +52 -0
- data/decidim-results/lib/decidim/results/list_engine.rb +19 -0
- data/decidim-results/lib/decidim/results/test/factories.rb +11 -0
- data/decidim-results/spec/commands/create_result_spec.rb +90 -0
- data/decidim-results/spec/commands/update_result_spec.rb +83 -0
- data/decidim-results/spec/factories.rb +6 -0
- data/decidim-results/spec/features/admin_manages_results_spec.rb +16 -0
- data/decidim-results/spec/features/explore_results_spec.rb +186 -0
- data/decidim-results/spec/features/process_admin_manages_results_spec.rb +17 -0
- data/decidim-results/spec/forms/result_form_spec.rb +91 -0
- data/decidim-results/spec/models/result_spec.rb +18 -0
- data/decidim-results/spec/services/result_search_spec.rb +97 -0
- data/decidim-results/spec/services/result_stats_calculator_spec.rb +93 -0
- data/decidim-results/spec/shared/admin_shared_context.rb +11 -0
- data/decidim-results/spec/shared/manage_results_examples.rb +96 -0
- data/decidim-results/spec/spec_helper.rb +2 -0
- data/decidim-system/app/assets/javascripts/decidim/system/application.js.es6 +1 -3
- data/decidim-system/app/views/layouts/decidim/system/_header.html.erb +2 -2
- data/decidim-system/decidim-system.gemspec +0 -1
- data/decidim-system/lib/decidim/system/engine.rb +0 -1
- data/decidim-system/spec/features/manage_admins_spec.rb +1 -1
- data/decidim-system/spec/features/organizations_spec.rb +1 -1
- data/decidim.gemspec +2 -0
- data/docs/how_to_create_a_plugin.md +0 -2
- data/lib/decidim.rb +2 -0
- data/lib/generators/decidim/install_generator.rb +1 -0
- data/lib/generators/decidim/templates/Gemfile.erb +10 -1
- data/lib/generators/decidim/templates/initializer.rb +9 -0
- data/lib/generators/decidim/templates/secrets.yml.erb +3 -0
- data/lib/generators/decidim/templates/social_share_button.rb +1 -1
- data/package.json +2 -3
- data/yarn.lock +10 -8
- metadata +265 -32
- data/decidim-admin/app/helpers/decidim/admin/aria_selected_link_to_helper.rb +0 -28
- data/decidim-admin/app/views/decidim/admin/participatory_process_attachments/edit.html.erb +0 -9
- data/decidim-admin/app/views/decidim/admin/participatory_process_attachments/index.html.erb +0 -37
- data/decidim-admin/app/views/decidim/admin/participatory_process_attachments/show.html.erb +0 -25
- data/decidim-comments/app/frontend/support/generate_current_user_data.js +0 -13
- data/decidim-comments/app/types/decidim/comments/author_type.rb +0 -15
- data/decidim-comments/spec/types/author_type_spec.rb +0 -21
- data/decidim-dev/lib/decidim/dev/assets/avatar.svg +0 -14
- data/decidim-proposals/app/views/decidim/proposals/proposal_votes/create.js.erb +0 -5
@@ -1,12 +1,13 @@
|
|
1
1
|
/* eslint-disable no-unused-expressions */
|
2
|
-
import { shallow, mount }
|
2
|
+
import { shallow, mount } from 'enzyme';
|
3
3
|
|
4
|
-
import { AddCommentForm }
|
4
|
+
import { AddCommentForm } from './add_comment_form.component';
|
5
5
|
|
6
|
-
import
|
6
|
+
import generateUserData from '../support/generate_user_data';
|
7
|
+
import generateUserGroupData from '../support/generate_user_group_data';
|
7
8
|
|
8
9
|
describe("<AddCommentForm />", () => {
|
9
|
-
let
|
10
|
+
let session = null;
|
10
11
|
const commentableId = "1";
|
11
12
|
const commentableType = "Decidim::ParticipatoryProcess";
|
12
13
|
const addCommentStub = () => {
|
@@ -14,48 +15,51 @@ describe("<AddCommentForm />", () => {
|
|
14
15
|
}
|
15
16
|
|
16
17
|
beforeEach(() => {
|
17
|
-
|
18
|
+
session = {
|
19
|
+
user: generateUserData(),
|
20
|
+
verifiedUserGroups: []
|
21
|
+
};
|
18
22
|
});
|
19
23
|
|
20
24
|
it("should render a div with class add-comment", () => {
|
21
|
-
const wrapper = shallow(<AddCommentForm addComment={addCommentStub}
|
25
|
+
const wrapper = shallow(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} />);
|
22
26
|
expect(wrapper.find('div.add-comment')).to.present();
|
23
27
|
});
|
24
28
|
|
25
29
|
it("should have a reference to body textarea", () => {
|
26
|
-
const wrapper = mount(<AddCommentForm addComment={addCommentStub}
|
30
|
+
const wrapper = mount(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} />);
|
27
31
|
expect(wrapper.instance().bodyTextArea).to.be.ok;
|
28
32
|
});
|
29
33
|
|
30
34
|
it("should initialize with a state property disabled as true", () => {
|
31
|
-
const wrapper = mount(<AddCommentForm addComment={addCommentStub}
|
35
|
+
const wrapper = mount(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} />);
|
32
36
|
expect(wrapper).to.have.state('disabled', true);
|
33
37
|
});
|
34
38
|
|
35
39
|
it("should have a default prop showTitle as true", () => {
|
36
|
-
const wrapper = mount(<AddCommentForm addComment={addCommentStub}
|
37
|
-
expect(wrapper).to.have.prop('showTitle').equal(true);
|
40
|
+
const wrapper = mount(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} />);
|
41
|
+
expect(wrapper).to.have.prop('showTitle').equal(true);
|
38
42
|
});
|
39
43
|
|
40
44
|
it("should not render the title if prop showTitle is false", () => {
|
41
|
-
const wrapper = shallow(<AddCommentForm addComment={addCommentStub}
|
45
|
+
const wrapper = shallow(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} showTitle={false} />);
|
42
46
|
expect(wrapper.find('h5.section-heading')).not.to.be.present();
|
43
47
|
});
|
44
48
|
|
45
49
|
it("should have a default prop submitButtonClassName as 'button button--sc'", () => {
|
46
|
-
const wrapper = mount(<AddCommentForm addComment={addCommentStub}
|
50
|
+
const wrapper = mount(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} />);
|
47
51
|
expect(wrapper).to.have.prop('submitButtonClassName').equal('button button--sc');
|
48
52
|
});
|
49
53
|
|
50
54
|
it("should use prop submitButtonClassName as a className prop for submit button", () => {
|
51
|
-
const wrapper = shallow(<AddCommentForm addComment={addCommentStub}
|
55
|
+
const wrapper = shallow(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} submitButtonClassName="button small hollow" />);
|
52
56
|
expect(wrapper.find('input[type="submit"]')).to.have.className('button');
|
53
57
|
expect(wrapper.find('input[type="submit"]')).to.have.className('small');
|
54
58
|
expect(wrapper.find('input[type="submit"]')).to.have.className('hollow');
|
55
59
|
});
|
56
60
|
|
57
61
|
it("should enable the submit button if textarea is not blank", () => {
|
58
|
-
const wrapper = mount(<AddCommentForm addComment={addCommentStub}
|
62
|
+
const wrapper = mount(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} />);
|
59
63
|
wrapper.find('textarea').simulate('change', {
|
60
64
|
target: {
|
61
65
|
value: 'This is a comment'
|
@@ -65,7 +69,7 @@ describe("<AddCommentForm />", () => {
|
|
65
69
|
});
|
66
70
|
|
67
71
|
it("should disable the submit button if textarea is blank", () => {
|
68
|
-
const wrapper = mount(<AddCommentForm addComment={addCommentStub}
|
72
|
+
const wrapper = mount(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} />);
|
69
73
|
wrapper.find('textarea').simulate('change', {
|
70
74
|
target: {
|
71
75
|
value: 'This will be deleted'
|
@@ -80,7 +84,7 @@ describe("<AddCommentForm />", () => {
|
|
80
84
|
});
|
81
85
|
|
82
86
|
it("should not render a div with class 'opinion-toggle'", () => {
|
83
|
-
const wrapper = shallow(<AddCommentForm addComment={addCommentStub}
|
87
|
+
const wrapper = shallow(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} />);
|
84
88
|
expect(wrapper.find('.opinion-toggle')).not.to.be.present();
|
85
89
|
});
|
86
90
|
|
@@ -93,7 +97,7 @@ describe("<AddCommentForm />", () => {
|
|
93
97
|
beforeEach(() => {
|
94
98
|
addComment = sinon.spy();
|
95
99
|
onCommentAdded = sinon.spy();
|
96
|
-
wrapper = mount(<AddCommentForm addComment={addComment}
|
100
|
+
wrapper = mount(<AddCommentForm addComment={addComment} session={session} commentableId={commentableId} commentableType={commentableType} onCommentAdded={onCommentAdded} />);
|
97
101
|
message = 'This will be submitted';
|
98
102
|
wrapper.instance().bodyTextArea.value = message;
|
99
103
|
});
|
@@ -121,25 +125,25 @@ describe("<AddCommentForm />", () => {
|
|
121
125
|
});
|
122
126
|
|
123
127
|
it("should initialize state with a property alignment and value 0", () => {
|
124
|
-
const wrapper = shallow(<AddCommentForm addComment={addCommentStub}
|
128
|
+
const wrapper = shallow(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} arguable />);
|
125
129
|
expect(wrapper).to.have.state('alignment').equal(0);
|
126
130
|
});
|
127
131
|
|
128
132
|
describe("when receiving an optional prop arguable with value true", () => {
|
129
133
|
it("should render a div with class 'opinion-toggle'", () => {
|
130
|
-
const wrapper = shallow(<AddCommentForm addComment={addCommentStub}
|
134
|
+
const wrapper = shallow(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} arguable />);
|
131
135
|
expect(wrapper.find('.opinion-toggle')).to.be.present();
|
132
136
|
});
|
133
137
|
|
134
138
|
it("should set state alignment to 1 if user clicks ok button and change its class", () => {
|
135
|
-
const wrapper = shallow(<AddCommentForm addComment={addCommentStub}
|
139
|
+
const wrapper = shallow(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} arguable />);
|
136
140
|
wrapper.find('.opinion-toggle--ok').simulate('click');
|
137
141
|
expect(wrapper.find('.opinion-toggle--ok')).to.have.className('is-active');
|
138
142
|
expect(wrapper).to.have.state('alignment').equal(1);
|
139
143
|
});
|
140
144
|
|
141
145
|
it("should set state alignment to -11 if user clicks ko button and change its class", () => {
|
142
|
-
const wrapper = shallow(<AddCommentForm addComment={addCommentStub}
|
146
|
+
const wrapper = shallow(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} arguable />);
|
143
147
|
wrapper.find('.opinion-toggle--ko').simulate('click');
|
144
148
|
expect(wrapper.find('.opinion-toggle--ko')).to.have.className('is-active');
|
145
149
|
expect(wrapper).to.have.state('alignment').equal(-1);
|
@@ -152,7 +156,7 @@ describe("<AddCommentForm />", () => {
|
|
152
156
|
|
153
157
|
beforeEach(() => {
|
154
158
|
addComment = sinon.spy();
|
155
|
-
wrapper = mount(<AddCommentForm addComment={addComment}
|
159
|
+
wrapper = mount(<AddCommentForm addComment={addComment} session={session} commentableId={commentableId} commentableType={commentableType} arguable />);
|
156
160
|
message = 'This will be submitted';
|
157
161
|
wrapper.instance().bodyTextArea.value = message;
|
158
162
|
});
|
@@ -170,4 +174,55 @@ describe("<AddCommentForm />", () => {
|
|
170
174
|
});
|
171
175
|
});
|
172
176
|
});
|
177
|
+
|
178
|
+
describe("when user groups are greater than 0", () => {
|
179
|
+
beforeEach(() => {
|
180
|
+
session.verifiedUserGroups = [
|
181
|
+
generateUserGroupData(),
|
182
|
+
generateUserGroupData()
|
183
|
+
];
|
184
|
+
});
|
185
|
+
|
186
|
+
it("should have a reference to user_group_id select", () => {
|
187
|
+
const wrapper = mount(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} />);
|
188
|
+
expect(wrapper.instance().userGroupIdSelect).to.be.ok;
|
189
|
+
});
|
190
|
+
|
191
|
+
it("should render a select with option tags for each verified user group", () => {
|
192
|
+
const wrapper = mount(<AddCommentForm addComment={addCommentStub} session={session} commentableId={commentableId} commentableType={commentableType} />);
|
193
|
+
expect(wrapper.find('select')).to.have.exactly(3).descendants('option');
|
194
|
+
});
|
195
|
+
|
196
|
+
describe("submitting the form", () => {
|
197
|
+
let addComment = null;
|
198
|
+
let wrapper = null;
|
199
|
+
let message = null;
|
200
|
+
let userGroupId = null;
|
201
|
+
|
202
|
+
beforeEach(() => {
|
203
|
+
addComment = sinon.spy();
|
204
|
+
wrapper = mount(<AddCommentForm addComment={addComment} session={session} commentableId={commentableId} commentableType={commentableType} />);
|
205
|
+
message = 'This will be submitted';
|
206
|
+
userGroupId = session.verifiedUserGroups[1].id;
|
207
|
+
wrapper.instance().bodyTextArea.value = message;
|
208
|
+
wrapper.instance().userGroupIdSelect.value = userGroupId;
|
209
|
+
});
|
210
|
+
|
211
|
+
it("should call addComment prop with the body textarea, alignment and user_group_id select values", () => {
|
212
|
+
wrapper.find('form').simulate('submit');
|
213
|
+
expect(addComment).to.calledWith({ body: message, alignment: 0, userGroupId });
|
214
|
+
});
|
215
|
+
|
216
|
+
describe("when user_group_id is blank", () => {
|
217
|
+
beforeEach(() => {
|
218
|
+
wrapper.instance().userGroupIdSelect.value = '';
|
219
|
+
});
|
220
|
+
|
221
|
+
it("should call addComment prop with the body textarea and alignment", () => {
|
222
|
+
wrapper.find('form').simulate('submit');
|
223
|
+
expect(addComment).to.calledWith({ body: message, alignment: 0 });
|
224
|
+
});
|
225
|
+
});
|
226
|
+
});
|
227
|
+
})
|
173
228
|
});
|
@@ -1,5 +1,5 @@
|
|
1
|
-
mutation addComment($commentableId: String!, $commentableType: String!, $body: String!, $alignment: Int) {
|
2
|
-
addComment(commentableId: $commentableId, commentableType: $commentableType, body: $body, alignment: $alignment) {
|
1
|
+
mutation addComment($commentableId: String!, $commentableType: String!, $body: String!, $alignment: Int, $userGroupId: ID) {
|
2
|
+
addComment(commentableId: $commentableId, commentableType: $commentableType, body: $body, alignment: $alignment, userGroupId: $userGroupId) {
|
3
3
|
...CommentThread
|
4
4
|
}
|
5
5
|
}
|
@@ -68,12 +68,12 @@ class Comment extends Component {
|
|
68
68
|
* @returns {Void|DOMElement} - Render the reply button or not if user can reply
|
69
69
|
*/
|
70
70
|
_renderReplyButton() {
|
71
|
-
const { comment: { canHaveReplies },
|
71
|
+
const { comment: { canHaveReplies }, session } = this.props;
|
72
72
|
const { showReplyForm } = this.state;
|
73
73
|
|
74
|
-
if (
|
74
|
+
if (session && canHaveReplies) {
|
75
75
|
return (
|
76
|
-
<button
|
76
|
+
<button
|
77
77
|
className="comment__reply muted-link"
|
78
78
|
aria-controls="comment1-reply"
|
79
79
|
onClick={() => this.setState({ showReplyForm: !showReplyForm })}
|
@@ -92,10 +92,10 @@ class Comment extends Component {
|
|
92
92
|
* @returns {Void|DOMElement} - Render the reply button or not if user can reply
|
93
93
|
*/
|
94
94
|
_renderAdditionalReplyButton() {
|
95
|
-
const { comment: { canHaveReplies, hasReplies },
|
95
|
+
const { comment: { canHaveReplies, hasReplies }, session, isRootComment } = this.props;
|
96
96
|
const { showReplyForm } = this.state;
|
97
|
-
|
98
|
-
if (
|
97
|
+
|
98
|
+
if (session && canHaveReplies) {
|
99
99
|
if (hasReplies && isRootComment) {
|
100
100
|
|
101
101
|
return (
|
@@ -140,9 +140,9 @@ class Comment extends Component {
|
|
140
140
|
* @returns {Void|DomElement} - A wrapper element with comment replies inside
|
141
141
|
*/
|
142
142
|
_renderReplies() {
|
143
|
-
const { comment: { id, replies },
|
143
|
+
const { comment: { id, replies }, session, votable, articleClassName } = this.props;
|
144
144
|
let replyArticleClassName = 'comment comment--nested';
|
145
|
-
|
145
|
+
|
146
146
|
if (articleClassName === 'comment comment--nested') {
|
147
147
|
replyArticleClassName = `${replyArticleClassName} comment--nested--alt`;
|
148
148
|
}
|
@@ -155,7 +155,7 @@ class Comment extends Component {
|
|
155
155
|
<Comment
|
156
156
|
key={`comment_${id}_reply_${reply.id}`}
|
157
157
|
comment={reply}
|
158
|
-
|
158
|
+
session={session}
|
159
159
|
votable={votable}
|
160
160
|
articleClassName={replyArticleClassName}
|
161
161
|
/>
|
@@ -164,7 +164,7 @@ class Comment extends Component {
|
|
164
164
|
</div>
|
165
165
|
);
|
166
166
|
}
|
167
|
-
|
167
|
+
|
168
168
|
return null;
|
169
169
|
}
|
170
170
|
|
@@ -174,7 +174,7 @@ class Comment extends Component {
|
|
174
174
|
* @returns {Void|ReactElement} - Render the AddCommentForm component or not
|
175
175
|
*/
|
176
176
|
_renderReplyForm() {
|
177
|
-
const {
|
177
|
+
const { session, comment } = this.props;
|
178
178
|
const { showReplyForm } = this.state;
|
179
179
|
|
180
180
|
if (showReplyForm) {
|
@@ -182,7 +182,7 @@ class Comment extends Component {
|
|
182
182
|
<AddCommentForm
|
183
183
|
commentableId={comment.id}
|
184
184
|
commentableType="Decidim::Comments::Comment"
|
185
|
-
|
185
|
+
session={session}
|
186
186
|
showTitle={false}
|
187
187
|
submitButtonClassName="button small hollow"
|
188
188
|
onCommentAdded={() => this.setState({ showReplyForm: false })}
|
@@ -207,7 +207,7 @@ class Comment extends Component {
|
|
207
207
|
});
|
208
208
|
|
209
209
|
let label = '';
|
210
|
-
|
210
|
+
|
211
211
|
if (alignment === 1) {
|
212
212
|
label = I18n.t('components.comment.alignment.in_favor');
|
213
213
|
} else {
|
@@ -251,8 +251,8 @@ Comment.propTypes = {
|
|
251
251
|
propType(Comment.fragments.comment).isRequired,
|
252
252
|
propType(Comment.fragments.commentData).isRequired
|
253
253
|
]).isRequired,
|
254
|
-
|
255
|
-
|
254
|
+
session: PropTypes.shape({
|
255
|
+
user: PropTypes.any.isRequired
|
256
256
|
}),
|
257
257
|
articleClassName: PropTypes.string.isRequired,
|
258
258
|
isRootComment: PropTypes.bool,
|
@@ -1,25 +1,25 @@
|
|
1
1
|
/* eslint-disable no-unused-expressions */
|
2
|
-
import { shallow, mount }
|
3
|
-
import { filter }
|
4
|
-
import gql
|
2
|
+
import { shallow, mount } from 'enzyme';
|
3
|
+
import { filter } from 'graphql-anywhere';
|
4
|
+
import gql from 'graphql-tag';
|
5
5
|
|
6
|
-
import Comment
|
7
|
-
import AddCommentForm
|
8
|
-
import UpVoteButton
|
9
|
-
import DownVoteButton
|
6
|
+
import Comment from './comment.component';
|
7
|
+
import AddCommentForm from './add_comment_form.component';
|
8
|
+
import UpVoteButton from './up_vote_button.component';
|
9
|
+
import DownVoteButton from './down_vote_button.component';
|
10
10
|
|
11
|
-
import commentFragment
|
12
|
-
import commentDataFragment
|
13
|
-
import upVoteFragment
|
14
|
-
import downVoteFragment
|
11
|
+
import commentFragment from './comment.fragment.graphql';
|
12
|
+
import commentDataFragment from './comment_data.fragment.graphql';
|
13
|
+
import upVoteFragment from './up_vote.fragment.graphql';
|
14
|
+
import downVoteFragment from './down_vote.fragment.graphql';
|
15
15
|
|
16
|
-
import stubComponent
|
17
|
-
import generateCommentsData
|
18
|
-
import
|
16
|
+
import stubComponent from '../support/stub_component';
|
17
|
+
import generateCommentsData from '../support/generate_comments_data';
|
18
|
+
import generateUserData from '../support/generate_user_data';
|
19
19
|
|
20
20
|
describe("<Comment />", () => {
|
21
21
|
let comment = {};
|
22
|
-
let
|
22
|
+
let session = null;
|
23
23
|
|
24
24
|
stubComponent(AddCommentForm);
|
25
25
|
stubComponent(UpVoteButton);
|
@@ -28,8 +28,7 @@ describe("<Comment />", () => {
|
|
28
28
|
beforeEach(() => {
|
29
29
|
let commentsData = generateCommentsData(1);
|
30
30
|
commentsData[0].replies = generateCommentsData(3);
|
31
|
-
|
32
|
-
|
31
|
+
|
33
32
|
const fragment = gql`
|
34
33
|
${commentFragment}
|
35
34
|
${commentDataFragment}
|
@@ -38,44 +37,46 @@ describe("<Comment />", () => {
|
|
38
37
|
`;
|
39
38
|
|
40
39
|
comment = filter(fragment, commentsData[0]);
|
41
|
-
|
40
|
+
session = {
|
41
|
+
user: generateUserData()
|
42
|
+
}
|
42
43
|
});
|
43
44
|
|
44
45
|
it("should render an article with class comment", () => {
|
45
|
-
const wrapper = shallow(<Comment comment={comment}
|
46
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
46
47
|
expect(wrapper.find('article.comment')).to.present();
|
47
48
|
});
|
48
49
|
|
49
50
|
it("should render a time tag with comment's created at", () => {
|
50
|
-
const wrapper = shallow(<Comment comment={comment}
|
51
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
51
52
|
expect(wrapper.find('time')).to.have.text(comment.created_at);
|
52
53
|
});
|
53
54
|
|
54
55
|
it("should render author's name in a link with class author__name", () => {
|
55
|
-
const wrapper = shallow(<Comment comment={comment}
|
56
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
56
57
|
expect(wrapper.find('a.author__name')).to.have.text(comment.author.name);
|
57
58
|
});
|
58
59
|
|
59
60
|
it("should render author's avatar as a image tag", () => {
|
60
|
-
const wrapper = shallow(<Comment comment={comment}
|
61
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
61
62
|
expect(wrapper.find('a.author__avatar img')).to.have.attr('src').equal(comment.author.avatarUrl);
|
62
63
|
});
|
63
64
|
|
64
65
|
it("should render comment's body on a div with class comment__content", () => {
|
65
|
-
const wrapper = shallow(<Comment comment={comment}
|
66
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
66
67
|
expect(wrapper.find('div.comment__content')).to.have.text(comment.body);
|
67
68
|
});
|
68
69
|
|
69
70
|
it("should initialize with a state property showReplyForm as false", () => {
|
70
|
-
const wrapper = shallow(<Comment comment={comment}
|
71
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
71
72
|
expect(wrapper).to.have.state('showReplyForm', false);
|
72
73
|
});
|
73
74
|
|
74
75
|
it("should render a AddCommentForm component with the correct props when clicking the reply button", () => {
|
75
|
-
const wrapper = shallow(<Comment comment={comment}
|
76
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
76
77
|
expect(wrapper.find(AddCommentForm)).not.to.be.present();
|
77
78
|
wrapper.find('button.comment__reply').simulate('click');
|
78
|
-
expect(wrapper.find(AddCommentForm)).to.have.prop('
|
79
|
+
expect(wrapper.find(AddCommentForm)).to.have.prop('session').deep.equal(session);
|
79
80
|
expect(wrapper.find(AddCommentForm)).to.have.prop('commentableId').equal(comment.id);
|
80
81
|
expect(wrapper.find(AddCommentForm)).to.have.prop('commentableType').equal("Decidim::Comments::Comment");
|
81
82
|
expect(wrapper.find(AddCommentForm)).to.have.prop('showTitle').equal(false);
|
@@ -84,89 +85,89 @@ describe("<Comment />", () => {
|
|
84
85
|
|
85
86
|
it("should not render the reply button if the comment cannot have replies", () => {
|
86
87
|
comment.canHaveReplies = false;
|
87
|
-
const wrapper = shallow(<Comment comment={comment}
|
88
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
88
89
|
expect(wrapper.find('button.comment__reply')).not.to.be.present();
|
89
90
|
});
|
90
91
|
|
91
92
|
it("should not render the additional reply button if the parent comment has no replies and isRootcomment", () => {
|
92
93
|
comment.canHaveReplies = true;
|
93
94
|
comment.hasReplies = false;
|
94
|
-
const wrapper = shallow(<Comment comment={comment}
|
95
|
+
const wrapper = shallow(<Comment comment={comment} session={session} isRootComment />);
|
95
96
|
expect(wrapper.find('div.comment__additionalreply')).not.to.be.present();
|
96
97
|
});
|
97
98
|
|
98
99
|
it("should not render the additional reply button if the parent comment has replies and not isRootcomment", () => {
|
99
100
|
comment.canHaveReplies = true;
|
100
101
|
comment.hasReplies = true;
|
101
|
-
const wrapper = shallow(<Comment comment={comment}
|
102
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
102
103
|
expect(wrapper.find('div.comment__additionalreply')).not.to.be.present();
|
103
104
|
});
|
104
105
|
|
105
106
|
it("should render the additional reply button if the parent comment has replies and isRootcomment", () => {
|
106
107
|
comment.canHaveReplies = true;
|
107
108
|
comment.hasReplies = true;
|
108
|
-
const wrapper = shallow(<Comment comment={comment}
|
109
|
+
const wrapper = shallow(<Comment comment={comment} session={session} isRootComment />);
|
109
110
|
expect(wrapper.find('div.comment__additionalreply')).to.be.present();
|
110
111
|
});
|
111
112
|
|
112
113
|
it("should render comment replies a separate Comment components", () => {
|
113
|
-
const wrapper = shallow(<Comment comment={comment}
|
114
|
+
const wrapper = shallow(<Comment comment={comment} session={session} votable />);
|
114
115
|
wrapper.find(Comment).forEach((node, idx) => {
|
115
116
|
expect(node).to.have.prop("comment").deep.equal(comment.replies[idx]);
|
116
|
-
expect(node).to.have.prop("
|
117
|
+
expect(node).to.have.prop("session").deep.equal(session);
|
117
118
|
expect(node).to.have.prop("articleClassName").equal("comment comment--nested")
|
118
119
|
expect(node).to.have.prop("votable").equal(true);
|
119
120
|
});
|
120
121
|
});
|
121
122
|
|
122
123
|
it("should render comment replies with articleClassName as 'comment comment--nested comment--nested--alt' when articleClassName is 'comment comment--nested'", () => {
|
123
|
-
const wrapper = shallow(<Comment comment={comment}
|
124
|
+
const wrapper = shallow(<Comment comment={comment} session={session} articleClassName="comment comment--nested" />);
|
124
125
|
wrapper.find(Comment).forEach((node) => {
|
125
126
|
expect(node).to.have.prop("articleClassName").equal("comment comment--nested comment--nested--alt")
|
126
127
|
});
|
127
128
|
});
|
128
129
|
|
129
130
|
it("should have a default prop articleClassName with value 'comment'", () => {
|
130
|
-
const wrapper = mount(<Comment comment={comment}
|
131
|
+
const wrapper = mount(<Comment comment={comment} session={session} />);
|
131
132
|
expect(wrapper).to.have.prop("articleClassName").equal("comment");
|
132
133
|
});
|
133
134
|
|
134
135
|
it("should have a default prop isRootComment with value false", () => {
|
135
|
-
const wrapper = mount(<Comment comment={comment}
|
136
|
+
const wrapper = mount(<Comment comment={comment} session={session} />);
|
136
137
|
expect(wrapper).to.have.prop("isRootComment").equal(false);
|
137
138
|
});
|
138
139
|
|
139
140
|
describe("when user is not logged in", () => {
|
140
141
|
beforeEach(() => {
|
141
|
-
|
142
|
+
session = null;
|
142
143
|
});
|
143
144
|
|
144
145
|
it("should not render reply button", () => {
|
145
|
-
const wrapper = shallow(<Comment comment={comment}
|
146
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
146
147
|
expect(wrapper.find('button.comment__reply')).not.to.be.present();
|
147
148
|
});
|
148
149
|
});
|
149
150
|
|
150
151
|
it("should render a 'in favor' badge if comment's alignment is 1", () => {
|
151
152
|
comment.alignment = 1;
|
152
|
-
const wrapper = shallow(<Comment comment={comment}
|
153
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
153
154
|
expect(wrapper.find('span.success.label')).to.have.text('In favor');
|
154
155
|
});
|
155
156
|
|
156
157
|
it("should render a 'against' badge if comment's alignment is -1", () => {
|
157
158
|
comment.alignment = -1;
|
158
|
-
const wrapper = shallow(<Comment comment={comment}
|
159
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
159
160
|
expect(wrapper.find('span.alert.label')).to.have.text('Against');
|
160
161
|
});
|
161
162
|
|
162
163
|
describe("when the comment is votable", () => {
|
163
164
|
it("should render an UpVoteButton component", () => {
|
164
|
-
const wrapper = shallow(<Comment comment={comment}
|
165
|
+
const wrapper = shallow(<Comment comment={comment} session={session} votable />);
|
165
166
|
expect(wrapper.find(UpVoteButton)).to.have.prop("comment").deep.equal(comment);
|
166
167
|
})
|
167
168
|
|
168
169
|
it("should render an DownVoteButton component", () => {
|
169
|
-
const wrapper = shallow(<Comment comment={comment}
|
170
|
+
const wrapper = shallow(<Comment comment={comment} session={session} votable />);
|
170
171
|
expect(wrapper.find(DownVoteButton)).to.have.prop("comment").deep.equal(comment);
|
171
172
|
})
|
172
173
|
});
|