diff --git a/.erb-lint.yml b/.erb-lint.yml index af4b9ee7a14f..9c0b1a2e6570 100644 --- a/.erb-lint.yml +++ b/.erb-lint.yml @@ -170,6 +170,7 @@ linters: - budget-list__item - budget-list__item-cell - budget-list__number + - budget-list__number-show-for-medium - budget-list__text - budget-list__title - budget-progress--fixed @@ -1585,9 +1586,10 @@ linters: - show-8 - show-9 - show-comment-replies - - show-for-dark-mode - show-for-ie + - show-for-dark-mode - show-for-landscape + - show-for-large - show-for-large-only - show-for-medium - show-for-medium-only @@ -1892,6 +1894,7 @@ linters: - timeline__phase - timeline__phase__number - timeline__title + - tiny - title-action - title-action__action - title-action__title diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md index 3b9bb0c10f9a..ca3fd9a8b7cf 100644 --- a/.github/ISSUE_TEMPLATE/Feature_request.md +++ b/.github/ISSUE_TEMPLATE/Feature_request.md @@ -8,7 +8,7 @@ We have disabled the feature request's issue creation on this repository. If you * [Feature Request](https://meta.decidim.org/processes/roadmap) -We are doing this because we are trying to eat our own dog food. Once your proposal is collaboratively reviewed and accepted by the Product Comitee, we will create the new issue on GitHub and notify you through Metadecidim. +We are doing this because we are trying to eat our own dog food. Once your proposal is collaboratively reviewed and accepted by the Product Committee, we will create the new issue on GitHub and notify you through Metadecidim. Thanks for contributing to Decidim! diff --git a/Gemfile.lock b/Gemfile.lock index ad2f5f0dfff9..3191b3ed6c97 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,6 +83,7 @@ PATH mime-types (>= 1.16, < 4.0) mini_magick (~> 4.9) net-smtp (~> 0.3.1) + nokogiri (~> 1.16, >= 1.16.2) omniauth (~> 2.0) omniauth-facebook (~> 5.0) omniauth-google-oauth2 (~> 1.0) @@ -121,7 +122,7 @@ PATH factory_bot_rails (~> 6.2) faker (~> 3.2) i18n-tasks (~> 1.0) - nokogiri (~> 1.14, >= 1.14.3) + nokogiri (~> 1.16, >= 1.16.2) parallel_tests (~> 4.2) puma (~> 6.2, >= 6.3.1) rails-controller-testing (~> 1.0) @@ -169,7 +170,7 @@ PATH decidim-proposals (0.29.0.dev) decidim-comments (= 0.29.0.dev) decidim-core (= 0.29.0.dev) - doc2text (~> 0.4.6) + doc2text (~> 0.4.7) redcarpet (~> 3.5, >= 3.5.1) decidim-sortitions (0.29.0.dev) decidim-admin (= 0.29.0.dev) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 774d004244e8..1ac565a885a6 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -106,7 +106,17 @@ In case you have modifications in your application's webpack configuration, adap You can read more about this change on PR [\#12238](https://github.com/decidim/decidim/pull/12238). -### 3.4. [[TITLE OF THE ACTION]] +### 3.4. Allow removal of orphan categories + +A bug was identified that prevented the deletion of categories lacking associated resources. This action is a one-time task that must be performed directly in the production database. + +```console +bin/rails decidim:upgrade:fix_orphan_categorizations +``` + +You can read more about this change on PR [\#12143](https://github.com/decidim/decidim/pull/12143). + +### 3.5. [[TITLE OF THE ACTION]] You can read more about this change on PR [\#XXXX](https://github.com/decidim/decidim/pull/XXXX). diff --git a/decidim-accountability/app/cells/decidim/accountability/project_cell.rb b/decidim-accountability/app/cells/decidim/accountability/project_cell.rb index 566a120b4c2d..a1c9b61a3b10 100644 --- a/decidim-accountability/app/cells/decidim/accountability/project_cell.rb +++ b/decidim-accountability/app/cells/decidim/accountability/project_cell.rb @@ -18,11 +18,11 @@ def show private def title - translated_attribute result.title + decidim_escape_translated result.title end def description - translated_attribute(result.description).html_safe + decidim_sanitize_admin translated_attribute(result.description) end def scope diff --git a/decidim-accountability/app/cells/decidim/accountability/result_metadata_cell.rb b/decidim-accountability/app/cells/decidim/accountability/result_metadata_cell.rb index e1a3658501b1..8c31ad3130c6 100644 --- a/decidim-accountability/app/cells/decidim/accountability/result_metadata_cell.rb +++ b/decidim-accountability/app/cells/decidim/accountability/result_metadata_cell.rb @@ -69,7 +69,7 @@ def status_item_compact return if status.blank? { - text: translated_attribute(status.name), + text: decidim_escape_translated(status.name), icon: "focus-2-line" } end @@ -108,12 +108,12 @@ def status_item { text: t("models.result.fields.status", scope: "decidim.accountability"), icon: "focus-2-line", - value: translated_attribute(status.name) + value: decidim_escape_translated(status.name) } end def status_description - return unless status.present? && (description = translated_attribute(status.description)).present? + return unless status.present? && (description = decidim_escape_translated(status.description)).present? { text: t("models.status.fields.description", scope: "decidim.accountability"), diff --git a/decidim-accountability/app/models/decidim/accountability/result.rb b/decidim-accountability/app/models/decidim/accountability/result.rb index 52745230d352..3bdac690ce3f 100644 --- a/decidim-accountability/app/models/decidim/accountability/result.rb +++ b/decidim-accountability/app/models/decidim/accountability/result.rb @@ -56,7 +56,7 @@ def update_parent_progress end # Public: There are two ways to update parent's progress: - # - using weights, in which case each progress is multiplied by the weigth and them summed + # - using weights, in which case each progress is multiplied by the weight and them summed # - not using weights, and using the average of progress of each children def update_progress! self.progress = if children_use_weighted_progress? diff --git a/decidim-accountability/app/views/decidim/accountability/admin/statuses/index.html.erb b/decidim-accountability/app/views/decidim/accountability/admin/statuses/index.html.erb index 2e76084f38c6..44a2488f0e0b 100644 --- a/decidim-accountability/app/views/decidim/accountability/admin/statuses/index.html.erb +++ b/decidim-accountability/app/views/decidim/accountability/admin/statuses/index.html.erb @@ -22,7 +22,7 @@ <%= status.key %>
<%= translated_attribute(status.name) %> - <%= truncate translated_attribute(status.description), lenght: 50 %> + <%= truncate translated_attribute(status.description), length: 50 %> <%= status.progress %> <% if allowed_to? :update, :status, status: status %> diff --git a/decidim-accountability/app/views/decidim/accountability/results/home.html.erb b/decidim-accountability/app/views/decidim/accountability/results/home.html.erb index e5db3b5e8cab..554b9adffe75 100644 --- a/decidim-accountability/app/views/decidim/accountability/results/home.html.erb +++ b/decidim-accountability/app/views/decidim/accountability/results/home.html.erb @@ -21,7 +21,7 @@ <%= render layout: "layouts/decidim/shared/layout_two_col" do %>
-
<%== translated_attribute component_settings.intro %>
+
<%= decidim_sanitize_admin translated_attribute(component_settings.intro) %>
diff --git a/decidim-accountability/app/views/decidim/accountability/results/index.html.erb b/decidim-accountability/app/views/decidim/accountability/results/index.html.erb index 54e711d2d5c0..fb5b84b23bd5 100644 --- a/decidim-accountability/app/views/decidim/accountability/results/index.html.erb +++ b/decidim-accountability/app/views/decidim/accountability/results/index.html.erb @@ -7,7 +7,7 @@ <%= render layout: "layouts/decidim/shared/layout_two_col" do %>
-

<%= category.present? ? translated_attribute(category.name) : t("decidim.accountability.results.home_header.global_status") %>

+

<%= category.present? ? decidim_escape_translated(category.name) : t("decidim.accountability.results.home_header.global_status") %>

diff --git a/decidim-accountability/lib/decidim/accountability/test/factories.rb b/decidim-accountability/lib/decidim/accountability/test/factories.rb index c7b5952450f0..0549daf04598 100644 --- a/decidim-accountability/lib/decidim/accountability/test/factories.rb +++ b/decidim-accountability/lib/decidim/accountability/test/factories.rb @@ -9,16 +9,19 @@ FactoryBot.define do factory :accountability_component, parent: :component do - name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :accountability).i18n_name } + transient do + skip_injection { false } + end + name { generate_component_name(participatory_space.organization.available_locales, :accountability, skip_injection:) } manifest_name { :accountability } - participatory_space { create(:participatory_process, :with_steps, organization:) } + participatory_space { create(:participatory_process, :with_steps, organization:, skip_injection:) } settings do { - intro: Decidim::Faker::Localized.wrapped("

", "

") { generate_localized_title }, - categories_label: Decidim::Faker::Localized.word, - subcategories_label: Decidim::Faker::Localized.word, - heading_parent_level_results: Decidim::Faker::Localized.word, - heading_leaf_level_results: Decidim::Faker::Localized.word, + intro: generate_localized_description(:accountability_component_intro, skip_injection:), + categories_label: generate_localized_word(:accountability_component_categories_label, skip_injection:), + subcategories_label: generate_localized_word(:accountability_component_subcategories_label, skip_injection:), + heading_parent_level_results: generate_localized_word(:accountability_component_heading_parent_level_results, skip_injection:), + heading_leaf_level_results: generate_localized_word(:accountability_component_heading_leaf_level_results, skip_injection:), scopes_enabled: true, scope_id: participatory_space.scope&.id } @@ -26,27 +29,36 @@ end factory :status, class: "Decidim::Accountability::Status" do - component { create(:accountability_component) } + transient do + skip_injection { false } + end + component { create(:accountability_component, skip_injection:) } sequence(:key) { |n| "status_#{n}" } - name { Decidim::Faker::Localized.word } - description { generate_localized_title } + name { generate_localized_word(:status_name, skip_injection:) } + description { generate_localized_word(:status_description, skip_injection:) } progress { rand(1..100) } end factory :result, class: "Decidim::Accountability::Result" do - component { create(:accountability_component) } - title { generate_localized_title } - description { Decidim::Faker::Localized.wrapped("

", "

") { generate_localized_title } } + transient do + skip_injection { false } + end + component { create(:accountability_component, skip_injection:) } + title { generate_localized_title(:result_title, skip_injection:) } + description { generate_localized_description(:result_description, skip_injection:) } start_date { "12/7/2017" } end_date { "30/9/2017" } - status { create :status, component: } + status { create :status, component:, skip_injection: } progress { rand(1..100) } end factory :timeline_entry, class: "Decidim::Accountability::TimelineEntry" do - result { create(:result) } + transient do + skip_injection { false } + end + result { create(:result, skip_injection:) } entry_date { "12/7/2017" } - title { generate_localized_title } - description { generate_localized_title } + title { generate_localized_title(:timeline_entry_title, skip_injection:) } + description { generate_localized_title(:timeline_entry_description, skip_injection:) } end end diff --git a/decidim-accountability/spec/events/decidim/accountability/proposal_linked_event_spec.rb b/decidim-accountability/spec/events/decidim/accountability/proposal_linked_event_spec.rb index 16c52d8baaba..85b572c6d032 100644 --- a/decidim-accountability/spec/events/decidim/accountability/proposal_linked_event_spec.rb +++ b/decidim-accountability/spec/events/decidim/accountability/proposal_linked_event_spec.rb @@ -10,7 +10,7 @@ let(:proposal_component) do create(:component, manifest_name: "proposals", participatory_space: resource.component.participatory_space) end - let(:proposal) { create(:proposal, component: proposal_component, title: generate_localized_title(:proposal_title)) } + let(:proposal) { create(:proposal, component: proposal_component) } let(:extra) { { proposal_id: proposal.id } } let(:proposal_path) { resource_locator(proposal).path } let(:proposal_title) { decidim_sanitize_translated(proposal.title) } diff --git a/decidim-accountability/spec/events/decidim/accountability/result_progress_updated_event_spec.rb b/decidim-accountability/spec/events/decidim/accountability/result_progress_updated_event_spec.rb index 17fe1d937aba..575591767880 100644 --- a/decidim-accountability/spec/events/decidim/accountability/result_progress_updated_event_spec.rb +++ b/decidim-accountability/spec/events/decidim/accountability/result_progress_updated_event_spec.rb @@ -10,7 +10,7 @@ let(:proposal_component) do create(:component, manifest_name: "proposals", participatory_space: resource.component.participatory_space) end - let(:proposal) { create(:proposal, component: proposal_component, title: generate_localized_title(:proposal_title)) } + let(:proposal) { create(:proposal, component: proposal_component) } let(:extra) { { proposal_id: proposal.id, progress: 95 } } let(:proposal_path) { resource_locator(proposal).path } let(:proposal_title) { decidim_sanitize_translated(proposal.title) } diff --git a/decidim-accountability/spec/shared/export_results_examples.rb b/decidim-accountability/spec/shared/export_results_examples.rb index 529a79b864e0..f7e01129d567 100644 --- a/decidim-accountability/spec/shared/export_results_examples.rb +++ b/decidim-accountability/spec/shared/export_results_examples.rb @@ -25,7 +25,7 @@ shared_examples "export as CSV" do it "exports a CSV" do find("span.exports", text: export_type).click - perform_enqueued_jobs { click_link "Results as CSV" } + perform_enqueued_jobs { click_on "Results as CSV" } expect(page).to have_admin_callout "Your export is currently in progress. You will receive an email when it is complete." expect(last_email.subject).to include("results", "csv") @@ -37,7 +37,7 @@ shared_examples "export as JSON" do it "exports a JSON" do find("span.exports", text: export_type).click - perform_enqueued_jobs { click_link "Results as JSON" } + perform_enqueued_jobs { click_on "Results as JSON" } expect(page).to have_admin_callout "Your export is currently in progress. You will receive an email when it is complete." expect(last_email.subject).to include("results", "json") diff --git a/decidim-accountability/spec/shared/manage_attachment_collections_examples.rb b/decidim-accountability/spec/shared/manage_attachment_collections_examples.rb index d8d11f58e993..8e4cdfd01f3e 100644 --- a/decidim-accountability/spec/shared/manage_attachment_collections_examples.rb +++ b/decidim-accountability/spec/shared/manage_attachment_collections_examples.rb @@ -5,7 +5,7 @@ before do within "tr", text: translated(result.title) do - click_link "Folders" + click_on "Folders" end end diff --git a/decidim-accountability/spec/shared/manage_attachments_examples.rb b/decidim-accountability/spec/shared/manage_attachments_examples.rb index 5bc6714b7712..8ccceff11330 100644 --- a/decidim-accountability/spec/shared/manage_attachments_examples.rb +++ b/decidim-accountability/spec/shared/manage_attachments_examples.rb @@ -8,7 +8,7 @@ before do within "tr", text: translated(result.title) do - click_link "Attachments" + click_on "Attachments" end end diff --git a/decidim-accountability/spec/shared/manage_child_results_examples.rb b/decidim-accountability/spec/shared/manage_child_results_examples.rb index d83e2f84abb9..d2ab8d43499a 100644 --- a/decidim-accountability/spec/shared/manage_child_results_examples.rb +++ b/decidim-accountability/spec/shared/manage_child_results_examples.rb @@ -3,7 +3,7 @@ RSpec.shared_examples "manage child results" do it "updates a result" do within "tr", text: translated(child_result.title) do - click_link "Edit" + click_on "Edit" end within ".edit_result" do @@ -38,7 +38,7 @@ end it "creates a new child result" do - click_link "New result", match: :first + click_on "New result", match: :first within ".new_result" do fill_in_i18n( @@ -74,13 +74,13 @@ before do visit current_path within ".table-list__actions" do - click_link "New result" + click_on "New result" end end it "deletes a result" do within "tr", text: translated(child_result.title) do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") diff --git a/decidim-accountability/spec/shared/manage_results_examples.rb b/decidim-accountability/spec/shared/manage_results_examples.rb index c0947d0b93b2..dec97c1a56a7 100644 --- a/decidim-accountability/spec/shared/manage_results_examples.rb +++ b/decidim-accountability/spec/shared/manage_results_examples.rb @@ -34,7 +34,7 @@ it "updates a result" do within "tr", text: translated(result.title) do - click_link "Edit" + click_on "Edit" end within ".edit_result" do @@ -59,7 +59,7 @@ end it "creates a new result", :slow do - click_link "New result", match: :first + click_on "New result", match: :first within ".new_result" do fill_in_i18n( @@ -114,7 +114,7 @@ it "deletes a result" do within "tr", text: translated(result2.title) do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") diff --git a/decidim-accountability/spec/shared/manage_statuses_examples.rb b/decidim-accountability/spec/shared/manage_statuses_examples.rb index 075aec3169b5..69af2bf4c8be 100644 --- a/decidim-accountability/spec/shared/manage_statuses_examples.rb +++ b/decidim-accountability/spec/shared/manage_statuses_examples.rb @@ -3,7 +3,7 @@ RSpec.shared_examples "manage statuses" do it "updates a status" do within "tr", text: status.key do - click_link "Edit" + click_on "Edit" end within ".edit_status" do @@ -26,7 +26,7 @@ end it "creates a new status" do - click_link "New status" + click_on "New status" within ".new_status" do fill_in :status_key, with: "status_key_1" @@ -69,7 +69,7 @@ it "deletes a status" do within "tr", text: status2.key do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") diff --git a/decidim-accountability/spec/system/admin/admin_manages_accountability_spec.rb b/decidim-accountability/spec/system/admin/admin_manages_accountability_spec.rb index ef34763336cb..347e554c4ed4 100644 --- a/decidim-accountability/spec/system/admin/admin_manages_accountability_spec.rb +++ b/decidim-accountability/spec/system/admin/admin_manages_accountability_spec.rb @@ -21,7 +21,7 @@ describe "child results" do before do within ".table-list__actions" do - click_link "New result" + click_on "New result" end end @@ -30,7 +30,7 @@ describe "statuses" do before do - click_link "Statuses" + click_on "Statuses" end it_behaves_like "manage statuses" diff --git a/decidim-accountability/spec/system/admin/admin_orders_results_spec.rb b/decidim-accountability/spec/system/admin/admin_orders_results_spec.rb index 3ad41a566844..99496667cae6 100644 --- a/decidim-accountability/spec/system/admin/admin_orders_results_spec.rb +++ b/decidim-accountability/spec/system/admin/admin_orders_results_spec.rb @@ -29,7 +29,7 @@ it "orders results by ID" do ordered_results = results.sort_by(&:id).reverse - click_link "ID" + click_on "ID" rows = page.all("tbody tr") rows.each_with_index do |row, i| @@ -40,7 +40,7 @@ it "orders results by title" do ordered_results = results.sort_by { |result| translated(result.title) } - click_link "Title" + click_on "Title" rows = page.all("tbody tr") rows.each_with_index do |row, i| @@ -51,7 +51,7 @@ it "orders results by category" do ordered_results = results.sort_by { |result| translated(result.category.name) } - click_link "Category" + click_on "Category" rows = page.all("tbody tr") rows.each_with_index do |row, i| @@ -62,7 +62,7 @@ it "orders results by scope" do ordered_results = results.sort_by { |result| translated(result.scope.name) } - click_link "Scope" + click_on "Scope" rows = page.all("tbody tr") rows.each_with_index do |row, i| @@ -73,7 +73,7 @@ it "orders results by status" do ordered_results = results.sort_by { |result| translated(result.status.name) } - click_link "Status" + click_on "Status" rows = page.all("tbody tr") rows.each_with_index do |row, i| @@ -84,7 +84,7 @@ it "orders results by progress" do ordered_results = results.sort_by(&:progress) - click_link "Progress" + click_on "Progress" rows = page.all("tbody tr") rows.each_with_index do |row, i| @@ -95,7 +95,7 @@ it "orders results by created at" do ordered_results = results.sort_by(&:created_at) - click_link "Created" + click_on "Created" rows = page.all("tbody tr") rows.each_with_index do |row, i| diff --git a/decidim-accountability/spec/system/explore_results_spec.rb b/decidim-accountability/spec/system/explore_results_spec.rb index 8b879fac140f..794cd88c79e0 100644 --- a/decidim-accountability/spec/system/explore_results_spec.rb +++ b/decidim-accountability/spec/system/explore_results_spec.rb @@ -23,7 +23,7 @@ context "when filtering by scope" do it "shows an empty page with a message" do within "div.filter-container" do - click_link translated(scope.name) + click_on translated(scope.name) end within "main" do @@ -116,7 +116,7 @@ context "with a scope" do before do within "div.filter-container" do - click_link translated(scope.name) + click_on translated(scope.name) end end @@ -210,7 +210,7 @@ end it "maintains scope filter" do - click_link translated(category.name) + click_on translated(category.name) within "div.filter-container a.is-active" do expect(page).to have_content(translated(scope.name)) @@ -226,7 +226,7 @@ it "shows all result info" do expect(page).to have_i18n_content(result.title) - expect(page).to have_i18n_content(result.description) + expect(page).to have_i18n_content(result.description, strip_tags: true) expect(page).to have_content(result.reference) expect(page).to have_content("#{result.progress.to_i}%") end @@ -331,12 +331,12 @@ end it "the result is mentioned in the proposal page" do - click_link translated(proposal.title) + click_on translated(proposal.title) expect(page).to have_i18n_content(result.title) end it "a banner links back to the result" do - click_link translated(proposal.title) + click_on translated(proposal.title) expect(page).to have_content("Included in #{translated(result.title)}") end end @@ -365,7 +365,7 @@ end it "the result is mentioned in the project page" do - click_link translated(project.title) + click_on translated(project.title) expect(page).to have_i18n_content(result.title) end end @@ -393,12 +393,12 @@ end it "the result is mentioned in the meeting page" do - click_link translated(meeting.title) + click_on translated(meeting.title) expect(page).to have_i18n_content(result.title) end it "a banner links back to the result" do - click_link translated(meeting.title) + click_on translated(meeting.title) expect(page).to have_content("Included in #{translated(result.title)}") end end diff --git a/decidim-accountability/spec/system/explore_versions_spec.rb b/decidim-accountability/spec/system/explore_versions_spec.rb index bca4bd447ad7..22cff6d3863e 100644 --- a/decidim-accountability/spec/system/explore_versions_spec.rb +++ b/decidim-accountability/spec/system/explore_versions_spec.rb @@ -33,7 +33,7 @@ context "when visiting versions index" do before do - click_link "see other versions" + click_on "see other versions" end it "lists all versions" do @@ -44,8 +44,8 @@ context "when showing version" do before do - click_link "see other versions" - click_link "Version 2 of 2" + click_on "see other versions" + click_on "Version 2 of 2" end it "shows the version author and creation date" do diff --git a/decidim-accountability/spec/types/integration_schema_spec.rb b/decidim-accountability/spec/types/integration_schema_spec.rb index 5bc4ad75d8ab..3812fbea1c7f 100644 --- a/decidim-accountability/spec/types/integration_schema_spec.rb +++ b/decidim-accountability/spec/types/integration_schema_spec.rb @@ -71,7 +71,7 @@ { "__typename" => "Accountability", "id" => current_component.id.to_s, - "name" => { "translation" => "Accountability" }, + "name" => { "translation" => translated(current_component.name) }, "results" => { "edges" => [ { @@ -187,7 +187,7 @@ ) end - it "executes sucessfully" do + it "executes successfully" do expect { response }.not_to raise_error end @@ -294,7 +294,7 @@ ) end - it "executes sucessfully" do + it "executes successfully" do expect { response }.not_to raise_error end diff --git a/decidim-admin/app/cells/decidim/admin/content_block_cell.rb b/decidim-admin/app/cells/decidim/admin/content_block_cell.rb index 83733b187693..15b449640d82 100644 --- a/decidim-admin/app/cells/decidim/admin/content_block_cell.rb +++ b/decidim-admin/app/cells/decidim/admin/content_block_cell.rb @@ -29,7 +29,7 @@ def component def name return I18n.t(public_name_key) if component.blank? - "#{I18n.t(public_name_key)} (#{translated_attribute(component&.name)})" + "#{I18n.t(public_name_key)} (#{decidim_escape_translated(component&.name)})" end end end diff --git a/decidim-admin/app/commands/decidim/admin/destroy_category.rb b/decidim-admin/app/commands/decidim/admin/destroy_category.rb index 39da3d11996a..778178e3dbb2 100644 --- a/decidim-admin/app/commands/decidim/admin/destroy_category.rb +++ b/decidim-admin/app/commands/decidim/admin/destroy_category.rb @@ -5,10 +5,10 @@ module Admin # A command with all the business logic to destroy a category in the # system. class DestroyCategory < Decidim::Commands::DestroyResource - private + protected def invalid? - resource.nil? || resource.subcategories.any? + resource.nil? || resource.subcategories.any? || !resource.unused? end end end diff --git a/decidim-admin/app/commands/decidim/admin/officialize_user.rb b/decidim-admin/app/commands/decidim/admin/officialize_user.rb index 8af3c5d41e1f..51441f9c448c 100644 --- a/decidim-admin/app/commands/decidim/admin/officialize_user.rb +++ b/decidim-admin/app/commands/decidim/admin/officialize_user.rb @@ -13,7 +13,7 @@ def initialize(form) # Executes the command. Broadcasts these events: # - # - :ok when the officialization suceeds. + # - :ok when the officialization succeeds. # - :invalid when the form is invalid. # # Returns nothing. diff --git a/decidim-admin/app/commands/decidim/admin/unofficialize_user.rb b/decidim-admin/app/commands/decidim/admin/unofficialize_user.rb index bad5fd843b46..dcaa4f2edc81 100644 --- a/decidim-admin/app/commands/decidim/admin/unofficialize_user.rb +++ b/decidim-admin/app/commands/decidim/admin/unofficialize_user.rb @@ -15,7 +15,7 @@ def initialize(user, current_user) # Executes the command. Broadcasts these events: # - # - :ok when the unofficialization suceeds. + # - :ok when the unofficialization succeeds. # - :invalid when the form is invalid. # # Returns nothing. diff --git a/decidim-admin/app/controllers/decidim/admin/impersonatable_users_controller.rb b/decidim-admin/app/controllers/decidim/admin/impersonatable_users_controller.rb index 5709a0bbb08d..12cf38926d31 100644 --- a/decidim-admin/app/controllers/decidim/admin/impersonatable_users_controller.rb +++ b/decidim-admin/app/controllers/decidim/admin/impersonatable_users_controller.rb @@ -28,7 +28,7 @@ def index private def collection - @collection ||= current_organization.users.where(admin: false, roles: []).order(created_at: :desc) + @collection ||= current_organization.users.not_deleted.not_blocked.where(admin: false, roles: []).order(created_at: :desc) end def new_managed_user diff --git a/decidim-admin/app/helpers/decidim/admin/newsletters_helper.rb b/decidim-admin/app/helpers/decidim/admin/newsletters_helper.rb index 96746e2233f6..f65ab7702f61 100644 --- a/decidim-admin/app/helpers/decidim/admin/newsletters_helper.rb +++ b/decidim-admin/app/helpers/decidim/admin/newsletters_helper.rb @@ -65,7 +65,7 @@ def sent_to_users(newsletter) def sent_to_spaces(newsletter) html = "

" - newsletter.sended_to_partipatory_spaces.try(:each) do |type| + newsletter.sent_to_participatory_spaces.try(:each) do |type| next if type["ids"].blank? html += t("index.segmented_to", scope: "decidim.admin.newsletters", subject: t("activerecord.models.decidim/#{type["manifest_name"].singularize}.other")) diff --git a/decidim-admin/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb b/decidim-admin/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb index d96e914e7708..a26273396bb5 100644 --- a/decidim-admin/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb +++ b/decidim-admin/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb @@ -17,7 +17,7 @@ def perform(email, user_name, privatable_to, current_user) private_user_form = ParticipatorySpacePrivateUserForm.from_params(params, privatable_to:) .with_context( current_user:, - current_particiaptory_space: privatable_to + current_participatory_space: privatable_to ) Decidim::Admin::CreateParticipatorySpacePrivateUser.call(private_user_form, current_user, privatable_to, via_csv: true) diff --git a/decidim-admin/app/packs/src/decidim/admin/form.js b/decidim-admin/app/packs/src/decidim/admin/form.js index 0f12d6b477db..0dbd0cfb0d09 100644 --- a/decidim-admin/app/packs/src/decidim/admin/form.js +++ b/decidim-admin/app/packs/src/decidim/admin/form.js @@ -28,7 +28,7 @@ $(() => { // - amendment_promotion_enabled // (1) Hides target fields if amendments_enabled component setting is NOT checked. - // (2) Toggles visibilty of target fields when amendments_enabled component setting is clicked. + // (2) Toggles visibility of target fields when amendments_enabled component setting is clicked. const $amendmentsEnabled = $("input#component_settings_amendments_enabled"); if ($amendmentsEnabled.length > 0) { diff --git a/decidim-admin/app/views/decidim/admin/block_user/new.html.erb b/decidim-admin/app/views/decidim/admin/block_user/new.html.erb index 54ff3b161455..e62f0e08d20f 100644 --- a/decidim-admin/app/views/decidim/admin/block_user/new.html.erb +++ b/decidim-admin/app/views/decidim/admin/block_user/new.html.erb @@ -16,8 +16,7 @@ <% if @form.hide %> - <% announcement_message = t(".already_reported_html", link: new_user_block_path(user_id: user.id)) %> - <%= cell("decidim/announcement", announcement_message, callout_class: "alert" ) %> + <%= cell("decidim/announcement", t(".already_reported_html"), callout_class: "alert" ) %> <% end %> <% if defined?(Decidim::Templates) %> diff --git a/decidim-admin/app/views/decidim/admin/categories/index.html.erb b/decidim-admin/app/views/decidim/admin/categories/index.html.erb index f996cd740bb7..5a17b62433f2 100644 --- a/decidim-admin/app/views/decidim/admin/categories/index.html.erb +++ b/decidim-admin/app/views/decidim/admin/categories/index.html.erb @@ -48,7 +48,11 @@ <% end %> <% if allowed_to? :destroy, :category, category: subcategory %> - <%= icon_link_to "delete-bin-line", category_path(current_participatory_space, subcategory), t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } %> + <% if subcategory.unused? %> + <%= icon_link_to "delete-bin-line", category_path(current_participatory_space, subcategory), t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } %> + <% else %> + <%= icon "delete-bin-line", class: "action-icon action-icon--disabled", role: "img", "aria-hidden": true %> + <% end %> <% end %> diff --git a/decidim-admin/app/views/decidim/admin/imports/new.html.erb b/decidim-admin/app/views/decidim/admin/imports/new.html.erb index 63b34dc7b28d..5c91e0983e60 100644 --- a/decidim-admin/app/views/decidim/admin/imports/new.html.erb +++ b/decidim-admin/app/views/decidim/admin/imports/new.html.erb @@ -5,7 +5,7 @@

<% if import_manifest.has_example? %> - + <%= t(".download_example") %> <%= icon "arrow-down-s-line", class: "dropdown-filter-icon" %> @@ -21,7 +21,7 @@
<% end %> - <%= link_to t(".actions.back"), manage_component_path(@current_component), class: "button button__sm button__secondary hollow tiny button--simple" %> + <%= link_to t(".actions.back"), manage_component_path(@current_component), class: "button button__sm button__secondary hollow button--simple" %> diff --git a/decidim-admin/app/views/decidim/admin/shared/landing_page/_content_blocks.html.erb b/decidim-admin/app/views/decidim/admin/shared/landing_page/_content_blocks.html.erb index 702e6459f4d0..b9b620e99a4d 100644 --- a/decidim-admin/app/views/decidim/admin/shared/landing_page/_content_blocks.html.erb +++ b/decidim-admin/app/views/decidim/admin/shared/landing_page/_content_blocks.html.erb @@ -40,7 +40,7 @@
<%= inactive_content_blocks_title %>
-
    +
      <% inactive_blocks.each do |content_block_or_manifest| %> <%= cell resource_content_block_cell, content_block_or_manifest %> <% end %> diff --git a/decidim-admin/config/locales/en.yml b/decidim-admin/config/locales/en.yml index fe65cc01169b..8461ca816727 100644 --- a/decidim-admin/config/locales/en.yml +++ b/decidim-admin/config/locales/en.yml @@ -288,7 +288,7 @@ en: block_user: new: action: Block account and send justification - already_reported_html: Continuing with this action you will also hide all the participants contents. Block the account. + already_reported_html: Continuing with this action you will also hide all the participants contents. description: Blocking a user will render their account unusable. You may provide in your justification any guidelines on ways you would consider unblocking the user. justification: Justification title: Block User %{name} @@ -355,7 +355,7 @@ en: title: Verification conflicts transfer: email: Email - error: There was a problem transfering the current participant to managed participant. + error: There was a problem transferring the current participant to managed participant. name: Name reason: Reason success: The current transfer has been successfully completed. diff --git a/decidim-admin/lib/decidim/admin/test/commands/destroy_category_examples.rb b/decidim-admin/lib/decidim/admin/test/commands/destroy_category_examples.rb index 9a013cae8afd..e2143a324fb1 100644 --- a/decidim-admin/lib/decidim/admin/test/commands/destroy_category_examples.rb +++ b/decidim-admin/lib/decidim/admin/test/commands/destroy_category_examples.rb @@ -19,6 +19,15 @@ module Admin end end + context "when the category is being used by a resource" do + let(:component) { create(:dummy_component, participatory_space:) } + let!(:resource) { create(:dummy_resource, component:, category:) } + + it "broadcasts invalid" do + expect { command.call }.to broadcast(:invalid) + end + end + context "when the category is not empty" do let!(:subcategory) { create :subcategory, parent: category } diff --git a/decidim-admin/lib/decidim/admin/test/filterable_examples.rb b/decidim-admin/lib/decidim/admin/test/filterable_examples.rb index fa487228920b..e5d41dec1fae 100644 --- a/decidim-admin/lib/decidim/admin/test/filterable_examples.rb +++ b/decidim-admin/lib/decidim/admin/test/filterable_examples.rb @@ -11,13 +11,15 @@ def apply_filter(options, filter) within(".filters__section") do find_link("Filter").hover find_link(options).hover - click_link(filter, href: /q/) + within ".submenu > .is-active > .submenu" do + click_on(filter) + end end end def remove_applied_filter(filter) within("[data-applied-filters-tags] .label", text: /#{filter}/i) do - click_link("Cancel") + click_on("Cancel") end end @@ -50,7 +52,7 @@ def search_by_text(text) before { apply_filter(options, filter) } it { expect(page).to have_content(in_filter) } - it { expect(page).not_to have_content(not_in_filter) } + it { expect(page).to have_no_content(not_in_filter) } it_behaves_like "searching by text" do let(:text) { in_filter } diff --git a/decidim-admin/lib/decidim/admin/test/filters_participatory_space_user_roles_examples.rb b/decidim-admin/lib/decidim/admin/test/filters_participatory_space_user_roles_examples.rb index fe97eac255e4..3f9af3db17ee 100644 --- a/decidim-admin/lib/decidim/admin/test/filters_participatory_space_user_roles_examples.rb +++ b/decidim-admin/lib/decidim/admin/test/filters_participatory_space_user_roles_examples.rb @@ -14,7 +14,7 @@ let(:sort_by) { "name asc" } it "displays the result" do - expect(page).not_to have_content(user.name) + expect(page).to have_no_content(user.name) end end end @@ -32,7 +32,7 @@ let(:sort_by) { "email asc" } it "displays the result" do - expect(page).not_to have_content(user.name) + expect(page).to have_no_content(user.name) end end end @@ -50,7 +50,7 @@ let(:sort_by) { "last_sign_in_at asc" } it "displays the result" do - expect(page).not_to have_content(user.name) + expect(page).to have_no_content(user.name) end end end @@ -68,7 +68,7 @@ let(:sort_by) { "invitation_accepted_at asc" } it "displays the result" do - expect(page).not_to have_content(user.name) + expect(page).to have_no_content(user.name) end end end @@ -86,7 +86,7 @@ let(:sort_by) { "role asc" } it "displays the result" do - expect(page).not_to have_content(user.name) + expect(page).to have_no_content(user.name) end end end diff --git a/decidim-admin/lib/decidim/admin/test/manage_attachment_collections_examples.rb b/decidim-admin/lib/decidim/admin/test/manage_attachment_collections_examples.rb index dc56305c8891..117a873c19ea 100644 --- a/decidim-admin/lib/decidim/admin/test/manage_attachment_collections_examples.rb +++ b/decidim-admin/lib/decidim/admin/test/manage_attachment_collections_examples.rb @@ -15,16 +15,16 @@ it "can view an attachment collection details" do within "#attachment_collections table" do - click_link "Edit" + click_on "Edit" end - expect(page).to have_selector("input#attachment_collection_name_en[value='#{translated(attachment_collection.name, locale: :en)}']") - expect(page).to have_selector("input#attachment_collection_weight[value='#{attachment_collection.weight}']") - expect(page).to have_selector("input#attachment_collection_description_en[value='#{translated(attachment_collection.description, locale: :en)}']") + expect(page).to have_css("input#attachment_collection_name_en[value='#{translated(attachment_collection.name, locale: :en)}']") + expect(page).to have_css("input#attachment_collection_weight[value='#{attachment_collection.weight}']") + expect(page).to have_css("input#attachment_collection_description_en[value='#{translated(attachment_collection.description, locale: :en)}']") end it "can add attachment collections to a process" do - click_link "New attachment folder" + click_on "New attachment folder" within ".new_attachment_collection" do fill_in_i18n( @@ -55,8 +55,8 @@ it "can update an attachment collection" do within "#attachment_collections" do - within find("tr", text: translated(attachment_collection.name)) do - click_link "Edit" + within "tr", text: translated(attachment_collection.name) do + click_on "Edit" end end @@ -88,14 +88,14 @@ end it "can delete the attachment collection" do - within find("tr", text: translated(attachment_collection2.name)) do - accept_confirm { click_link "Delete" } + within "tr", text: translated(attachment_collection2.name) do + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") within "#attachment_collections table" do - expect(page).not_to have_content(translated(attachment_collection2.name)) + expect(page).to have_no_content(translated(attachment_collection2.name)) end end end @@ -108,8 +108,8 @@ end it "cannot delete it" do - within find("tr", text: translated(attachment_collection.name)) do - expect(page).not_to have_selector("a.action-icon--remove") + within "tr", text: translated(attachment_collection.name) do + expect(page).to have_no_css("a.action-icon--remove") end end end diff --git a/decidim-admin/lib/decidim/admin/test/manage_attachments_examples.rb b/decidim-admin/lib/decidim/admin/test/manage_attachments_examples.rb index 0c285458175d..4f60bf695803 100644 --- a/decidim-admin/lib/decidim/admin/test/manage_attachments_examples.rb +++ b/decidim-admin/lib/decidim/admin/test/manage_attachments_examples.rb @@ -19,18 +19,18 @@ it "can view an attachment details" do within "#attachments table" do - click_link "Edit" + click_on "Edit" end - expect(page).to have_selector("input#attachment_title_en[value='#{translated(attachment.title, locale: :en)}']") - expect(page).to have_selector("input#attachment_description_en[value='#{translated(attachment.description, locale: :en)}']") - expect(page).to have_selector("input#attachment_weight[value='#{attachment.weight}']") + expect(page).to have_css("input#attachment_title_en[value='#{translated(attachment.title, locale: :en)}']") + expect(page).to have_css("input#attachment_description_en[value='#{translated(attachment.description, locale: :en)}']") + expect(page).to have_css("input#attachment_weight[value='#{attachment.weight}']") expect(page).to have_select("attachment_attachment_collection_id", selected: translated(attachment_collection.name, locale: :en)) expect(page).to have_css("img[src~='#{attachment.url}']") end it "can add attachments without a collection to a process" do - click_link "New attachment" + click_on "New attachment" within ".new_attachment" do fill_in_i18n( @@ -64,7 +64,7 @@ end it "can add attachments within a collection to a process" do - click_link "New attachment" + click_on "New attachment" within ".new_attachment" do fill_in_i18n( @@ -102,9 +102,9 @@ it "can remove an attachment from a collection" do within "#attachments" do - within find("tr", text: translated(attachment.title)) do + within "tr", text: translated(attachment.title) do expect(page).to have_text(translated(attachment_collection.name, locale: :en)) - click_link "Edit" + click_on "Edit" end end @@ -115,26 +115,26 @@ end within "#attachments" do - within find("tr", text: translated(attachment.title)) do - expect(page).not_to have_text(translated(attachment_collection.name, locale: :en)) + within "tr", text: translated(attachment.title) do + expect(page).to have_no_text(translated(attachment_collection.name, locale: :en)) end end end it "can delete an attachment from a process" do - within find("tr", text: translated(attachment.title)) do - accept_confirm { click_link "Delete" } + within "tr", text: translated(attachment.title) do + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") - expect(page).not_to have_content(translated(attachment.title, locale: :en)) + expect(page).to have_no_content(translated(attachment.title, locale: :en)) end it "can update an attachment" do within "#attachments" do - within find("tr", text: translated(attachment.title)) do - click_link "Edit" + within "tr", text: translated(attachment.title) do + click_on "Edit" end end diff --git a/decidim-admin/lib/decidim/admin/test/manage_categories_examples.rb b/decidim-admin/lib/decidim/admin/test/manage_categories_examples.rb index 2628f950e7e5..777ae9d05516 100644 --- a/decidim-admin/lib/decidim/admin/test/manage_categories_examples.rb +++ b/decidim-admin/lib/decidim/admin/test/manage_categories_examples.rb @@ -9,17 +9,17 @@ it "can view a category detail" do within "#categories table" do - click_link translated(category.name, locale: :en) + click_on translated(category.name, locale: :en) end - expect(page).to have_selector("input#category_name_en[value='#{translated(category.name, locale: :en)}']") - expect(page).to have_selector("input#category_weight[value='#{category.weight}']") + expect(page).to have_css("input#category_name_en[value='#{translated(category.name, locale: :en)}']") + expect(page).to have_css("input#category_weight[value='#{category.weight}']") expect(page).to have_select(id: "category_parent_id") end it "creates a new category" do - click_link "New category" + click_on "New category" within ".new_category" do fill_in_i18n( @@ -42,8 +42,8 @@ it "updates a category" do within "#categories" do - within find("tr", text: translated(category.name)) do - click_link "Edit" + within "tr", text: translated(category.name) do + click_on "Edit" end end @@ -76,14 +76,14 @@ end it "deletes a category" do - within find("tr", text: translated(category2.name)) do - accept_confirm { click_link "Delete" } + within "tr", text: translated(category2.name) do + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") within "#categories table" do - expect(page).not_to have_content(translated(category2.name)) + expect(page).to have_no_content(translated(category2.name)) end end end @@ -96,8 +96,8 @@ end it "deletes a category" do - within find("tr", text: translated(category2.name)) do - accept_confirm { click_link "Delete" } + within "tr", text: translated(category2.name) do + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("problem deleting") @@ -116,8 +116,8 @@ it "cannot delete it" do visit current_path - within find("tr", text: translated(category.name)) do - expect(page).not_to have_selector("a.action-icon--remove") + within "tr", text: translated(category.name) do + expect(page).to have_no_css("a.action-icon--remove") end end end diff --git a/decidim-admin/lib/decidim/admin/test/manage_component_permissions_examples.rb b/decidim-admin/lib/decidim/admin/test/manage_component_permissions_examples.rb index 2e55f2fe48ed..238ed8cd09b9 100644 --- a/decidim-admin/lib/decidim/admin/test/manage_component_permissions_examples.rb +++ b/decidim-admin/lib/decidim/admin/test/manage_component_permissions_examples.rb @@ -23,7 +23,7 @@ context "when setting permissions" do before do within ".component-#{component.id}" do - click_link "Permissions" + click_on "Permissions" end end @@ -54,7 +54,7 @@ before do allow_any_instance_of(Decidim::Admin::PermissionsForm).to receive(:valid?).and_return(false) within ".component-#{component.id}" do - click_link "Permissions" + click_on "Permissions" end within "#components form" do within ".foo-permission" do @@ -85,7 +85,7 @@ ) within ".component-#{component.id}" do - click_link "Permissions" + click_on "Permissions" end end @@ -120,7 +120,7 @@ ) within ".component-#{component.id}" do - click_link "Permissions" + click_on "Permissions" end end @@ -206,7 +206,7 @@ let(:component_settings) { { resources_permissions_enabled: false } } it "does not show the resource permissions settings" do - expect(page).not_to have_content(resource.title) + expect(page).to have_no_content(resource.title) end end diff --git a/decidim-admin/lib/decidim/admin/test/manage_hide_content_examples.rb b/decidim-admin/lib/decidim/admin/test/manage_hide_content_examples.rb index 9bad18e8be68..bf8ab353e743 100644 --- a/decidim-admin/lib/decidim/admin/test/manage_hide_content_examples.rb +++ b/decidim-admin/lib/decidim/admin/test/manage_hide_content_examples.rb @@ -19,7 +19,7 @@ visit reportable_path within ".profile__actions-secondary", match: :first do - click_button(I18n.t("decidim.shared.flag_modal.report")) + click_on(I18n.t("decidim.shared.flag_modal.report")) end within ".flag-modal" do find(:css, "input[name='report[block]']").set(true) @@ -31,7 +31,7 @@ within ".flag-modal" do find(:css, "input[name='report[hide]']").set(true) end - click_button I18n.t("decidim.shared.flag_user_modal.block") + click_on I18n.t("decidim.shared.flag_user_modal.block") expect(page).to have_current_path(decidim_admin.new_user_block_path(user_id: reportable.id, hide: true)) end @@ -46,12 +46,12 @@ within ".flag-modal" do find(:css, "input[name='report[hide]']").set(true) end - click_button I18n.t("decidim.shared.flag_user_modal.block") + click_on I18n.t("decidim.shared.flag_user_modal.block") expect(page).to have_current_path(decidim_admin.new_user_block_path(user_id: reportable.id, hide: true)) fill_in :block_user_justification, with: "This user is a spammer" * 2 # to have at least 15 chars - click_button I18n.t("decidim.admin.block_user.new.action") + click_on I18n.t("decidim.admin.block_user.new.action") expect(content.reload).to be_hidden end diff --git a/decidim-admin/lib/decidim/admin/test/manage_moderations_examples.rb b/decidim-admin/lib/decidim/admin/test/manage_moderations_examples.rb index 8c2bed2e08ff..d6d5ab448edf 100644 --- a/decidim-admin/lib/decidim/admin/test/manage_moderations_examples.rb +++ b/decidim-admin/lib/decidim/admin/test/manage_moderations_examples.rb @@ -15,16 +15,16 @@ before do visit participatory_space_path if moderations_link_in_admin_menu - within_admin_sidebar_menu { click_link(moderations_link_text) } + within_admin_sidebar_menu { click_on(moderations_link_text) } else - within("div.layout-nav") { click_link(moderations_link_text) } + within("div.layout-nav") { click_on(moderations_link_text) } end end it "sorts the most recent first" do link_text = find("ul[data-pages]").text.split("\n")[-2] within "ul[data-pages]" do - click_link link_text + click_on link_text end all("tbody tr").each_with_index do |row, _index| expect(row.find("td:first-child")).to have_content(reportables.first.id) @@ -54,9 +54,9 @@ before do visit participatory_space_path if moderations_link_in_admin_menu - within_admin_sidebar_menu { click_link(moderations_link_text) } + within_admin_sidebar_menu { click_on(moderations_link_text) } else - within("div.layout-nav") { click_link(moderations_link_text) } + within("div.layout-nav") { click_on(moderations_link_text) } end end @@ -68,7 +68,7 @@ visit current_path - expect(page).not_to have_selector("tr[data-id=\"#{external_moderation.id}\"]") + expect(page).to have_no_css("tr[data-id=\"#{external_moderation.id}\"]") end it "user can review them" do @@ -82,7 +82,7 @@ it "user can un-report a resource" do within "tr[data-id=\"#{moderation.id}\"]" do - click_link "Unreport" + click_on "Unreport" end expect(page).to have_admin_callout("Resource successfully unreported") @@ -90,11 +90,11 @@ it "user can hide a resource" do within "tr[data-id=\"#{moderation.id}\"]" do - click_link "Hide" + click_on "Hide" end expect(page).to have_admin_callout("Resource successfully hidden") - expect(page).not_to have_content(moderation.reportable.reported_content_url) + expect(page).to have_no_content(moderation.reportable.reported_content_url) end it "user can sort by report count" do @@ -102,7 +102,7 @@ moderations_ordered_by_report_count_asc = moderations.sort_by(&:report_count) within "table" do - click_link "Reports count" + click_on "Reports count" all("tbody tr").each_with_index do |row, index| reportable_id = moderations_ordered_by_report_count_asc[index].reportable.id @@ -116,23 +116,23 @@ within ".filters__section" do find(:xpath, "//a[contains(text(), 'Filter')]").hover find(:xpath, "//a[contains(text(), 'Type')]").hover - click_link reportable_type + click_on reportable_type end - expect(page).to have_selector("tbody tr", count: moderations.length) + expect(page).to have_css("tbody tr", count: moderations.length) end it "user can filter by reported content" do search = moderation.reportable.id within ".filters__section" do fill_in("Search Moderation by reportable id or content.", with: search) - click_button(type: "submit") + within(".input-group-button") { click_on(class: "text-secondary") } end - expect(page).to have_selector("tbody tr", count: 1) + expect(page).to have_css("tbody tr", count: 1) end it "user can see moderation details" do within "tr[data-id=\"#{moderation.id}\"]" do - click_link "Expand" + click_on "Expand" end reported_content_slice = moderation.reportable.reported_searchable_content_text.split("\n").first @@ -144,7 +144,7 @@ moderation.reportable.destroy visit current_path - expect(page).not_to have_selector("tr[data-id=\"#{moderation.id}\"]") + expect(page).to have_no_css("tr[data-id=\"#{moderation.id}\"]") end end @@ -170,7 +170,7 @@ ) within_language_menu(admin: true) do - click_link "Català" + click_on "Català" end end @@ -184,11 +184,11 @@ context "when listing hidden resources" do before do - click_link "Hidden" + click_on "Hidden" end it "user cannot unreport them" do - expect(page).not_to have_css(".action-icon--unreport") + expect(page).to have_no_css(".action-icon--unreport") end it "user can review them" do @@ -231,11 +231,11 @@ it "user can hide them" do moderation_id = moderations.first.id within "tr[data-id=\"#{moderation_id}\"]" do - click_link "Hide" + click_on "Hide" end expect(page).to have_admin_callout("Resource successfully hidden") - expect(page).not_to have_selector("tr[data-id=\"#{moderation_id}\"]") + expect(page).to have_no_css("tr[data-id=\"#{moderation_id}\"]") end end end diff --git a/decidim-admin/lib/decidim/admin/test/manage_paginated_collection_examples.rb b/decidim-admin/lib/decidim/admin/test/manage_paginated_collection_examples.rb index 140b7a633b47..c7ea21248be8 100644 --- a/decidim-admin/lib/decidim/admin/test/manage_paginated_collection_examples.rb +++ b/decidim-admin/lib/decidim/admin/test/manage_paginated_collection_examples.rb @@ -3,7 +3,7 @@ shared_examples "a paginated collection" do |options| before do # Current path strips out the request parameters, use current_url when needed - # Be aware that current_utl can lead to flaky, use with caution + # Be aware that current_url can lead to flaky, use with caution if options&.dig(:url) visit current_url else @@ -19,10 +19,10 @@ it "changes the number of results per page" do within "[data-pagination]" do page.find("details", text: "15").click - click_link "50" + click_on "50" end - expect(page).to have_selector(".table-list tbody tr", count: 50) + expect(page).to have_css(".table-list tbody tr", count: 50) end end end diff --git a/decidim-admin/lib/decidim/admin/test/manage_participatory_space_publications_examples.rb b/decidim-admin/lib/decidim/admin/test/manage_participatory_space_publications_examples.rb index 174b4242f50e..3bd38d318305 100644 --- a/decidim-admin/lib/decidim/admin/test/manage_participatory_space_publications_examples.rb +++ b/decidim-admin/lib/decidim/admin/test/manage_participatory_space_publications_examples.rb @@ -15,7 +15,7 @@ end it "publishes it" do - click_link "Publish" + click_on "Publish" expect(page).to have_content("successfully") @@ -42,7 +42,7 @@ it "unpublishes it" do # we cannot use "a 404 page" shared example as we want to check it # inside an example - click_link "Unpublish" + click_on "Unpublish" expect(page).to have_content("successfully") diff --git a/decidim-admin/spec/commands/decidim/admin/update_organization_tos_version_spec.rb b/decidim-admin/spec/commands/decidim/admin/update_organization_tos_version_spec.rb index 7eb3554300a8..ade0a28e40ca 100644 --- a/decidim-admin/spec/commands/decidim/admin/update_organization_tos_version_spec.rb +++ b/decidim-admin/spec/commands/decidim/admin/update_organization_tos_version_spec.rb @@ -74,7 +74,7 @@ module Decidim::Admin expect(action_log.action).to eq "update" end - it "updates the the organization's terms-of-service updated at setting" do + it "updates the organization's terms-of-service updated at setting" do command.call tos_page.reload organization.reload diff --git a/decidim-admin/spec/commands/decidim/admin/update_static_page_changed_notably_spec.rb b/decidim-admin/spec/commands/decidim/admin/update_static_page_changed_notably_spec.rb index 37e7b170c633..485ffa5d8ee9 100644 --- a/decidim-admin/spec/commands/decidim/admin/update_static_page_changed_notably_spec.rb +++ b/decidim-admin/spec/commands/decidim/admin/update_static_page_changed_notably_spec.rb @@ -38,7 +38,7 @@ module Decidim::Admin expect(action_log.version.object_changes).to include "tos_version" end - it "updates the the organization's terms-of-service version setting" do + it "updates the organization's terms-of-service version setting" do command.call organization.reload page.reload diff --git a/decidim-admin/spec/controllers/conflicts_controller_spec.rb b/decidim-admin/spec/controllers/conflicts_controller_spec.rb index 839a759dd582..6cec851fc926 100644 --- a/decidim-admin/spec/controllers/conflicts_controller_spec.rb +++ b/decidim-admin/spec/controllers/conflicts_controller_spec.rb @@ -69,7 +69,7 @@ module Admin } } - expect(flash[:alert]).to eq("There was a problem transfering the current participant to managed participant.") + expect(flash[:alert]).to eq("There was a problem transferring the current participant to managed participant.") end end end diff --git a/decidim-admin/spec/shared/manage_impersonations_examples.rb b/decidim-admin/spec/shared/manage_impersonations_examples.rb index b9b276b37694..76679e87a946 100644 --- a/decidim-admin/spec/shared/manage_impersonations_examples.rb +++ b/decidim-admin/spec/shared/manage_impersonations_examples.rb @@ -26,7 +26,7 @@ before do navigate_to_impersonations_page - click_link "Manage new participant" + click_on "Manage new participant" fill_in_the_impersonation_form(document_number, name: "Rigoberto") end @@ -81,7 +81,7 @@ before do visit resource_locator(dummy_resource).path - click_link "Foo" + click_on "Foo" end context "and the action allowed by the handler used to impersonate" do @@ -104,7 +104,7 @@ end it "closes the current session and check the logs" do - click_button "Close session" + click_on "Close session" expect(page).to have_content("successfully") @@ -145,7 +145,7 @@ it "does not offer authorization handler selection" do navigate_to_impersonations_page - click_link "Manage new participant" + click_on "Manage new participant" expect(page).to have_no_select("Authorization method") end @@ -161,7 +161,7 @@ it "allows selecting the preferred authorization handler" do navigate_to_impersonations_page - click_link "Manage new participant" + click_on "Manage new participant" expect(page).to have_select("Authorization method") expect(page).to have_field("Document number").and have_no_field("Passport number") @@ -217,7 +217,7 @@ it_behaves_like "impersonating a user" it "saves the reason in the impersonation logs" do - click_button "Close session" + click_on "Close session" expect(page).to have_content("successfully") check_impersonation_logs @@ -238,14 +238,14 @@ navigate_to_impersonations_page within "tr", text: managed_user.name do - click_link "Promote" + click_on "Promote" end within ".item__edit form" do fill_in :managed_user_promotion_email, with: "foo@example.org" end - perform_enqueued_jobs { click_button "Promote" } + perform_enqueued_jobs { click_on "Promote" } expect(page).to have_content("successfully") expect(page).to have_content(managed_user.name) @@ -262,7 +262,7 @@ expect(page).to have_content("successfully") within_user_menu do - click_link "My public profile" + click_on "My public profile" end expect(page).to have_content(managed_user.name) @@ -286,7 +286,7 @@ it "show only verifications of current organization" do navigate_to_impersonations_page within_admin_sidebar_menu do - click_link "Verification conflicts" + click_on "Verification conflicts" end expect(page).to have_content("Rigoberto") @@ -302,7 +302,7 @@ it "show only verifications of current organization" do navigate_to_impersonations_page within_admin_sidebar_menu do - click_link "Verification conflicts" + click_on "Verification conflicts" end expect(page).to have_no_content("Rigoberto") @@ -324,7 +324,7 @@ def fill_in_the_impersonation_form(document_number, name: nil, reason: nil) within "[data-content]" do expect(page).to have_css("*[type=submit]", count: 1) - click_button "Impersonate" + click_on "Impersonate" end end @@ -332,7 +332,7 @@ def impersonate(user, reason: nil) navigate_to_impersonations_page within "tr", text: user.name do - click_link "Impersonate" + click_on "Impersonate" end fill_in_the_impersonation_form("123456789X", reason:) @@ -351,7 +351,7 @@ def simulate_session_expiration def check_impersonation_logs within "tr", text: impersonated_user.name do - click_link "View logs" + click_on "View logs" end expect(page).to have_css("tbody tr", count: 1) diff --git a/decidim-admin/spec/system/admin_checks_logs_spec.rb b/decidim-admin/spec/system/admin_checks_logs_spec.rb index c1f721010749..81f123f34ce2 100644 --- a/decidim-admin/spec/system/admin_checks_logs_spec.rb +++ b/decidim-admin/spec/system/admin_checks_logs_spec.rb @@ -12,7 +12,7 @@ switch_to_host(organization.host) login_as user, scope: :user visit decidim_admin.root_path - click_link "Admin activity log" + click_on "Admin activity log" end it "lists all recent logs" do diff --git a/decidim-admin/spec/system/admin_checks_metrics_spec.rb b/decidim-admin/spec/system/admin_checks_metrics_spec.rb index 1b15b4c1efd1..e7dc1898c643 100644 --- a/decidim-admin/spec/system/admin_checks_metrics_spec.rb +++ b/decidim-admin/spec/system/admin_checks_metrics_spec.rb @@ -26,7 +26,7 @@ end it "allows checking more metrics" do - click_link "See more metrics" + click_on "See more metrics" expect(page).to have_content("Metrics") expect(page).to have_css(".areachart", count: metric_manifests.count) diff --git a/decidim-admin/spec/system/admin_manage_moderated_users_spec.rb b/decidim-admin/spec/system/admin_manage_moderated_users_spec.rb index 3d075f3fd280..a043fc9e4e3a 100644 --- a/decidim-admin/spec/system/admin_manage_moderated_users_spec.rb +++ b/decidim-admin/spec/system/admin_manage_moderated_users_spec.rb @@ -77,7 +77,7 @@ context "when sorting" do context "with report count" do it "sorts reported users by report count" do - click_link "Reports count" + click_on "Reports count" all("tbody").last do expect(all("tr").first.text).to include(first_user.name) @@ -154,7 +154,7 @@ context "when sorting" do context "with report count" do it "sorts reported users by report count" do - click_link "Reports count" + click_on "Reports count" all("tbody").last do expect(all("tr").first.text).to include(first_user.nickname) diff --git a/decidim-admin/spec/system/admin_manages_help_sections_spec.rb b/decidim-admin/spec/system/admin_manages_help_sections_spec.rb index 820b1438bdd3..1dbebd692c84 100644 --- a/decidim-admin/spec/system/admin_manages_help_sections_spec.rb +++ b/decidim-admin/spec/system/admin_manages_help_sections_spec.rb @@ -18,7 +18,7 @@ "#sections_participatory_processes_content", en: "

      Well hello!

      " - click_button "Save" + click_on "Save" expect(page).to have_admin_callout "Help sections updated successfully" @@ -33,7 +33,7 @@ it "destroys the section when it is empty" do clear_i18n_editor :help_sections_sections_participatory_processes_content, "#sections_participatory_processes_content", [:en] - click_button "Save" + click_on "Save" expect(page).to have_admin_callout "Help sections updated successfully" diff --git a/decidim-admin/spec/system/admin_manages_impersonatable_users_list_spec.rb b/decidim-admin/spec/system/admin_manages_impersonatable_users_list_spec.rb index d005ab5a8b94..4456c4e89b4e 100644 --- a/decidim-admin/spec/system/admin_manages_impersonatable_users_list_spec.rb +++ b/decidim-admin/spec/system/admin_manages_impersonatable_users_list_spec.rb @@ -11,34 +11,41 @@ switch_to_host(organization.host) login_as admin, scope: :user visit decidim_admin.root_path - click_link "Participants" + click_on "Participants" end describe "listing impersonatable users" do let!(:managed) { create(:user, :managed, organization:) } - let!(:not_managed) { create(:user, organization:) } - let!(:external_not_managed) { create(:user) } - let!(:another_admin) { create(:user, :admin) } - let!(:user_manager) { create(:user, :user_manager) } + let!(:deleted) { create(:user, :confirmed, :deleted, organization:) } + let!(:blocked) { create(:user, :confirmed, :blocked, organization:) } + let!(:another_admin) { create(:user, :admin, organization:) } + let!(:user_manager) { create(:user, :user_manager, organization:) } + let!(:external_not_managed) { create(:user) } + let!(:external_admin) { create(:user, :admin) } + let!(:external_user_manager) { create(:user, :user_manager) } before do within_admin_sidebar_menu do - click_link "Impersonations" + click_on "Impersonations" end end it "shows each user and its managed status" do expect(page).to have_css("tr[data-user-id=\"#{managed.id}\"]", text: managed.name) expect(page).to have_css("tr[data-user-id=\"#{managed.id}\"]", text: "Managed") + expect(page).to have_css("tr[data-user-id=\"#{not_managed.id}\"]", text: not_managed.name) + expect(page).to have_css("tr[data-user-id=\"#{not_managed.id}\"]", text: "Not managed") - expect(page).to have_no_css("tr[data-user-id=\"#{external_not_managed.id}\"]", text: not_managed.name) + expect(page).to have_no_css("tr[data-user-id=\"#{admin.id}\"]", text: admin.name) + expect(page).to have_no_css("tr[data-user-id=\"#{deleted.id}\"]", text: deleted.name) + expect(page).to have_no_css("tr[data-user-id=\"#{blocked.id}\"]", text: blocked.name) expect(page).to have_no_css("tr[data-user-id=\"#{another_admin.id}\"]", text: another_admin.name) expect(page).to have_no_css("tr[data-user-id=\"#{user_manager.id}\"]", text: user_manager.name) - - expect(page).to have_css("tr[data-user-id=\"#{not_managed.id}\"]", text: not_managed.name) - expect(page).to have_css("tr[data-user-id=\"#{not_managed.id}\"]", text: "Not managed") + expect(page).to have_no_css("tr[data-user-id=\"#{external_not_managed.id}\"]", text: external_not_managed.name) + expect(page).to have_no_css("tr[data-user-id=\"#{external_admin.id}\"]", text: external_admin.name) + expect(page).to have_no_css("tr[data-user-id=\"#{external_user_manager.id}\"]", text: external_user_manager.name) end end end diff --git a/decidim-admin/spec/system/admin_manages_impersonations_spec.rb b/decidim-admin/spec/system/admin_manages_impersonations_spec.rb index f54cbeb647c1..97b429d3196c 100644 --- a/decidim-admin/spec/system/admin_manages_impersonations_spec.rb +++ b/decidim-admin/spec/system/admin_manages_impersonations_spec.rb @@ -7,9 +7,9 @@ def navigate_to_impersonations_page visit decidim_admin.root_path - click_link "Participants" + click_on "Participants" within_admin_sidebar_menu do - click_link "Impersonations" + click_on "Impersonations" end end diff --git a/decidim-admin/spec/system/admin_manages_newsletter_templates_spec.rb b/decidim-admin/spec/system/admin_manages_newsletter_templates_spec.rb index 339b94f4bc53..cb687f502738 100644 --- a/decidim-admin/spec/system/admin_manages_newsletter_templates_spec.rb +++ b/decidim-admin/spec/system/admin_manages_newsletter_templates_spec.rb @@ -29,7 +29,7 @@ find(".button.new").click within "#basic_only_text" do - click_link "Preview" + click_on "Preview" end expect(page).to have_content("Preview template: Basic (only text)") @@ -45,10 +45,10 @@ find(".button.new").click within "#basic_only_text" do - click_link "Preview" + click_on "Preview" end - click_link "Use this template" + click_on "Use this template" expect(page).to have_content("New newsletter") end diff --git a/decidim-admin/spec/system/admin_manages_newsletters_spec.rb b/decidim-admin/spec/system/admin_manages_newsletters_spec.rb index 2537f77dd12a..f657c61aaaa7 100644 --- a/decidim-admin/spec/system/admin_manages_newsletters_spec.rb +++ b/decidim-admin/spec/system/admin_manages_newsletters_spec.rb @@ -34,7 +34,7 @@ find(".button.new").click within "#image_text_cta" do - click_link "Use this template" + click_on "Use this template" end within ".new_newsletter" do @@ -116,7 +116,7 @@ it "sends a test email" do visit decidim_admin.newsletter_path(newsletter) perform_enqueued_jobs do - click_link "Send me a test email" + click_on "Send me a test email" end expect(page).to have_content("Newsletter has been sent") expect(last_email.subject).to include("A fancy newsletter for") @@ -127,7 +127,7 @@ it "sends a test email" do visit decidim_admin.newsletters_path perform_enqueued_jobs do - click_link "Send me a test email" + click_on "Send me a test email" end expect(page).to have_content("Newsletter has been sent") expect(last_email.subject).to include("A fancy newsletter for") @@ -141,7 +141,7 @@ it "allows a newsletter to be updated" do visit decidim_admin.newsletters_path within("tr[data-newsletter-id=\"#{newsletter.id}\"]") do - click_link "Edit" + click_on "Edit" end within ".edit_newsletter" do @@ -341,7 +341,7 @@ def select_all visit decidim_admin.newsletters_path within("tr[data-newsletter-id=\"#{newsletter.id}\"]") do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_content("successfully") diff --git a/decidim-admin/spec/system/admin_manages_officializations_spec.rb b/decidim-admin/spec/system/admin_manages_officializations_spec.rb index 1b2595f0cae1..1d1d405c3a60 100644 --- a/decidim-admin/spec/system/admin_manages_officializations_spec.rb +++ b/decidim-admin/spec/system/admin_manages_officializations_spec.rb @@ -16,7 +16,7 @@ switch_to_host(organization.host) login_as admin, scope: :user visit decidim_admin.root_path - click_link "Participants" + click_on "Participants" end describe "listing officializations" do @@ -31,7 +31,7 @@ before do within_admin_sidebar_menu do - click_link "Participants" + click_on "Participants" end end @@ -53,7 +53,7 @@ before do within_admin_sidebar_menu do - click_link "Participants" + click_on "Participants" end end @@ -72,16 +72,16 @@ before do within_admin_sidebar_menu do - click_link "Participants" + click_on "Participants" end within "tr[data-user-id=\"#{user.id}\"]" do - click_link "Officialize" + click_on "Officialize" end end it "officializes it with the standard badge" do - click_button "Officialize" + click_on "Officialize" expect(page).to have_content("successfully officialized") @@ -98,7 +98,7 @@ es: "Alcaldesa de Barcelona" ) - click_button "Officialize" + click_on "Officialize" expect(page).to have_content("successfully officialized") @@ -120,11 +120,11 @@ before do within_admin_sidebar_menu do - click_link "Participants" + click_on "Participants" end within "tr[data-user-id=\"#{user.id}\"]" do - click_link "Reofficialize" + click_on "Reofficialize" end end @@ -136,7 +136,7 @@ "#officialization-officialized_as-tabs", en: "Major of Barcelona" ) - click_button "Officialize" + click_on "Officialize" expect(page).to have_content("successfully officialized") @@ -152,11 +152,11 @@ before do within_admin_sidebar_menu do - click_link "Participants" + click_on "Participants" end within "tr[data-user-id=\"#{user.id}\"]" do - click_link "Unofficialize" + click_on "Unofficialize" end end @@ -174,13 +174,13 @@ before do within_admin_sidebar_menu do - click_link "Participants" + click_on "Participants" end end it "redirect to conversation path" do within "tr[data-user-id=\"#{user.id}\"]" do - click_link "Contact" + click_on "Contact" end expect(page).to have_current_path decidim.new_conversation_path(recipient_id: user.id) end @@ -191,13 +191,13 @@ before do within_admin_sidebar_menu do - click_link "Participants" + click_on "Participants" end end it "redirect to user profile page" do within "tr[data-user-id=\"#{user.id}\"]" do - click_link user.name + click_on user.name end within "div.profile__details" do @@ -211,13 +211,13 @@ before do within_admin_sidebar_menu do - click_link "Participants" + click_on "Participants" end end it "redirect to user profile page" do within "tr[data-user-id=\"#{user.id}\"]" do - click_link user.nickname + click_on user.nickname end within "div.profile__details" do @@ -231,21 +231,21 @@ before do within_admin_sidebar_menu do - click_link "Participants" + click_on "Participants" end end it "shows the users emails to admin users and logs the action" do users.each do |user| within "tr[data-user-id=\"#{user.id}\"]" do - click_link "Show email" + click_on "Show email" end within "#show-email-modal" do expect(page).to have_content("Show participant's email address") expect(page).to have_no_content(user.email) - click_button "Show" + click_on "Show" expect(page).to have_content(user.email) diff --git a/decidim-admin/spec/system/admin_manages_organization_admins_spec.rb b/decidim-admin/spec/system/admin_manages_organization_admins_spec.rb index 93b87317e8c3..6bfb121e7d36 100644 --- a/decidim-admin/spec/system/admin_manages_organization_admins_spec.rb +++ b/decidim-admin/spec/system/admin_manages_organization_admins_spec.rb @@ -14,14 +14,14 @@ before do login_as admin, scope: :user visit decidim_admin.root_path - click_link "Participants" + click_on "Participants" within_admin_sidebar_menu do - click_link "Admins" + click_on "Admins" end end it "can invite new users" do - click_link "New admin" + click_on "New admin" within ".new_user" do fill_in :user_name, with: "New admin" @@ -38,7 +38,7 @@ end it "can invite a user with a specific role" do - click_link "New admin" + click_on "New admin" within ".new_user" do fill_in :user_name, with: "New user manager" @@ -70,7 +70,7 @@ it "can resend the invitation" do within "tr[data-user-id=\"#{user.id}\"]" do - click_link "Resend invitation" + click_on "Resend invitation" end expect(page).to have_content("Invitation successfully resent") @@ -80,7 +80,7 @@ expect(page).to have_content(other_admin.name) within "tr[data-user-id=\"#{other_admin.id}\"]" do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_no_content(other_admin.name) diff --git a/decidim-admin/spec/system/admin_manages_organization_appearance_spec.rb b/decidim-admin/spec/system/admin_manages_organization_appearance_spec.rb index 515303153e00..66b2d1aa7329 100644 --- a/decidim-admin/spec/system/admin_manages_organization_appearance_spec.rb +++ b/decidim-admin/spec/system/admin_manages_organization_appearance_spec.rb @@ -73,7 +73,7 @@ end dynamically_attach_file(:organization_official_img_footer, Decidim::Dev.asset("city3.jpeg"), remove_before: true) - click_button "Update" + click_on "Update" expect(page).to have_content("updated successfully") diff --git a/decidim-admin/spec/system/admin_manages_organization_area_types_spec.rb b/decidim-admin/spec/system/admin_manages_organization_area_types_spec.rb index 0ba13d168942..710f0cf9b56e 100644 --- a/decidim-admin/spec/system/admin_manages_organization_area_types_spec.rb +++ b/decidim-admin/spec/system/admin_manages_organization_area_types_spec.rb @@ -10,9 +10,9 @@ switch_to_host(organization.host) login_as admin, scope: :user visit decidim_admin.root_path - click_link "Settings" - click_link "Areas" - click_link "Area types" + click_on "Settings" + click_on "Areas" + click_on "Area types" end it "can create new area types" do @@ -62,7 +62,7 @@ it "can edit them" do within "tr", text: translated(area_type.name) do - click_link "Edit" + click_on "Edit" end within ".edit_area_type" do @@ -89,7 +89,7 @@ it "can delete them" do within "tr", text: translated(area_type.name) do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") diff --git a/decidim-admin/spec/system/admin_manages_organization_areas_spec.rb b/decidim-admin/spec/system/admin_manages_organization_areas_spec.rb index 773079554b58..6ce0ea16ac26 100644 --- a/decidim-admin/spec/system/admin_manages_organization_areas_spec.rb +++ b/decidim-admin/spec/system/admin_manages_organization_areas_spec.rb @@ -16,12 +16,12 @@ before do login_as admin, scope: :user visit decidim_admin.root_path - click_link "Settings" - click_link "Areas" + click_on "Settings" + click_on "Areas" end it "can create new areas" do - click_link "Add" + click_on "Add" within ".item__edit-form" do fill_in_i18n :area_name, "#area-name-tabs", en: "My area", @@ -55,7 +55,7 @@ it "can edit them" do within "tr", text: translated(area.name) do - click_link "Edit" + click_on "Edit" end within ".item__edit-form" do @@ -98,7 +98,7 @@ def click_delete_area within "tr", text: translated(area.name) do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end end end diff --git a/decidim-admin/spec/system/admin_manages_organization_homepage_spec.rb b/decidim-admin/spec/system/admin_manages_organization_homepage_spec.rb index b552a8f7dee0..bd677cd6707b 100644 --- a/decidim-admin/spec/system/admin_manages_organization_homepage_spec.rb +++ b/decidim-admin/spec/system/admin_manages_organization_homepage_spec.rb @@ -18,7 +18,7 @@ expect(Decidim::ContentBlock.count).to eq 0 within ".edit_content_blocks" do - click_button "Add content block" + click_on "Add content block" within ".add-components" do find("a", text: "Hero image").click end @@ -39,7 +39,7 @@ with: "Custom welcome text!" ) - click_button "Update" + click_on "Update" visit decidim.root_path expect(page).to have_content("Custom welcome text!") end @@ -49,7 +49,7 @@ dynamically_attach_file(:content_block_images_background_image, Decidim::Dev.asset("city2.jpeg")) - click_button "Update" + click_on "Update" visit decidim.root_path expect(page.html).to include("city2.jpeg") end diff --git a/decidim-admin/spec/system/admin_manages_organization_scope_types_spec.rb b/decidim-admin/spec/system/admin_manages_organization_scope_types_spec.rb index 1a134fe6548e..fc0e16becef0 100644 --- a/decidim-admin/spec/system/admin_manages_organization_scope_types_spec.rb +++ b/decidim-admin/spec/system/admin_manages_organization_scope_types_spec.rb @@ -10,9 +10,9 @@ switch_to_host(organization.host) login_as admin, scope: :user visit decidim_admin.root_path - click_link "Settings" - click_link "Scopes" - click_link "Scope types" + click_on "Settings" + click_on "Scopes" + click_on "Scope types" end it "can create new scope types" do @@ -62,7 +62,7 @@ it "can edit them" do within "tr", text: translated(scope_type.name) do - click_link "Edit" + click_on "Edit" end within ".item__edit-form" do @@ -89,7 +89,7 @@ it "can delete them" do within "tr", text: translated(scope_type.name) do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") diff --git a/decidim-admin/spec/system/admin_manages_organization_scopes_spec.rb b/decidim-admin/spec/system/admin_manages_organization_scopes_spec.rb index a5cf4488f6ae..2ae76f8ed660 100644 --- a/decidim-admin/spec/system/admin_manages_organization_scopes_spec.rb +++ b/decidim-admin/spec/system/admin_manages_organization_scopes_spec.rb @@ -16,12 +16,12 @@ before do login_as admin, scope: :user visit decidim_admin.root_path - click_link "Settings" - click_link "Scopes" + click_on "Settings" + click_on "Scopes" end it "can create new scopes" do - click_link "Add" + click_on "Add" within ".new_scope" do fill_in_i18n :scope_name, "#scope-name-tabs", en: "My nice district", @@ -49,7 +49,7 @@ it "can edit them" do within "tr", text: translated(scope.name) do - click_link "Edit" + click_on "Edit" end within ".edit_scope" do @@ -68,7 +68,7 @@ it "can delete them" do within "tr", text: translated(scope.name) do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") @@ -78,12 +78,12 @@ end end - it "can create a new subcope" do + it "can create a new subscope" do within "tr", text: translated(scope.name) do page.find("td:first-child a").click end - click_link "Add" + click_on "Add" within ".new_scope" do fill_in_i18n :scope_name, "#scope-name-tabs", en: "My nice subdistrict", diff --git a/decidim-admin/spec/system/admin_manages_organization_spec.rb b/decidim-admin/spec/system/admin_manages_organization_spec.rb index 7b409ac3bea3..27527e84a853 100644 --- a/decidim-admin/spec/system/admin_manages_organization_spec.rb +++ b/decidim-admin/spec/system/admin_manages_organization_spec.rb @@ -21,7 +21,7 @@ %w(X Facebook Instagram YouTube GitHub).each do |network| within "#organization_social_handlers" do - click_link network + click_on network end field_name = "organization_#{network.downcase}_handler" @@ -36,7 +36,7 @@ en: "

      Respect the privacy of others.

      ", es: "

      Spanish - Respect the privacy of others.

      " - click_button "Update" + click_on "Update" expect(page).to have_content("updated successfully") end @@ -258,7 +258,7 @@ it "is still editable" do find('div[contenteditable="true"].ProseMirror').native.send_keys(Array.new(15) { :backspace }, "bar baz") - click_button "Update" + click_on "Update" expect(page).to have_content("Organization updated successfully") expect(find( "#organization-admin_terms_of_service_body-tabs-admin_terms_of_service_body-panel-0 .editor .ProseMirror" @@ -510,7 +510,7 @@ find("button[data-action='save']").click end - click_button "Update" + click_on "Update" organization.reload expect(translated(organization.admin_terms_of_service_body)).to eq( @@ -527,7 +527,7 @@ visit decidim_admin.edit_organization_path check "Send welcome notification" expect(page).to have_no_content("Welcome notification subject") - click_button "Update" + click_on "Update" expect(page).to have_content("updated successfully") organization.reload @@ -548,7 +548,7 @@ fill_in_i18n_editor :organization_welcome_notification_body, "#organization-welcome_notification_body-tabs", en: "

      Body

      " - click_button "Update" + click_on "Update" expect(page).to have_content("updated successfully") organization.reload @@ -565,13 +565,13 @@ fill_in_i18n :organization_welcome_notification_subject, "#organization-welcome_notification_subject-tabs", en: "" - click_button "Update" + click_on "Update" expect(page).to have_content("There was a problem updating this organization.") fill_in_i18n :organization_welcome_notification_subject, "#organization-welcome_notification_subject-tabs", en: "Well hello!" - click_button "Update" + click_on "Update" expect(page).to have_content("updated successfully") organization.reload diff --git a/decidim-admin/spec/system/admin_manages_static_page_content_blocks_spec.rb b/decidim-admin/spec/system/admin_manages_static_page_content_blocks_spec.rb index 4e141b22fce1..a116fb918706 100644 --- a/decidim-admin/spec/system/admin_manages_static_page_content_blocks_spec.rb +++ b/decidim-admin/spec/system/admin_manages_static_page_content_blocks_spec.rb @@ -19,7 +19,7 @@ expect(Decidim::ContentBlock.count).to eq 0 within ".edit_content_blocks" do - click_button "Add content block" + click_on "Add content block" within ".add-components" do find("a", text: "Summary").click end @@ -37,7 +37,7 @@ expect do number_of_content_blocks.times do within ".edit_content_blocks" do - click_button "Add content block" + click_on "Add content block" within ".add-components" do find("a", text: "Section").click end @@ -90,7 +90,7 @@ "#content_block-settings--summary-tabs", en: "

      Custom privacy policy summary text!

      " - click_button "Update" + click_on "Update" visit decidim.page_path(tos_page) expect(page).to have_content("Custom privacy policy summary text!") diff --git a/decidim-admin/spec/system/admin_manages_user_groups_spec.rb b/decidim-admin/spec/system/admin_manages_user_groups_spec.rb index 52e17b01b595..44d51fdc54bf 100644 --- a/decidim-admin/spec/system/admin_manages_user_groups_spec.rb +++ b/decidim-admin/spec/system/admin_manages_user_groups_spec.rb @@ -15,15 +15,15 @@ switch_to_host(organization.host) login_as user, scope: :user visit decidim_admin.root_path - click_link "Participants" + click_on "Participants" within_admin_sidebar_menu do - click_link "Groups" + click_on "Groups" end end it "verifies a user group" do within "tr[data-user-group-id=\"#{user_group.id}\"]" do - click_link "Verify" + click_on "Verify" end expect(page).to have_content("successfully verified") @@ -35,7 +35,7 @@ it "reject a user group" do within "tr[data-user-group-id=\"#{user_group.id}\"]" do - click_link "Reject" + click_on "Reject" end expect(page).to have_content("successfully rejected") diff --git a/decidim-admin/spec/system/admin_moderates_user_spec.rb b/decidim-admin/spec/system/admin_moderates_user_spec.rb index 7297e4eceb49..7665e5fa9107 100644 --- a/decidim-admin/spec/system/admin_moderates_user_spec.rb +++ b/decidim-admin/spec/system/admin_moderates_user_spec.rb @@ -19,7 +19,7 @@ expect(page).to have_css(".profile__actions-secondary") within ".profile__actions-secondary", match: :first do - click_button + click_on "Report" end expect(page).to have_css(".flag-modal", visible: :visible) @@ -28,7 +28,7 @@ find(:css, "input[name='report[block]']").set(true) expect(page).to have_field(name: "report[block]", visible: :visible) expect(page).to have_field(name: "report[hide]", visible: :visible) - click_button I18n.t("decidim.shared.flag_user_modal.block") + click_on I18n.t("decidim.shared.flag_user_modal.block") end expect(page).to have_current_path(decidim_admin.new_user_block_path(user_id: reportable.id), ignore_query: true) @@ -42,7 +42,7 @@ expect(page).to have_css(".profile__actions-secondary") within ".profile__actions-secondary", match: :first do - click_button + click_on "Report" end expect(page).to have_css(".flag-modal", visible: :visible) @@ -52,7 +52,7 @@ find(:css, "input[name='report[hide]']").set(true) expect(page).to have_field(name: "report[block]", visible: :visible) expect(page).to have_field(name: "report[hide]", visible: :visible) - click_button I18n.t("decidim.shared.flag_user_modal.block") + click_on I18n.t("decidim.shared.flag_user_modal.block") end expect(page).to have_current_path(decidim_admin.new_user_block_path(user_id: reportable.id), ignore_query: true) diff --git a/decidim-admin/spec/system/admin_passwords_spec.rb b/decidim-admin/spec/system/admin_passwords_spec.rb index aaab987cfc2c..899147ce707b 100644 --- a/decidim-admin/spec/system/admin_passwords_spec.rb +++ b/decidim-admin/spec/system/admin_passwords_spec.rb @@ -22,7 +22,7 @@ expect(page).to have_content("Admin users need to change their password every 90 days") expect(page).to have_content("Password change") fill_in :password_user_password, with: new_password - click_button "Change my password" + click_on "Change my password" expect(page).to have_css("[data-alert-box].success") expect(page).to have_content("Password successfully updated") expect(user.reload.password_updated_at).to be_between(2.seconds.ago, Time.current) @@ -32,7 +32,7 @@ manual_login(user.email, password) expect(page).to have_content("Password change") within "#admin-bar" do - click_link "Admin dashboard" + click_on "Admin dashboard" end expect(page).to have_content("You need to change your password in order to proceed further") expect(page).to have_content("Password change") @@ -48,7 +48,7 @@ manual_login(user.email, password) expect(page).to have_content("Password change") fill_in :password_user_password, with: new_password - click_button "Change my password" + click_on "Change my password" expect(page).to have_admin_callout("Password successfully updated") expect(page).to have_current_path(decidim_admin.root_path) @@ -81,9 +81,11 @@ end def manual_login(email, password) - click_link "Log in", match: :first - fill_in :session_user_email, with: email - fill_in :session_user_password, with: password - click_button "Log in" + click_on "Log in", match: :first + within ".new_user" do + fill_in :session_user_email, with: email + fill_in :session_user_password, with: password + click_on "Log in" + end end end diff --git a/decidim-admin/spec/system/admin_tos_acceptance_spec.rb b/decidim-admin/spec/system/admin_tos_acceptance_spec.rb index f7e2953db408..1d3bece6ee68 100644 --- a/decidim-admin/spec/system/admin_tos_acceptance_spec.rb +++ b/decidim-admin/spec/system/admin_tos_acceptance_spec.rb @@ -52,7 +52,7 @@ end it "allows accepting and redirects to the previous page" do - click_button "I agree with the terms" + click_on "I agree with the terms" expect(page).to have_content("New process") within_admin_menu do expect(page).to have_content("Process types") @@ -80,7 +80,7 @@ # ActionDispatch::Cookies::CookieOverflow exception visit "#{decidim_admin_participatory_processes.participatory_processes_path}?#{long_parameters}" expect(page).to have_content(review_message) - click_button "I agree with the terms" + click_on "I agree with the terms" expect(page).to have_content("New process") within_admin_menu do expect(page).to have_content("Process types") @@ -100,7 +100,7 @@ end it "allows accepting the terms" do - click_button "I agree with the terms" + click_on "I agree with the terms" expect(page).to have_content("Activity") expect(page).to have_content("Metrics") diff --git a/decidim-admin/spec/system/admin_verifies_user_groups_via_csv_spec.rb b/decidim-admin/spec/system/admin_verifies_user_groups_via_csv_spec.rb index 211149d5042c..c22d9d0db08b 100644 --- a/decidim-admin/spec/system/admin_verifies_user_groups_via_csv_spec.rb +++ b/decidim-admin/spec/system/admin_verifies_user_groups_via_csv_spec.rb @@ -21,11 +21,11 @@ switch_to_host(organization.host) login_as user, scope: :user visit decidim_admin.root_path - click_link "Participants" + click_on "Participants" within_admin_sidebar_menu do - click_link "Groups" + click_on "Groups" end - click_link "Verify via CSV" + click_on "Verify via CSV" end it "verifies a batch of user groups" do @@ -35,7 +35,7 @@ expect(Decidim::Admin::VerifyUserGroupFromCsvJob).to receive(:perform_later).once.ordered.with("Email", user, organization) expect(Decidim::Admin::VerifyUserGroupFromCsvJob).to receive(:perform_later).once.ordered.with(user_group.email, user, organization) dynamically_attach_file(:user_group_csv_verification_file, Decidim::Dev.asset("verify_user_groups.csv")) - perform_enqueued_jobs { click_button "Upload" } + perform_enqueued_jobs { click_on "Upload" } expect(page).to have_content("CSV file uploaded successfully") end diff --git a/decidim-admin/spec/system/autocomplete/multiselect_spec.rb b/decidim-admin/spec/system/autocomplete/multiselect_spec.rb index bc016362f5ec..d2b1a3e2247e 100644 --- a/decidim-admin/spec/system/autocomplete/multiselect_spec.rb +++ b/decidim-admin/spec/system/autocomplete/multiselect_spec.rb @@ -61,7 +61,7 @@ + Required field #{body_extra}
      diff --git a/decidim-admin/spec/system/participatory_space_private_user_import_via_csv_spec.rb b/decidim-admin/spec/system/participatory_space_private_user_import_via_csv_spec.rb index c6da97a5c50b..86a30fefcce5 100644 --- a/decidim-admin/spec/system/participatory_space_private_user_import_via_csv_spec.rb +++ b/decidim-admin/spec/system/participatory_space_private_user_import_via_csv_spec.rb @@ -13,9 +13,9 @@ login_as user, scope: :user visit decidim_admin_assemblies.edit_assembly_path(assembly) within_admin_sidebar_menu do - click_link "Private users" + click_on "Private users" end - click_link "Import via CSV" + click_on "Import via CSV" end it "show the form to add some private users via csv" do @@ -43,7 +43,7 @@ expect(page).to have_content("Are you sure you want to delete all private participants?") - click_button("OK") + click_on("OK") expect(page).to have_content("You have no private participants") end diff --git a/decidim-admin/spec/system/participatory_space_private_user_spec.rb b/decidim-admin/spec/system/participatory_space_private_user_spec.rb index fc8b7b13a539..1120afa467a7 100644 --- a/decidim-admin/spec/system/participatory_space_private_user_spec.rb +++ b/decidim-admin/spec/system/participatory_space_private_user_spec.rb @@ -17,7 +17,7 @@ login_as user, scope: :user visit decidim_admin_assemblies.edit_assembly_path(assembly) within_admin_sidebar_menu do - click_link "Private users" + click_on "Private users" end end diff --git a/decidim-admin/spec/system/static_pages_spec.rb b/decidim-admin/spec/system/static_pages_spec.rb index 7ea977e0444c..45dd865e7a51 100644 --- a/decidim-admin/spec/system/static_pages_spec.rb +++ b/decidim-admin/spec/system/static_pages_spec.rb @@ -38,7 +38,7 @@ page_title = decidim_page.title[I18n.locale.to_s] within(".page__accordion", text: topic_title) do - click_button + find("button[role=button]").click expect(page).to have_css( "a[href=\"#{decidim.page_path(decidim_page)}\"]", @@ -54,12 +54,12 @@ before do login_as admin, scope: :user visit decidim_admin.root_path - click_link "Pages" - click_link "Topics" + click_on "Pages" + click_on "Topics" end it "can create topics" do - click_link "Create topic" + click_on "Create topic" within ".new_static_page_topic" do fill_in_i18n( @@ -92,12 +92,12 @@ before do login_as admin, scope: :user visit decidim_admin.root_path - click_link "Pages" - click_link "Topics" + click_on "Pages" + click_on "Topics" end it "can create page groups" do - click_link translated(topic.title) + click_on translated(topic.title) within ".edit_static_page_topic" do fill_in_i18n( @@ -130,13 +130,13 @@ before do login_as admin, scope: :user visit decidim_admin.root_path - click_link "Pages" - click_link "Topics" + click_on "Pages" + click_on "Topics" end it "can delete them" do within "tr", text: translated(topic.title) do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") @@ -152,19 +152,19 @@ before do login_as admin, scope: :user visit decidim_admin.root_path - click_link "Pages" + click_on "Pages" end context "when displaying the page form" do before do - click_link "Create page" + click_on "Create page" end it_behaves_like "having a rich text editor", "new_static_page", "full" end it "can create new pages" do - click_link "Create page" + click_on "Create page" within ".new_static_page" do fill_in :static_page_slug, with: "welcome" @@ -207,7 +207,7 @@ context "when displaying the page form" do before do within "tr", text: translated(decidim_page.title) do - click_link "Edit" + click_on "Edit" end end @@ -216,7 +216,7 @@ it "can edit them" do within "tr", text: translated(decidim_page.title) do - click_link "Edit" + click_on "Edit" end within ".edit_static_page" do @@ -243,7 +243,7 @@ it "can delete them" do within "tr", text: translated(decidim_page.title) do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") @@ -256,7 +256,7 @@ it "can visit them" do new_window = window_opened_by do within "tr", text: translated(decidim_page.title) do - click_link "View public page" + click_on "View public page" end end diff --git a/decidim-admin/spec/system/user_manager_manages_impersonations_spec.rb b/decidim-admin/spec/system/user_manager_manages_impersonations_spec.rb index f8f598d8e0b3..4457bced846b 100644 --- a/decidim-admin/spec/system/user_manager_manages_impersonations_spec.rb +++ b/decidim-admin/spec/system/user_manager_manages_impersonations_spec.rb @@ -7,7 +7,7 @@ def navigate_to_impersonations_page visit decidim_admin.root_path - click_link "Participants" + click_on "Participants" end it_behaves_like "manage impersonations examples" diff --git a/decidim-api/docs/usage.md b/decidim-api/docs/usage.md index 1a178569f5d1..4507d659668e 100644 --- a/decidim-api/docs/usage.md +++ b/decidim-api/docs/usage.md @@ -16,6 +16,8 @@ Typically (although some particular installations may change that) you will find The GraphQL format is a JSON formatted text that is specified in a query. Response is a JSON object as well. For details about specification check the official [GraphQL site](https://graphql.org/learn/). +Exercise caution when utilizing the output of this API, as it may include HTML that has not been escaped. Take particular care in handling this data, specially if you intend to render it on a webpage. + For instance, you can check the version of a Decidim installation by using `curl` in the terminal: ```bash diff --git a/decidim-api/lib/decidim/api/test/shared_examples/statistics_examples.rb b/decidim-api/lib/decidim/api/test/shared_examples/statistics_examples.rb index c5acb8dc166c..01802c600dbf 100644 --- a/decidim-api/lib/decidim/api/test/shared_examples/statistics_examples.rb +++ b/decidim-api/lib/decidim/api/test/shared_examples/statistics_examples.rb @@ -21,7 +21,7 @@ } end - it "executes sucessfully" do + it "executes successfully" do expect { response }.not_to raise_error end diff --git a/decidim-assemblies/app/cells/decidim/assemblies/content_blocks/extra_data_cell.rb b/decidim-assemblies/app/cells/decidim/assemblies/content_blocks/extra_data_cell.rb index 857906d11ce7..26abccb8afa6 100644 --- a/decidim-assemblies/app/cells/decidim/assemblies/content_blocks/extra_data_cell.rb +++ b/decidim-assemblies/app/cells/decidim/assemblies/content_blocks/extra_data_cell.rb @@ -22,7 +22,7 @@ def type_item { title: t("assembly_type", scope: "decidim.assemblies.show"), icon: "group-2-line", - text: assembly_type + text: decidim_sanitize_translated(assembly_type) } end diff --git a/decidim-assemblies/app/controllers/decidim/assemblies/admin/assemblies_types_controller.rb b/decidim-assemblies/app/controllers/decidim/assemblies/admin/assemblies_types_controller.rb index 1ab7f0f21a81..81da7438e709 100644 --- a/decidim-assemblies/app/controllers/decidim/assemblies/admin/assemblies_types_controller.rb +++ b/decidim-assemblies/app/controllers/decidim/assemblies/admin/assemblies_types_controller.rb @@ -5,7 +5,7 @@ module Assemblies module Admin # Controller used to manage the available assemblies types for the current # organization. - # As this substitues former i18n simple hash we need to keep these i18n keys for migrations + # As this substitutes former i18n simple hash we need to keep these i18n keys for migrations # and rollbacks. So let i18n-tasks know about: # i18n-tasks-use t('decidim.assemblies.assembly_types.government') # i18n-tasks-use t('decidim.assemblies.assembly_types.commission') diff --git a/decidim-assemblies/app/serializers/decidim/assemblies/assembly_serializer.rb b/decidim-assemblies/app/serializers/decidim/assemblies/assembly_serializer.rb index 7449a6c0c5d3..15d692506a84 100644 --- a/decidim-assemblies/app/serializers/decidim/assemblies/assembly_serializer.rb +++ b/decidim-assemblies/app/serializers/decidim/assemblies/assembly_serializer.rb @@ -33,7 +33,7 @@ def serialize local_area: assembly.local_area, target: assembly.target, decidim_scope_id: assembly.decidim_scope_id, - paticipatory_scope: assembly.participatory_scope, + paticipatory_scope: assembly.participatory_scope, # intentionally misspelled participatory_structure: assembly.participatory_structure, show_statistics: assembly.show_statistics, scopes_enabled: assembly.scopes_enabled, diff --git a/decidim-assemblies/config/locales/en.yml b/decidim-assemblies/config/locales/en.yml index ad160f20fb43..17b6d30dd062 100644 --- a/decidim-assemblies/config/locales/en.yml +++ b/decidim-assemblies/config/locales/en.yml @@ -311,7 +311,7 @@ en: form: existing_user: Existing participant explanation: 'Guidance for image:' - image_guide: Preferrably a portrait image that does not have any text. + image_guide: Preferably a portrait image that does not have any text. non_user: Non participant non_user_avatar_help: You should get the consent of the persons before publishing them as a member. select_a_position: Select a position diff --git a/decidim-assemblies/lib/decidim/api/assembly_type.rb b/decidim-assemblies/lib/decidim/api/assembly_type.rb index 18966664a80d..46fd805acf96 100644 --- a/decidim-assemblies/lib/decidim/api/assembly_type.rb +++ b/decidim-assemblies/lib/decidim/api/assembly_type.rb @@ -54,7 +54,7 @@ class AssemblyType < Decidim::Api::Types::BaseObject field :twitter_handler, String, "Twitter handler", null: true field :instagram_handler, String, "Instagram handler", null: true field :facebook_handler, String, "Facebook handler", null: true - field :youtube_handler, String, "Youtube handler", null: true + field :youtube_handler, String, "YouTube handler", null: true field :github_handler, String, "GitHub handler", null: true field :announcement, Decidim::Core::TranslatedFieldType, "Highlighted announcement for this assembly", null: true diff --git a/decidim-assemblies/lib/decidim/assemblies/test/factories.rb b/decidim-assemblies/lib/decidim/assemblies/test/factories.rb index 72b7b12d09b6..21f847f98624 100644 --- a/decidim-assemblies/lib/decidim/assemblies/test/factories.rb +++ b/decidim-assemblies/lib/decidim/assemblies/test/factories.rb @@ -9,7 +9,10 @@ end factory :assemblies_type, class: "Decidim::AssembliesType" do - title { generate_localized_title } + transient do + skip_injection { false } + end + title { generate_localized_title(:assemblies_type_title, skip_injection:) } organization end @@ -17,45 +20,45 @@ transient do skip_injection { false } end - title { generate_localized_title } + title { generate_localized_title(:assembly_title, skip_injection:) } slug { generate(:assembly_slug) } - subtitle { generate_localized_title } - short_description { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } - description { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } + subtitle { generate_localized_title(:assembly_subtitle, skip_injection:) } + short_description { generate_localized_description(:assembly_short_description, skip_injection:) } + description { generate_localized_description(:assembly_description, skip_injection:) } organization hero_image { Decidim::Dev.test_file("city.jpeg", "image/jpeg") } # Keep after organization banner_image { Decidim::Dev.test_file("city2.jpeg", "image/jpeg") } # Keep after organization published_at { Time.current } - meta_scope { Decidim::Faker::Localized.word } - developer_group { generate_localized_title } - local_area { generate_localized_title } - target { generate_localized_title } - participatory_scope { generate_localized_title } - participatory_structure { generate_localized_title } + meta_scope { generate_localized_word(:assembly_meta_scope, skip_injection:) } + developer_group { generate_localized_title(:assembly_developer_group, skip_injection:) } + local_area { generate_localized_title(:assembly_local_area, skip_injection:) } + target { generate_localized_title(:assembly_target, skip_injection:) } + participatory_scope { generate_localized_title(:assembly_participatory_scope, skip_injection:) } + participatory_structure { generate_localized_title(:assembly_participatory_structure, skip_injection:) } show_statistics { true } private_space { false } - purpose_of_action { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } - composition { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } + purpose_of_action { generate_localized_description(:assembly_purpose_of_action, skip_injection:) } + composition { generate_localized_description(:assembly_composition, skip_injection:) } creation_date { 1.month.ago } created_by { "others" } - created_by_other { Decidim::Faker::Localized.word } + created_by_other { generate_localized_word(:assembly_created_by_other, skip_injection:) } duration { 2.months.from_now.at_midnight } included_at { 1.month.ago } closing_date { 2.months.from_now.at_midnight } - closing_date_reason { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } - internal_organisation { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } + closing_date_reason { generate_localized_description(:assembly_closing_date_reason, skip_injection:) } + internal_organisation { generate_localized_description(:assembly_internal_organisation, skip_injection:) } is_transparent { true } - special_features { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } + special_features { generate_localized_description(:assembly_special_features, skip_injection:) } twitter_handler { "others" } facebook_handler { "others" } instagram_handler { "others" } youtube_handler { "others" } github_handler { "others" } weight { 1 } - announcement { generate_localized_title } + announcement { generate_localized_title(:assembly_announcement, skip_injection:) } trait :with_type do - assembly_type { create :assemblies_type, organization: } + assembly_type { create :assemblies_type, organization:, skip_injection: } end trait :promoted do @@ -71,7 +74,7 @@ end trait :with_parent do - parent { create :assembly, organization: } + parent { create :assembly, organization:, skip_injection: } end trait :public do @@ -100,6 +103,7 @@ organization: assembly.organization, scope_name: :assembly_homepage, manifest_name:, + skip_injection: evaluator.skip_injection, scoped_resource_id: assembly.id ) end @@ -108,13 +112,17 @@ end factory :assembly_user_role, class: "Decidim::AssemblyUserRole" do + transient do + skip_injection { false } + end user - assembly { create :assembly, organization: user.organization } + assembly { create :assembly, organization: user.organization, skip_injection: } role { "admin" } end factory :assembly_admin, parent: :user, class: "Decidim::User" do transient do + skip_injection { false } assembly { create(:assembly) } end @@ -125,12 +133,14 @@ create :assembly_user_role, user:, assembly: evaluator.assembly, + skip_injection: evaluator.skip_injection, role: :admin end end factory :assembly_moderator, parent: :user, class: "Decidim::User" do transient do + skip_injection { false } assembly { create(:assembly) } end @@ -141,12 +151,14 @@ create :assembly_user_role, user:, assembly: evaluator.assembly, - role: :moderator + role: :moderator, + skip_injection: evaluator.skip_injection end end factory :assembly_collaborator, parent: :user, class: "Decidim::User" do transient do + skip_injection { false } assembly { create(:assembly) } end @@ -157,12 +169,14 @@ create :assembly_user_role, user:, assembly: evaluator.assembly, - role: :collaborator + role: :collaborator, + skip_injection: evaluator.skip_injection end end factory :assembly_valuator, parent: :user, class: "Decidim::User" do transient do + skip_injection { false } assembly { create(:assembly) } end @@ -173,12 +187,16 @@ create :assembly_user_role, user:, assembly: evaluator.assembly, - role: :valuator + role: :valuator, + skip_injection: evaluator.skip_injection end end factory :assembly_member, class: "Decidim::AssemblyMember" do - assembly { create(:assembly) } + transient do + skip_injection { false } + end + assembly { create(:assembly, skip_injection:) } full_name { Faker::Name.name } gender { Faker::Lorem.word } @@ -192,7 +210,7 @@ end trait :with_user do - user { create(:user, organization: assembly.organization) } + user { create(:user, organization: assembly.organization, skip_injection:) } end end end diff --git a/decidim-assemblies/spec/cells/decidim/assemblies/content_blocks/main_data_cell_spec.rb b/decidim-assemblies/spec/cells/decidim/assemblies/content_blocks/main_data_cell_spec.rb index b1599ac006da..9272360aaaa7 100644 --- a/decidim-assemblies/spec/cells/decidim/assemblies/content_blocks/main_data_cell_spec.rb +++ b/decidim-assemblies/spec/cells/decidim/assemblies/content_blocks/main_data_cell_spec.rb @@ -69,7 +69,7 @@ it_behaves_like "without extra attribute" end - context "when the extra attribute is an empty WYSWYG editor textarea" do + context "when the extra attribute is an empty WYSIWYG editor textarea" do let(:purpose_of_action) { "

      " } it_behaves_like "without extra attribute" diff --git a/decidim-assemblies/spec/permissions/decidim/assemblies/permissions_spec.rb b/decidim-assemblies/spec/permissions/decidim/assemblies/permissions_spec.rb index 0bb6cc825d1c..e1af0dabc5be 100644 --- a/decidim-assemblies/spec/permissions/decidim/assemblies/permissions_spec.rb +++ b/decidim-assemblies/spec/permissions/decidim/assemblies/permissions_spec.rb @@ -558,7 +558,7 @@ it { is_expected.to be(true) } end - context "when the assembly has one sucessor" do + context "when the assembly has one successor" do before do create(:assembly_user_role, user:, assembly: assembly.parent) end diff --git a/decidim-assemblies/spec/requests/assembly_search_spec.rb b/decidim-assemblies/spec/requests/assembly_search_spec.rb index 0d1b78fac0c3..c9b2c5a7fb45 100644 --- a/decidim-assemblies/spec/requests/assembly_search_spec.rb +++ b/decidim-assemblies/spec/requests/assembly_search_spec.rb @@ -37,16 +37,16 @@ end it "displays all assemblies by default" do - expect(subject).to include(translated(assembly1.title)) - expect(subject).to include(translated(assembly2.title)) + expect(subject).to include(decidim_escape_translated(assembly1.title)) + expect(subject).to include(decidim_escape_translated(assembly2.title)) end context "when filtering by assembly type" do let(:filter_params) { { with_any_type: [assembly1.assembly_type.id] } } it "displays matching assemblies" do - expect(subject).to include(translated(assembly1.title)) - expect(subject).not_to include(translated(assembly2.title)) + expect(subject).to include(decidim_escape_translated(assembly1.title)) + expect(subject).not_to include(decidim_escape_translated(assembly2.title)) end end @@ -54,8 +54,8 @@ let(:filter_params) { { with_any_area: [assembly1.area.id] } } it "displays matching assemblies" do - expect(subject).to include(translated(assembly1.title)) - expect(subject).not_to include(translated(assembly2.title)) + expect(subject).to include(decidim_escape_translated(assembly1.title)) + expect(subject).not_to include(decidim_escape_translated(assembly2.title)) end end @@ -63,8 +63,8 @@ let(:filter_params) { { with_any_scope: [assembly1.scope.id] } } it "displays matching assemblies" do - expect(subject).to include(translated(assembly1.title)) - expect(subject).not_to include(translated(assembly2.title)) + expect(subject).to include(decidim_escape_translated(assembly1.title)) + expect(subject).not_to include(decidim_escape_translated(assembly2.title)) end end end diff --git a/decidim-assemblies/spec/serializers/decidim/assemblies/assembly_serializer_spec.rb b/decidim-assemblies/spec/serializers/decidim/assemblies/assembly_serializer_spec.rb index 9a585fb084cc..cd11397937c4 100644 --- a/decidim-assemblies/spec/serializers/decidim/assemblies/assembly_serializer_spec.rb +++ b/decidim-assemblies/spec/serializers/decidim/assemblies/assembly_serializer_spec.rb @@ -31,7 +31,7 @@ module Decidim::Assemblies expect(serialized).to include(local_area: resource.local_area) expect(serialized).to include(target: resource.target) expect(serialized).to include(decidim_scope_id: resource.decidim_scope_id) - expect(serialized).to include(paticipatory_scope: resource.participatory_scope) + expect(serialized).to include(participatory_scope: resource.participatory_scope) expect(serialized).to include(participatory_structure: resource.participatory_structure) expect(serialized).to include(show_statistics: resource.show_statistics) expect(serialized).to include(scopes_enabled: resource.scopes_enabled) diff --git a/decidim-assemblies/spec/shared/assembly_admin_manage_assembly_components_examples.rb b/decidim-assemblies/spec/shared/assembly_admin_manage_assembly_components_examples.rb index 3bbe7653ebca..92d828f4208f 100644 --- a/decidim-assemblies/spec/shared/assembly_admin_manage_assembly_components_examples.rb +++ b/decidim-assemblies/spec/shared/assembly_admin_manage_assembly_components_examples.rb @@ -43,7 +43,7 @@ all("input[type=checkbox]").first.click end - click_button "Add component" + click_on "Add component" end end @@ -55,7 +55,7 @@ context "and then edit it" do before do within "tr", text: "My component" do - click_link "Configure" + click_on "Configure" end end @@ -70,7 +70,7 @@ end it "successfully edits it" do - click_button "Update" + click_on "Update" expect(page).to have_admin_callout("successfully") end @@ -96,7 +96,7 @@ it "updates the component" do within ".component-#{component.id}" do - click_link "Configure" + click_on "Configure" end within ".edit_component" do @@ -116,14 +116,14 @@ all("input[type=checkbox]").first.click end - click_button "Update" + click_on "Update" end expect(page).to have_admin_callout("successfully") expect(page).to have_content("My updated component") within "tr", text: "My updated component" do - click_link "Configure" + click_on "Configure" end within ".global-settings" do @@ -155,7 +155,7 @@ it "removes the component" do within ".component-#{component.id}" do - click_link "Delete" + click_on "Delete" end expect(page).to have_no_content("My component") @@ -176,7 +176,7 @@ context "when the component is unpublished" do it "publishes the component" do within ".component-#{component.id}" do - click_link "Publish" + click_on "Publish" end within ".component-#{component.id}" do @@ -189,7 +189,7 @@ create(:follow, followable: assembly, user: follower) within ".component-#{component.id}" do - click_link "Publish" + click_on "Publish" end expect(enqueued_jobs.last[:args]).to include("decidim.events.components.component_published") @@ -201,7 +201,7 @@ it "unpublishes the component" do within ".component-#{component.id}" do - click_link "Unpublish" + click_on "Unpublish" end within ".component-#{component.id}" do diff --git a/decidim-assemblies/spec/shared/copy_assemblies_examples.rb b/decidim-assemblies/spec/shared/copy_assemblies_examples.rb index 55692adaa264..7afb36cd9181 100644 --- a/decidim-assemblies/spec/shared/copy_assemblies_examples.rb +++ b/decidim-assemblies/spec/shared/copy_assemblies_examples.rb @@ -18,7 +18,7 @@ context "without any context" do it "copies the assembly with the basic fields" do - click_link "Duplicate", match: :first + click_on "Duplicate", match: :first within ".copy_assembly" do fill_in_i18n( @@ -29,7 +29,7 @@ ca: "Còpia del procés participatiu" ) fill_in :assembly_slug, with: "pp-copy" - click_button "Copy" + click_on "Copy" end expect(page).to have_content("successfully") @@ -40,7 +40,7 @@ context "with context" do before do - click_link "Duplicate", match: :first + click_on "Duplicate", match: :first within ".copy_assembly" do fill_in_i18n( @@ -56,15 +56,15 @@ it "copies the assembly with categories" do page.check("assembly[copy_categories]") - click_button "Copy" + click_on "Copy" expect(page).to have_content("successfully") within "tr", text: "Copy assembly" do - click_link "Configure" + click_on "Configure" end within_admin_sidebar_menu do - click_link "Categories" + click_on "Categories" end within ".table-list" do @@ -76,15 +76,15 @@ it "copies the assembly with components" do page.check("assembly[copy_components]") - click_button "Copy" + click_on "Copy" expect(page).to have_content("successfully") within "tr", text: "Copy assembly" do - click_link "Configure" + click_on "Configure" end within_admin_sidebar_menu do - click_link "Components" + click_on "Components" end within ".table-list" do @@ -100,9 +100,9 @@ let!(:assembly) { create(:assembly, parent: assembly_parent, organization:) } it "copies the child assembly with the basic fields" do - click_link "Assemblies", match: :first + click_on "Assemblies", match: :first - click_link "Duplicate", match: :first + click_on "Duplicate", match: :first within ".copy_assembly" do fill_in_i18n( @@ -113,7 +113,7 @@ ca: "Còpia del procés participatiu" ) fill_in :assembly_slug, with: "pp-copy" - click_button "Copy" + click_on "Copy" end expect(page).to have_content("successfully") diff --git a/decidim-assemblies/spec/shared/manage_assemblies_examples.rb b/decidim-assemblies/spec/shared/manage_assemblies_examples.rb index e471ff6acde4..441dc635655d 100644 --- a/decidim-assemblies/spec/shared/manage_assemblies_examples.rb +++ b/decidim-assemblies/spec/shared/manage_assemblies_examples.rb @@ -8,7 +8,7 @@ let(:assembly_parent_id_options) { page.find_by_id("assembly_parent_id").find_all("option").map(&:value) } before do - click_link "Configure" + click_on "Configure" end it "updates an assembly" do @@ -52,15 +52,15 @@ describe "updating an assembly without images" do before do within "tr", text: translated(assembly.title) do - click_link "Configure" + click_on "Configure" end end it "update an assembly without images does not delete them" do within_admin_sidebar_menu do - click_link "About this assembly" + click_on "About this assembly" end - click_button "Update" + click_on "Update" expect(page).to have_admin_callout("successfully") @@ -76,7 +76,7 @@ it "allows the user to preview the unpublished assembly" do new_window = window_opened_by do within "tr", text: translated(assembly.title) do - click_link "Preview" + click_on "Preview" end end @@ -94,7 +94,7 @@ it "allows the user to preview the unpublished assembly" do new_window = window_opened_by do within "tr", text: translated(assembly.title) do - click_link "Preview" + click_on "Preview" end end @@ -117,12 +117,12 @@ before do within "tr", text: translated(assembly.title) do - click_link "Configure" + click_on "Configure" end end it "publishes the assembly" do - click_link "Publish" + click_on "Publish" expect(page).to have_content("successfully published") expect(page).to have_content("Unpublish") expect(page).to have_current_path decidim_admin_assemblies.edit_assembly_path(assembly) @@ -137,12 +137,12 @@ before do within "tr", text: translated(assembly.title) do - click_link "Configure" + click_on "Configure" end end it "unpublishes the assembly" do - click_link "Unpublish" + click_on "Unpublish" expect(page).to have_content("successfully unpublished") expect(page).to have_content("Publish") expect(page).to have_current_path decidim_admin_assemblies.edit_assembly_path(assembly) @@ -170,7 +170,7 @@ end it "disables the scope for the assembly" do - click_link "Configure" + click_on "Configure" uncheck :assembly_scopes_enabled diff --git a/decidim-assemblies/spec/shared/manage_assembly_admins_examples.rb b/decidim-assemblies/spec/shared/manage_assembly_admins_examples.rb index 598fd22fc01d..d40fec0c7c91 100644 --- a/decidim-assemblies/spec/shared/manage_assembly_admins_examples.rb +++ b/decidim-assemblies/spec/shared/manage_assembly_admins_examples.rb @@ -15,7 +15,7 @@ login_as user, scope: :user visit decidim_admin_assemblies.edit_assembly_path(assembly) within_admin_sidebar_menu do - click_link "Assembly admins" + click_on "Assembly admins" end end @@ -26,7 +26,7 @@ end it "creates a new assembly admin" do - click_link "New assembly admin" + click_on "New assembly admin" within ".new_assembly_user_role" do fill_in :assembly_user_role_email, with: other_user.email @@ -52,7 +52,7 @@ it "updates an assembly admin" do within "#assembly_admins" do within "#assembly_admins tr", text: other_user.email do - click_link "Edit" + click_on "Edit" end end @@ -71,7 +71,7 @@ it "deletes an assembly_user_role" do within "#assembly_admins tr", text: other_user.email do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") @@ -99,7 +99,7 @@ it "resends the invitation to the user" do within "#assembly_admins tr", text: "test@example.org" do - click_link "Resend invitation" + click_on "Resend invitation" end expect(page).to have_admin_callout("successfully") diff --git a/decidim-assemblies/spec/shared/manage_assembly_categories_examples.rb b/decidim-assemblies/spec/shared/manage_assembly_categories_examples.rb index fc887f38f499..41b13fad054a 100644 --- a/decidim-assemblies/spec/shared/manage_assembly_categories_examples.rb +++ b/decidim-assemblies/spec/shared/manage_assembly_categories_examples.rb @@ -8,7 +8,7 @@ login_as user, scope: :user visit decidim_admin_assemblies.edit_assembly_path(assembly) within_admin_sidebar_menu do - click_link "Categories" + click_on "Categories" end end diff --git a/decidim-assemblies/spec/shared/manage_assembly_components_examples.rb b/decidim-assemblies/spec/shared/manage_assembly_components_examples.rb index b206269eb9a6..a219b10bde89 100644 --- a/decidim-assemblies/spec/shared/manage_assembly_components_examples.rb +++ b/decidim-assemblies/spec/shared/manage_assembly_components_examples.rb @@ -43,7 +43,7 @@ all("input[type=checkbox]").first.click end - click_button "Add component" + click_on "Add component" end end @@ -55,7 +55,7 @@ context "and then edit it" do before do within "tr", text: "My component" do - click_link "Configure" + click_on "Configure" end end @@ -70,7 +70,7 @@ end it "successfully edits it" do - click_button "Update" + click_on "Update" expect(page).to have_admin_callout("successfully") end @@ -96,7 +96,7 @@ it "updates the component" do within ".component-#{component.id}" do - click_link "Configure" + click_on "Configure" end within ".edit_component" do @@ -116,14 +116,14 @@ all("input[type=checkbox]").first.click end - click_button "Update" + click_on "Update" end expect(page).to have_admin_callout("successfully") expect(page).to have_content("My updated component") within "tr", text: "My updated component" do - click_link "Configure" + click_on "Configure" end within ".global-settings" do @@ -155,7 +155,7 @@ it "removes the component" do within ".component-#{component.id}" do - click_link "Delete" + click_on "Delete" end expect(page).to have_no_content("My component") @@ -176,7 +176,7 @@ context "when the component is unpublished" do it "publishes the component" do within ".component-#{component.id}" do - click_link "Publish" + click_on "Publish" end within ".component-#{component.id}" do @@ -189,7 +189,7 @@ create(:follow, followable: assembly, user: follower) within ".component-#{component.id}" do - click_link "Publish" + click_on "Publish" end expect(enqueued_jobs.last[:args]).to include("decidim.events.components.component_published") @@ -203,7 +203,7 @@ it "unpublishes the component" do within ".component-#{component.id}" do - click_link "Unpublish" + click_on "Unpublish" end within ".component-#{component.id}" do diff --git a/decidim-assemblies/spec/shared/manage_assembly_members_examples.rb b/decidim-assemblies/spec/shared/manage_assembly_members_examples.rb index 67c26f6d89a4..e94821a4c35c 100644 --- a/decidim-assemblies/spec/shared/manage_assembly_members_examples.rb +++ b/decidim-assemblies/spec/shared/manage_assembly_members_examples.rb @@ -6,7 +6,7 @@ login_as user, scope: :user visit decidim_admin_assemblies.edit_assembly_path(assembly) within_admin_sidebar_menu do - click_link "Members" + click_on "Members" end end @@ -14,7 +14,7 @@ let!(:assembly_member) { create(:assembly_member, assembly:) } it "creates a new assembly member" do - click_link "New assembly member" + click_on "New assembly member" fill_in_datepicker :assembly_member_designation_date_date, with: Time.current.strftime("%d/%m/%Y") @@ -48,7 +48,7 @@ let!(:member_user) { create(:user, organization: assembly.organization) } it "creates a new assembly member" do - click_link "New assembly member" + click_on "New assembly member" fill_in_datepicker :assembly_member_designation_date_date, with: Time.current.strftime("%d/%m/%Y") @@ -74,7 +74,7 @@ let!(:member_organization) { create(:user_group, :verified, organization: assembly.organization) } it "creates a new assembly member" do - click_link "New assembly member" + click_on "New assembly member" fill_in_datepicker :assembly_member_designation_date_date, with: Time.current.strftime("%d/%m/%Y") @@ -111,7 +111,7 @@ it "updates an assembly member" do within "#assembly_members tr", text: assembly_member.full_name do - click_link "Edit" + click_on "Edit" end within ".edit_assembly_member" do @@ -156,7 +156,7 @@ it "lists 15 members per page by default" do expect(page).to have_css(resource_selector, count: 15) expect(page).to have_css("[data-pages] [data-page]", count: 2) - click_link "Next" + click_on "Next" expect(page).to have_css("[data-pages] [data-page][aria-current='page']", text: "2") expect(page).to have_css(resource_selector, count: 5) end diff --git a/decidim-assemblies/spec/shared/manage_assembly_private_users_examples.rb b/decidim-assemblies/spec/shared/manage_assembly_private_users_examples.rb index 66f79b116508..aaa2750efca2 100644 --- a/decidim-assemblies/spec/shared/manage_assembly_private_users_examples.rb +++ b/decidim-assemblies/spec/shared/manage_assembly_private_users_examples.rb @@ -10,7 +10,7 @@ login_as user, scope: :user visit decidim_admin_assemblies.edit_assembly_path(assembly) within_admin_sidebar_menu do - click_link "Private users" + click_on "Private users" end end @@ -21,7 +21,7 @@ end it "creates a new assembly private users" do - click_link "New participatory space private user" + click_on "New participatory space private user" within ".new_participatory_space_private_user" do fill_in :participatory_space_private_user_name, with: "John Doe" @@ -39,13 +39,13 @@ describe "when import a batch of private users from csv" do it "import a batch of participatory space private users" do - click_link "Import via CSV" + click_on "Import via CSV" # The CSV has no headers expect(Decidim::Admin::ImportParticipatorySpacePrivateUserCsvJob).to receive(:perform_later).once.ordered.with("john.doe@example.org", "John Doe", assembly, user) expect(Decidim::Admin::ImportParticipatorySpacePrivateUserCsvJob).to receive(:perform_later).once.ordered.with("jane.doe@example.org", "Jane Doe", assembly, user) dynamically_attach_file(:participatory_space_private_user_csv_import_file, Decidim::Dev.asset("import_participatory_space_private_users.csv")) - perform_enqueued_jobs { click_button "Upload" } + perform_enqueued_jobs { click_on "Upload" } expect(page).to have_content("CSV file uploaded successfully") end @@ -59,7 +59,7 @@ it "deletes an assembly_private_user" do within "#private_users tr", text: other_user.email do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") @@ -87,7 +87,7 @@ it "resends the invitation to the user" do within "#private_users tr", text: "test@example.org" do - click_link "Resend invitation" + click_on "Resend invitation" end expect(page).to have_admin_callout("successfully") diff --git a/decidim-assemblies/spec/system/admin/admin_filters_assemblies_private_space_users_spec.rb b/decidim-assemblies/spec/system/admin/admin_filters_assemblies_private_space_users_spec.rb index 8bbbfb1dbd3d..a3deaba4a975 100644 --- a/decidim-assemblies/spec/system/admin/admin_filters_assemblies_private_space_users_spec.rb +++ b/decidim-assemblies/spec/system/admin/admin_filters_assemblies_private_space_users_spec.rb @@ -27,7 +27,7 @@ login_as user, scope: :user visit decidim_admin_assemblies.edit_assembly_path(assembly) within_admin_sidebar_menu do - click_link "Private users" + click_on "Private users" end end diff --git a/decidim-assemblies/spec/system/admin/admin_imports_assembly_spec.rb b/decidim-assemblies/spec/system/admin/admin_imports_assembly_spec.rb index d9ef55a594bb..8fb471115161 100644 --- a/decidim-assemblies/spec/system/admin/admin_imports_assembly_spec.rb +++ b/decidim-assemblies/spec/system/admin/admin_imports_assembly_spec.rb @@ -31,7 +31,7 @@ ) within_admin_menu do - click_link "Import" + click_on "Import" end within ".import_assembly" do @@ -46,7 +46,7 @@ end dynamically_attach_file(:assembly_document, Decidim::Dev.asset("assemblies.json")) - click_button "Import" + click_on "Import" end it "imports the json document" do @@ -55,11 +55,11 @@ expect(page).to have_content("Unpublished") within "tr", text: "Import assembly" do - click_link "Configure" + click_on "Configure" end within_admin_sidebar_menu do - click_link "Categories" + click_on "Categories" end within ".table-list" do expect(page).to have_content(translated("Veritatis provident nobis reprehenderit tenetur.")) @@ -67,7 +67,7 @@ end within_admin_sidebar_menu do - click_link "Components" + click_on "Components" end expect(Decidim::Assembly.last.components.size).to eq(9) within ".table-list" do @@ -77,7 +77,7 @@ end within_admin_sidebar_menu do - click_link "Attachments" + click_on "Attachments" end if Decidim::Assembly.last.attachments.any? within ".table-list" do diff --git a/decidim-assemblies/spec/system/admin/admin_manages_assemblies_spec.rb b/decidim-assemblies/spec/system/admin/admin_manages_assemblies_spec.rb index 12cd09ed73ae..5323a2afed1f 100644 --- a/decidim-assemblies/spec/system/admin/admin_manages_assemblies_spec.rb +++ b/decidim-assemblies/spec/system/admin/admin_manages_assemblies_spec.rb @@ -15,7 +15,7 @@ switch_to_host(organization.host) login_as user, scope: :user visit decidim_admin_assemblies.assemblies_path - click_link translated(my_space.title) + click_on translated(my_space.title) end context "when the participatory space is private" do @@ -47,7 +47,7 @@ let(:image2_path) { Decidim::Dev.asset(image2_filename) } before do - click_link "New assembly" + click_on "New assembly" end %w(purpose_of_action composition description short_description announcement internal_organisation).each do |field| @@ -169,7 +169,7 @@ def assembly_without_type(type) login_as user, scope: :user visit decidim_admin_assemblies.assemblies_path within "tr", text: translated(parent_assembly.title) do - click_link "Assemblies" + click_on "Assemblies" end end diff --git a/decidim-assemblies/spec/system/admin/admin_manages_assemblies_types_spec.rb b/decidim-assemblies/spec/system/admin/admin_manages_assemblies_types_spec.rb index 685d7ca1183a..e41d100a9e70 100644 --- a/decidim-assemblies/spec/system/admin/admin_manages_assemblies_types_spec.rb +++ b/decidim-assemblies/spec/system/admin/admin_manages_assemblies_types_spec.rb @@ -15,7 +15,7 @@ it "can create new assemblies types" do within "[data-content]" do - click_link "New assembly type" + click_on "New assembly type" within ".new_assembly_type" do fill_in_i18n( @@ -51,7 +51,7 @@ it "can edit them" do within "tr", text: translated(assembly_type.title) do - click_link "Edit" + click_on "Edit" end within ".edit_assembly_type" do @@ -84,7 +84,7 @@ def click_delete_assembly_type within "tr", text: translated(assembly_type.title) do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end end end diff --git a/decidim-assemblies/spec/system/admin/admin_manages_assemblies_with_parent_selector_spec.rb b/decidim-assemblies/spec/system/admin/admin_manages_assemblies_with_parent_selector_spec.rb index 3ace49211040..a4b3991bd822 100644 --- a/decidim-assemblies/spec/system/admin/admin_manages_assemblies_with_parent_selector_spec.rb +++ b/decidim-assemblies/spec/system/admin/admin_manages_assemblies_with_parent_selector_spec.rb @@ -18,7 +18,7 @@ context "when selecting a parent_assembly in the form" do before do - click_link "New assembly" + click_on "New assembly" end it "creates a new assembly" do @@ -80,9 +80,9 @@ before do within "tr", text: translated(assembly.title) do - click_link "Assemblies" + click_on "Assemblies" end - click_link "New assembly" + click_on "New assembly" end it "creates a new assembly" do diff --git a/decidim-assemblies/spec/system/admin/admin_manages_assembly_attachment_collections_spec.rb b/decidim-assemblies/spec/system/admin/admin_manages_assembly_attachment_collections_spec.rb index 9995e640fc6f..5513007590a7 100644 --- a/decidim-assemblies/spec/system/admin/admin_manages_assembly_attachment_collections_spec.rb +++ b/decidim-assemblies/spec/system/admin/admin_manages_assembly_attachment_collections_spec.rb @@ -12,9 +12,9 @@ login_as user, scope: :user visit decidim_admin_assemblies.edit_assembly_path(assembly) within_admin_sidebar_menu do - click_link "Attachments" + click_on "Attachments" end - click_link "Folders" + click_on "Folders" end it_behaves_like "manage attachment collections examples" diff --git a/decidim-assemblies/spec/system/admin/admin_manages_assembly_attachments_spec.rb b/decidim-assemblies/spec/system/admin/admin_manages_assembly_attachments_spec.rb index 6c69ecf4d5a1..50070178677b 100644 --- a/decidim-assemblies/spec/system/admin/admin_manages_assembly_attachments_spec.rb +++ b/decidim-assemblies/spec/system/admin/admin_manages_assembly_attachments_spec.rb @@ -13,7 +13,7 @@ login_as user, scope: :user visit decidim_admin_assemblies.edit_assembly_path(assembly) within_admin_sidebar_menu do - click_link "Attachments" + click_on "Attachments" end end diff --git a/decidim-assemblies/spec/system/admin/assembly_admin_accesses_admin_sections_spec.rb b/decidim-assemblies/spec/system/admin/assembly_admin_accesses_admin_sections_spec.rb index 86727c69e763..89de762cce98 100644 --- a/decidim-assemblies/spec/system/admin/assembly_admin_accesses_admin_sections_spec.rb +++ b/decidim-assemblies/spec/system/admin/assembly_admin_accesses_admin_sections_spec.rb @@ -39,7 +39,7 @@ context "when is a mother assembly" do before do visit decidim_admin_assemblies.assemblies_path - click_link "Configure" + click_on "Configure" end context "when is a public assembly" do @@ -59,10 +59,10 @@ before do visit decidim_admin_assemblies.assemblies_path within "tr", text: translated(assembly.title) do - click_link "Assemblies" + click_on "Assemblies" end - click_link "Configure" + click_on "Configure" end context "when is a public assembly" do diff --git a/decidim-assemblies/spec/system/admin/valuator_checks_components_spec.rb b/decidim-assemblies/spec/system/admin/valuator_checks_components_spec.rb index 2a9df8637d1c..738681678f53 100644 --- a/decidim-assemblies/spec/system/admin/valuator_checks_components_spec.rb +++ b/decidim-assemblies/spec/system/admin/valuator_checks_components_spec.rb @@ -33,7 +33,7 @@ context "when listing components in the space components page" do it "can only see the proposals component" do within_admin_sidebar_menu do - click_link "Components" + click_on "Components" end within ".card" do diff --git a/decidim-assemblies/spec/system/assemblies_spec.rb b/decidim-assemblies/spec/system/assemblies_spec.rb index 9d8eb0a1f4fa..5c05405fd588 100644 --- a/decidim-assemblies/spec/system/assemblies_spec.rb +++ b/decidim-assemblies/spec/system/assemblies_spec.rb @@ -112,7 +112,7 @@ visit decidim.root_path within "#home__menu" do - click_link "Assemblies" + click_on "Assemblies" end expect(page).to have_current_path decidim_assemblies.assemblies_path @@ -305,7 +305,7 @@ end end - it "shows the children assemblies by weigth" do + it "shows the children assemblies by weight" do expect(titles.first.text).to eq translated(child_assembly.title) expect(titles.last.text).to eq translated(second_child_assembly.title) end diff --git a/decidim-assemblies/spec/system/assembly_members_spec.rb b/decidim-assemblies/spec/system/assembly_members_spec.rb index ec6ec0ffc71d..4ebd9f3cbaa7 100644 --- a/decidim-assemblies/spec/system/assembly_members_spec.rb +++ b/decidim-assemblies/spec/system/assembly_members_spec.rb @@ -101,7 +101,7 @@ within ".participatory-space__nav-container" do expect(page).to have_content("Members") - click_link "Members" + click_on "Members" end expect(page).to have_current_path decidim_assemblies.assembly_assembly_members_path(assembly) diff --git a/decidim-assemblies/spec/types/integration_schema_spec.rb b/decidim-assemblies/spec/types/integration_schema_spec.rb index 38f11e41102e..d179ef8afd65 100644 --- a/decidim-assemblies/spec/types/integration_schema_spec.rb +++ b/decidim-assemblies/spec/types/integration_schema_spec.rb @@ -213,7 +213,7 @@ end describe "valid query" do - it "executes sucessfully" do + it "executes successfully" do expect { response }.not_to raise_error end @@ -367,7 +367,7 @@ ) end - it "executes sucessfully" do + it "executes successfully" do expect { response }.not_to raise_error end diff --git a/decidim-blogs/lib/decidim/blogs/test/factories.rb b/decidim-blogs/lib/decidim/blogs/test/factories.rb index 78d532a250bf..1554a88e4e51 100644 --- a/decidim-blogs/lib/decidim/blogs/test/factories.rb +++ b/decidim-blogs/lib/decidim/blogs/test/factories.rb @@ -7,21 +7,32 @@ FactoryBot.define do factory :post_component, parent: :component do - name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :blogs).i18n_name } + transient do + skip_injection { false } + end + + name { generate_component_name(participatory_space.organization.available_locales, :blogs, skip_injection:) } manifest_name { :blogs } - participatory_space { create(:participatory_process, :with_steps, organization:) } + participatory_space { create(:participatory_process, :with_steps, skip_injection:, organization:) } end factory :post, class: "Decidim::Blogs::Post" do - title { generate_localized_title } - body { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } - component { build(:component, manifest_name: "blogs") } - author { build(:user, :confirmed, organization: component.organization) } + transient do + skip_injection { false } + end + + title { generate_localized_title(:blog_title, skip_injection:) } + body { generate_localized_description(:blog_body, skip_injection:) } + component { build(:post_component, skip_injection:) } + author { build(:user, :confirmed, skip_injection:, organization: component.organization) } trait :with_endorsements do - after :create do |post| + after :create do |post, evaluator| 5.times.collect do - create(:endorsement, resource: post, author: build(:user, organization: post.participatory_space.organization)) + create(:endorsement, + resource: post, + skip_injection: evaluator.skip_injection, + author: build(:user, skip_injection: evaluator.skip_injection, organization: post.participatory_space.organization)) end end end diff --git a/decidim-blogs/spec/events/decidim/blogs/create_post_event_spec.rb b/decidim-blogs/spec/events/decidim/blogs/create_post_event_spec.rb index a9cea06792f6..4f4f9d40f03a 100644 --- a/decidim-blogs/spec/events/decidim/blogs/create_post_event_spec.rb +++ b/decidim-blogs/spec/events/decidim/blogs/create_post_event_spec.rb @@ -3,14 +3,15 @@ require "spec_helper" describe Decidim::Blogs::CreatePostEvent do + include_context "when a simple event" + let(:resource) { create(:post, title: generate_localized_title(:blog_title)) } let(:event_name) { "decidim.events.blogs.post_created" } let(:email_intro) { "The post \"#{resource_title}\" has been published in \"#{participatory_space_title}\" that you are following." } let(:email_outro) { "You have received this notification because you are following \"#{participatory_space_title}\". You can unfollow it from the previous link." } let(:notification_title) { "The post #{resource_title} has been published in #{participatory_space_title}" } - let(:email_subject) { "New post published in #{decidim_sanitize_translated(participatory_space.title)}" } + let(:email_subject) { "New post published in #{participatory_space_title}" } - include_context "when a simple event" it_behaves_like "a simple event" it_behaves_like "a simple event email" it_behaves_like "a simple event notification" diff --git a/decidim-blogs/spec/shared/manage_attachment_collections_examples.rb b/decidim-blogs/spec/shared/manage_attachment_collections_examples.rb index 4904a817c281..661374b4f719 100644 --- a/decidim-blogs/spec/shared/manage_attachment_collections_examples.rb +++ b/decidim-blogs/spec/shared/manage_attachment_collections_examples.rb @@ -5,7 +5,7 @@ before do within "tr", text: translated(post.title) do - click_link "Folders" + click_on "Folders" end end diff --git a/decidim-blogs/spec/shared/manage_attachments_examples.rb b/decidim-blogs/spec/shared/manage_attachments_examples.rb index d2e8b8af8286..701839c70d31 100644 --- a/decidim-blogs/spec/shared/manage_attachments_examples.rb +++ b/decidim-blogs/spec/shared/manage_attachments_examples.rb @@ -8,7 +8,7 @@ before do within "tr", text: translated(post.title) do - click_link "Attachments" + click_on "Attachments" end end diff --git a/decidim-blogs/spec/shared/manage_posts_examples.rb b/decidim-blogs/spec/shared/manage_posts_examples.rb index 4bfe29f2cd67..38c5afa6de59 100644 --- a/decidim-blogs/spec/shared/manage_posts_examples.rb +++ b/decidim-blogs/spec/shared/manage_posts_examples.rb @@ -4,14 +4,14 @@ it_behaves_like "having a rich text editor for field", ".tabs-content[data-tabs-content='post-body-tabs']", "full" do before do within "tr", text: translated(post1.title) do - click_link "Edit" + click_on "Edit" end end end it "updates a post" do within "tr", text: translated(post1.title) do - click_link "Edit" + click_on "Edit" end within ".edit_post" do @@ -45,7 +45,7 @@ end it "creates a new post" do - click_link "New post" + click_on "New post" fill_in_i18n( :post_title, @@ -83,7 +83,7 @@ it "deletes a post" do within "tr", text: translated(post1.title) do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") @@ -100,7 +100,7 @@ let!(:membership) { create(:user_group_membership, user:, user_group:) } it "can set user group as posts author" do - click_link "New post" + click_on "New post" select user_group.name, from: "post_decidim_author_id" @@ -136,7 +136,7 @@ it "can update the user group as the post author" do within "tr", text: translated(post1.title) do - click_link "Edit" + click_on "Edit" end within ".edit_post" do @@ -156,7 +156,7 @@ let(:author) { organization } it "can set organization as posts author" do - click_link "New post" + click_on "New post" select organization.name, from: "post_decidim_author_id" @@ -192,7 +192,7 @@ it "can update the blog as the organization" do within "tr", text: translated(post1.title) do - click_link "Edit" + click_on "Edit" end within ".edit_post" do @@ -212,7 +212,7 @@ let(:author) { user } it "can set current_user as posts author" do - click_link "New post" + click_on "New post" select user.name, from: "post_decidim_author_id" @@ -248,7 +248,7 @@ it "can update the blog as the user" do within "tr", text: translated(post1.title) do - click_link "Edit" + click_on "Edit" end within ".edit_post" do @@ -265,7 +265,7 @@ it "changes the publish time" do within "tr", text: translated(post1.title) do - click_link "Edit" + click_on "Edit" end within ".edit_post" do fill_in :post_published_at_date, with: nil, fill_options: { clear: :backspace } diff --git a/decidim-blogs/spec/system/endorse_posts_spec.rb b/decidim-blogs/spec/system/endorse_posts_spec.rb index 3842dd4bbd02..2f76f2596dce 100644 --- a/decidim-blogs/spec/system/endorse_posts_spec.rb +++ b/decidim-blogs/spec/system/endorse_posts_spec.rb @@ -16,8 +16,8 @@ context "when liking the post without belonging to a user group" do it "likes the post" do visit_component - click_link "Blog post title" - click_button "Like" + click_on "Blog post title" + click_on "Like" expect(page).to have_content("Dislike") end @@ -38,23 +38,23 @@ before do visit_component - click_link "Blog post title" + click_on "Blog post title" end it "opens a modal where you select identity as a user or a group" do - click_button "Like" + click_on "Like" expect(page).to have_content("Select identity") expect(page).to have_content("Tester's Organization") expect(page).to have_content("Tester") end def add_likes - click_button "Like" - click_button "Tester's Organization" - click_button "Tester" - click_button "Done" + click_on "Like" + click_on "Tester's Organization" + click_on "Tester" + click_on "Done" visit current_path - click_button "Dislike" + click_on "Dislike" end context "when both identities picked" do @@ -71,9 +71,9 @@ def add_likes it "does not cancel group like" do add_likes find(".is-selected", match: :first).click - click_button "Done" + click_on "Done" visit current_path - click_button "Like" + click_on "Like" within ".identities-modal__list" do expect(page).to have_css(".is-selected", count: 1) @@ -88,9 +88,9 @@ def add_likes it "does not cancel user like" do add_likes page.all(".is-selected")[1].click - click_button "Done" + click_on "Done" visit current_path - click_button "Dislike" + click_on "Dislike" within ".identities-modal__list" do expect(page).to have_css(".is-selected", count: 1) diff --git a/decidim-blogs/spec/types/integration_schema_spec.rb b/decidim-blogs/spec/types/integration_schema_spec.rb index dc6419d02f52..cfb058eee54f 100644 --- a/decidim-blogs/spec/types/integration_schema_spec.rb +++ b/decidim-blogs/spec/types/integration_schema_spec.rb @@ -50,7 +50,7 @@ { "__typename" => "Blogs", "id" => current_component.id.to_s, - "name" => { "translation" => "Blog" }, + "name" => { "translation" => translated(current_component.name) }, "posts" => { "edges" => [ { @@ -135,7 +135,7 @@ end context "when unfiltered" do - it "executes sucessfully" do + it "executes successfully" do expect { response }.not_to raise_error end @@ -306,7 +306,7 @@ ) end - it "executes sucessfully" do + it "executes successfully" do expect { response }.not_to raise_error end diff --git a/decidim-budgets/app/cells/decidim/budgets/base_cell.rb b/decidim-budgets/app/cells/decidim/budgets/base_cell.rb index d2ae7abbb452..904a3b857796 100644 --- a/decidim-budgets/app/cells/decidim/budgets/base_cell.rb +++ b/decidim-budgets/app/cells/decidim/budgets/base_cell.rb @@ -11,7 +11,7 @@ class BaseCell < Decidim::ViewModel delegate :settings, to: :current_component def budgets_link_list(budgets) - budgets.map { |budget| link_to(translated_attribute(budget.title), resource_locator(budget).path) } + budgets.map { |budget| link_to(decidim_escape_translated(budget.title), resource_locator(budget).path) } .to_sentence .html_safe end diff --git a/decidim-budgets/app/cells/decidim/budgets/budget_list_item/show.erb b/decidim-budgets/app/cells/decidim/budgets/budget_list_item/show.erb index b64484df52e3..a14799e28b0f 100644 --- a/decidim-budgets/app/cells/decidim/budgets/budget_list_item/show.erb +++ b/decidim-budgets/app/cells/decidim/budgets/budget_list_item/show.erb @@ -2,7 +2,7 @@
      <%= link_to resource_path, class: "p-4" do %>

      - <%= translated_attribute(title) %> + <%= decidim_escape_translated(title) %>

      <% if voted? %> <%= icon "check-double-line", class: "inline-block align-middle fill-success ml-2 h-[1.5em] w-[1.5em]" %> diff --git a/decidim-budgets/app/controllers/decidim/budgets/line_items_controller.rb b/decidim-budgets/app/controllers/decidim/budgets/line_items_controller.rb index 2b4e5b647aad..ea646e988d40 100644 --- a/decidim-budgets/app/controllers/decidim/budgets/line_items_controller.rb +++ b/decidim-budgets/app/controllers/decidim/budgets/line_items_controller.rb @@ -12,15 +12,21 @@ def create enforce_permission_to :vote, :project, project:, budget:, workflow: current_workflow respond_to do |format| - AddLineItem.call(persisted_current_order, project, current_user) do - on(:ok) do |order| - self.current_order = order - format.html { redirect_back(fallback_location: budget_path(budget)) } - format.js { render "update_budget" } - end - - on(:invalid) do - format.js { render "update_budget", status: :unprocessable_entity } + # Note that the user-specific lock here is important in order to + # prevent multiple simultaneous processes on different machines from + # creating multiple orders for the same user in case the button is + # pressed multiple times. + current_user.with_lock do + AddLineItem.call(persisted_current_order, project, current_user) do + on(:ok) do |order| + self.current_order = order + format.html { redirect_back(fallback_location: budget_path(budget)) } + format.js { render "update_budget" } + end + + on(:invalid) do + format.js { render "update_budget", status: :unprocessable_entity } + end end end end diff --git a/decidim-budgets/app/helpers/decidim/budgets/projects_helper.rb b/decidim-budgets/app/helpers/decidim/budgets/projects_helper.rb index 053f4cca0c28..93f0a3745a34 100644 --- a/decidim-budgets/app/helpers/decidim/budgets/projects_helper.rb +++ b/decidim-budgets/app/helpers/decidim/budgets/projects_helper.rb @@ -162,7 +162,7 @@ def reference_budgets_for_select references = Budget.joins(:component) .where(component: { participatory_space: current_participatory_space }).order(weight: :asc) references.map do |budget| - ["#{" " * 4} #{translated_attribute(budget.title)}".html_safe, budget.id] + ["#{" " * 4} #{decidim_escape_translated(budget.title)}".html_safe, budget.id] end end end diff --git a/decidim-budgets/app/views/decidim/budgets/admin/projects/edit.html.erb b/decidim-budgets/app/views/decidim/budgets/admin/projects/edit.html.erb index 0833be89bb57..70bf4c4dc4a3 100644 --- a/decidim-budgets/app/views/decidim/budgets/admin/projects/edit.html.erb +++ b/decidim-budgets/app/views/decidim/budgets/admin/projects/edit.html.erb @@ -1,7 +1,7 @@ <% add_decidim_page_title("#{translated_attribute(budget.title)} - #{t(".title")}") %>

      - <%= "#{translated_attribute(budget.title)} #{t(".title")}" %> + <%= "#{decidim_escape_translated(budget.title)} #{t(".title")}" %>

      diff --git a/decidim-budgets/app/views/decidim/budgets/admin/projects/index.html.erb b/decidim-budgets/app/views/decidim/budgets/admin/projects/index.html.erb index de256d244079..3e69d4e08c1c 100644 --- a/decidim-budgets/app/views/decidim/budgets/admin/projects/index.html.erb +++ b/decidim-budgets/app/views/decidim/budgets/admin/projects/index.html.erb @@ -3,7 +3,7 @@

      - <%= link_to translated_attribute(budget.title), budgets_path %> > + <%= link_to decidim_escape_translated(budget.title), budgets_path %> > <%= t(".title") %> ">
      diff --git a/decidim-budgets/app/views/decidim/budgets/admin/projects/new.html.erb b/decidim-budgets/app/views/decidim/budgets/admin/projects/new.html.erb index c95bc0d2806c..f90dd970ce24 100644 --- a/decidim-budgets/app/views/decidim/budgets/admin/projects/new.html.erb +++ b/decidim-budgets/app/views/decidim/budgets/admin/projects/new.html.erb @@ -1,7 +1,7 @@ <% add_decidim_page_title("#{translated_attribute(budget.title)} - #{t(".title")}") %>

      - <%= "#{translated_attribute(budget.title)} > #{t(".title")}".html_safe %> + <%= "#{decidim_escape_translated(budget.title)} > #{t(".title")}".html_safe %>

      diff --git a/decidim-budgets/app/views/decidim/budgets/projects/_budget_confirm.html.erb b/decidim-budgets/app/views/decidim/budgets/projects/_budget_confirm.html.erb index 29a3aa854913..5a3105e878f4 100644 --- a/decidim-budgets/app/views/decidim/budgets/projects/_budget_confirm.html.erb +++ b/decidim-budgets/app/views/decidim/budgets/projects/_budget_confirm.html.erb @@ -17,7 +17,7 @@

      - + <%= budget_to_currency project.budget_amount %>
      diff --git a/decidim-budgets/lib/decidim/budgets/test/factories.rb b/decidim-budgets/lib/decidim/budgets/test/factories.rb index 537463b12cb4..e40e0a5a67cd 100644 --- a/decidim-budgets/lib/decidim/budgets/test/factories.rb +++ b/decidim-budgets/lib/decidim/budgets/test/factories.rb @@ -9,9 +9,12 @@ FactoryBot.define do factory :budgets_component, parent: :component do - name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :budgets).i18n_name } + transient do + skip_injection { false } + end + name { generate_component_name(participatory_space.organization.available_locales, :budgets, skip_injection:) } manifest_name { :budgets } - participatory_space { create(:participatory_process, :with_steps, organization:) } + participatory_space { create(:participatory_process, :with_steps, skip_injection:, organization:) } trait :with_geocoding_enabled do settings do @@ -110,10 +113,13 @@ end factory :budget, class: "Decidim::Budgets::Budget" do - title { generate_localized_title } - description { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } + transient do + skip_injection { false } + end + title { generate_localized_title(:budget_title, skip_injection:) } + description { generate_localized_description(:budget_description, skip_injection:) } total_budget { 100_000_000 } - component { create(:budgets_component) } + component { create(:budgets_component, skip_injection:) } trait :with_projects do transient do @@ -121,19 +127,22 @@ end after(:create) do |budget, evaluator| - create_list(:project, evaluator.projects_number, budget:) + create_list(:project, evaluator.projects_number, skip_injection: evaluator.skip_injection, budget:) end end end factory :project, class: "Decidim::Budgets::Project" do - title { generate_localized_title } - description { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } + transient do + skip_injection { false } + end + title { generate_localized_title(:project_title, skip_injection:) } + description { generate_localized_description(:project_description, skip_injection:) } address { "#{Faker::Address.street_name}, #{Faker::Address.city}" } latitude { Faker::Address.latitude } longitude { Faker::Address.longitude } budget_amount { Faker::Number.number(digits: 8) } - budget { create(:budget) } + budget { create(:budget, skip_injection:) } trait :selected do selected_at { Time.current } @@ -145,14 +154,17 @@ end after :create do |project, evaluator| - project.attachments = create_list(:attachment, evaluator.photos_number, :with_image, attached_to: project) + project.attachments = create_list(:attachment, evaluator.photos_number, :with_image, attached_to: project, skip_injection: evaluator.skip_injection) end end end factory :order, class: "Decidim::Budgets::Order" do - budget { create(:budget) } - user { create(:user, organization: component.organization) } + transient do + skip_injection { false } + end + budget { create(:budget, skip_injection:) } + user { create(:user, organization: component.organization, skip_injection:) } trait :with_projects do transient do @@ -161,14 +173,17 @@ after(:create) do |order, evaluator| project_budget = (order.maximum_budget / evaluator.projects_number).to_i - order.projects << create_list(:project, evaluator.projects_number, budget_amount: project_budget, budget: order.budget) + order.projects << create_list(:project, evaluator.projects_number, budget_amount: project_budget, budget: order.budget, skip_injection: evaluator.skip_injection) order.save! end end end factory :line_item, class: "Decidim::Budgets::LineItem" do + transient do + skip_injection { false } + end order - project { create(:project, budget: order.budget) } + project { create(:project, budget: order.budget, skip_injection:) } end end diff --git a/decidim-budgets/spec/commands/decidim/budgets/admin/update_projects_budget_spec.rb b/decidim-budgets/spec/commands/decidim/budgets/admin/update_projects_budget_spec.rb index d5029815a12b..7923159e6f4b 100644 --- a/decidim-budgets/spec/commands/decidim/budgets/admin/update_projects_budget_spec.rb +++ b/decidim-budgets/spec/commands/decidim/budgets/admin/update_projects_budget_spec.rb @@ -43,7 +43,7 @@ module Decidim::Budgets end context "when everything is ok" do - it "broadcasts update with successfull flashes" do + it "broadcasts update with successful flashes" do successful = projects.map { |p| translated(p.title) } expect(budget.projects.count).to eq(4) expect(destination_budget.projects.count).to eq(0) diff --git a/decidim-budgets/spec/requests/line_items_spec.rb b/decidim-budgets/spec/requests/line_items_spec.rb new file mode 100644 index 000000000000..81baa872abb1 --- /dev/null +++ b/decidim-budgets/spec/requests/line_items_spec.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe "Project search" do + include Decidim::ComponentPathHelper + + let(:user) { create(:user, :confirmed) } + let(:participatory_space) { create :participatory_process, :with_steps, organization: user.organization } + let(:component) { create(:budgets_component, participatory_space:, settings:) } + let(:settings) { { vote_threshold_percent: 50 } } + let(:budget) { create(:budget, component:, total_budget: 100_000) } + let(:project) { create(:project, budget:, budget_amount: 60_000) } + + let(:headers) { { "HOST" => participatory_space.organization.host } } + + before do + login_as user, scope: :user + end + + describe "POST create" do + let(:request_path) { Decidim::EngineRouter.main_proxy(component).budget_order_line_item_path(budget) } + + it "creates the order" do + expect do + post(request_path, xhr: true, params: { project_id: project.id }, headers:) + end.to change(Decidim::Budgets::Order, :count).by(1) + + expect(response).to have_http_status(:ok) + end + + context "when trying to add the same project twice" do + it "adds it only once" do + post(request_path, xhr: true, params: { project_id: project.id }, headers:) + expect(response).to have_http_status(:ok) + + post(request_path, xhr: true, params: { project_id: project.id }, headers:) + expect(response).to have_http_status(:unprocessable_entity) + + expect(Decidim::Budgets::Order.count).to eq(1) + expect(Decidim::Budgets::LineItem.count).to eq(1) + end + end + + context "with concurrent requests" do + include_context "with concurrency" + + before do + # Persist the session cookie before the concurrent requests. + get(Decidim::Core::Engine.routes.url_helpers.root_path, headers:) + end + + it "only creates a single order" do + expect do + threads = 10.times.map do + Thread.new do + sleep(rand(0.05..0.5)) + + post(request_path, xhr: true, params: { project_id: project.id }, headers:) + end + end + # Wait for each thread to finish + threads.each(&:join) + end.not_to raise_error + + expect(Decidim::Budgets::Order.count).to eq(1) + end + end + end +end diff --git a/decidim-budgets/spec/requests/project_search_spec.rb b/decidim-budgets/spec/requests/project_search_spec.rb index b15be358b4bd..4c95e8613042 100644 --- a/decidim-budgets/spec/requests/project_search_spec.rb +++ b/decidim-budgets/spec/requests/project_search_spec.rb @@ -59,11 +59,11 @@ it_behaves_like "a resource search with categories", :project it "displays all projects within the budget without any filters" do - expect(subject).to include(translated(project1.title)) - expect(subject).to include(translated(project2.title)) - expect(subject).to include(translated(project3.title)) - expect(subject).not_to include(translated(project4.title)) - expect(subject).not_to include(translated(project5.title)) + expect(subject).to include(decidim_escape_translated(project1.title)) + expect(subject).to include(decidim_escape_translated(project2.title)) + expect(subject).to include(decidim_escape_translated(project3.title)) + expect(subject).not_to include(decidim_escape_translated(project4.title)) + expect(subject).not_to include(decidim_escape_translated(project5.title)) end context "when searching by status" do @@ -73,9 +73,9 @@ let(:status) { ["all"] } it "displays all projects" do - expect(subject).to include(translated(project1.title)) - expect(subject).to include(translated(project2.title)) - expect(subject).to include(translated(project3.title)) + expect(subject).to include(decidim_escape_translated(project1.title)) + expect(subject).to include(decidim_escape_translated(project2.title)) + expect(subject).to include(decidim_escape_translated(project3.title)) end end @@ -83,9 +83,9 @@ let(:status) { ["selected"] } it "displays the selected projects" do - expect(subject).to include(translated(project1.title)) - expect(subject).to include(translated(project2.title)) - expect(subject).not_to include(translated(project3.title)) + expect(subject).to include(decidim_escape_translated(project1.title)) + expect(subject).to include(decidim_escape_translated(project2.title)) + expect(subject).not_to include(decidim_escape_translated(project3.title)) end end @@ -93,9 +93,9 @@ let(:status) { ["not_selected"] } it "displays the selected projects" do - expect(subject).not_to include(translated(project1.title)) - expect(subject).not_to include(translated(project2.title)) - expect(subject).to include(translated(project3.title)) + expect(subject).not_to include(decidim_escape_translated(project1.title)) + expect(subject).not_to include(decidim_escape_translated(project2.title)) + expect(subject).to include(decidim_escape_translated(project3.title)) end end end diff --git a/decidim-budgets/spec/shared/export_projects_examples.rb b/decidim-budgets/spec/shared/export_projects_examples.rb index 3014359349a9..143746c7a1cf 100644 --- a/decidim-budgets/spec/shared/export_projects_examples.rb +++ b/decidim-budgets/spec/shared/export_projects_examples.rb @@ -23,7 +23,7 @@ shared_examples "export as CSV" do it "exports a CSV" do find("span.exports", text: export_type).click - perform_enqueued_jobs { click_link "Projects as CSV" } + perform_enqueued_jobs { click_on "Projects as CSV" } expect(page).to have_admin_callout "Your export is currently in progress. You will receive an email when it is complete." expect(last_email.subject).to include("projects", "csv") @@ -35,7 +35,7 @@ shared_examples "export as JSON" do it "exports a JSON" do find("span.exports", text: export_type).click - perform_enqueued_jobs { click_link "Projects as JSON" } + perform_enqueued_jobs { click_on "Projects as JSON" } expect(page).to have_admin_callout "Your export is currently in progress. You will receive an email when it is complete." expect(last_email.subject).to include("projects", "json") diff --git a/decidim-budgets/spec/shared/import_proposals_to_projects_examples.rb b/decidim-budgets/spec/shared/import_proposals_to_projects_examples.rb index 4a83fc44bfdb..39fd090dd45e 100644 --- a/decidim-budgets/spec/shared/import_proposals_to_projects_examples.rb +++ b/decidim-budgets/spec/shared/import_proposals_to_projects_examples.rb @@ -9,7 +9,7 @@ it "imports proposals from one component to a budget component" do page.find(".imports").click - click_link "Import proposals to projects" + click_on "Import proposals to projects" within ".import_proposals" do select origin_component.name["en"], from: :proposals_import_origin_component_id @@ -17,7 +17,7 @@ check :proposals_import_import_all_accepted_proposals end - click_button "Import proposals to projects" + click_on "Import proposals to projects" expect(page).to have_content("3 proposals successfully imported") diff --git a/decidim-budgets/spec/shared/manage_attachment_collections_examples.rb b/decidim-budgets/spec/shared/manage_attachment_collections_examples.rb index a49f9171f9a1..dc570bbdac89 100644 --- a/decidim-budgets/spec/shared/manage_attachment_collections_examples.rb +++ b/decidim-budgets/spec/shared/manage_attachment_collections_examples.rb @@ -5,11 +5,11 @@ before do within "tr", text: translated(budget.title) do - click_link "Manage projects" + click_on "Manage projects" end within "tr", text: translated(project.title) do - click_link "Folders" + click_on "Folders" end end diff --git a/decidim-budgets/spec/shared/manage_attachments_examples.rb b/decidim-budgets/spec/shared/manage_attachments_examples.rb index 87116be7bd19..2a1cd6fb8386 100644 --- a/decidim-budgets/spec/shared/manage_attachments_examples.rb +++ b/decidim-budgets/spec/shared/manage_attachments_examples.rb @@ -8,11 +8,11 @@ before do within "tr", text: translated(budget.title) do - click_link "Manage projects" + click_on "Manage projects" end within "tr", text: translated(project.title) do - click_link "Attachments" + click_on "Attachments" end end diff --git a/decidim-budgets/spec/shared/manage_projects_examples.rb b/decidim-budgets/spec/shared/manage_projects_examples.rb index 131035e7cc19..869de60dd243 100644 --- a/decidim-budgets/spec/shared/manage_projects_examples.rb +++ b/decidim-budgets/spec/shared/manage_projects_examples.rb @@ -4,7 +4,7 @@ describe "admin form" do before do within ".item_show__wrapper" do - click_link("New project", class: "button") + click_on("New project", class: "button") end end @@ -80,7 +80,7 @@ it "updates a project" do within "tr", text: translated(project.title) do - click_link "Edit" + click_on "Edit" end within ".edit_project" do @@ -141,7 +141,7 @@ it "creates a new project", :slow do within ".bulk-actions-budgets" do - click_link "New project" + click_on "New project" end within ".new_project" do @@ -183,7 +183,7 @@ it "deletes a project" do within "tr", text: translated(project2.title) do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") @@ -200,7 +200,7 @@ it "updates a project" do within "tr", text: translated(project.title) do - click_link "Edit" + click_on "Edit" end within ".edit_project" do @@ -230,7 +230,7 @@ expect(project.linked_resources(:proposals, "included_proposals").count).to eq(5) within "tr", text: translated(project.title) do - click_link "Edit" + click_on "Edit" end within ".edit_project" do @@ -246,7 +246,7 @@ it "creates a new project" do within ".bulk-actions-budgets" do - click_link "New project" + click_on "New project" end within ".new_project" do diff --git a/decidim-budgets/spec/system/admin_manages_budgets_spec.rb b/decidim-budgets/spec/system/admin_manages_budgets_spec.rb index 590f6a1df9da..5f6cd4d9f953 100644 --- a/decidim-budgets/spec/system/admin_manages_budgets_spec.rb +++ b/decidim-budgets/spec/system/admin_manages_budgets_spec.rb @@ -21,7 +21,7 @@ end it "creates a new budget" do - click_link "New budget" + click_on "New budget" within ".new_budget" do fill_in_i18n( @@ -43,7 +43,7 @@ select translated(scope.name), from: :budget_decidim_scope_id end - click_button "Create budget" + click_on "Create budget" expect(page).to have_admin_callout("Budget successfully created.") @@ -68,7 +68,7 @@ ) end - click_button "Update budget" + click_on "Update budget" expect(page).to have_admin_callout("Budget successfully updated.") diff --git a/decidim-budgets/spec/system/admin_manages_project_permissions_spec.rb b/decidim-budgets/spec/system/admin_manages_project_permissions_spec.rb index daf236806884..b2d1b6d37a2e 100644 --- a/decidim-budgets/spec/system/admin_manages_project_permissions_spec.rb +++ b/decidim-budgets/spec/system/admin_manages_project_permissions_spec.rb @@ -27,7 +27,7 @@ within "fieldset", text: "Vote" do page.check("Example authorization (Direct)") end - click_button "Submit" + click_on "Submit" expect(page).to have_content("Permissions updated successfully") within "tr", text: translated(budget.title) do page.find(".action-icon--edit-projects").click diff --git a/decidim-budgets/spec/system/admin_manages_projects_spec.rb b/decidim-budgets/spec/system/admin_manages_projects_spec.rb index 68866f5475ec..034333b3512a 100644 --- a/decidim-budgets/spec/system/admin_manages_projects_spec.rb +++ b/decidim-budgets/spec/system/admin_manages_projects_spec.rb @@ -37,9 +37,9 @@ it "changes projects category" do find(".js-resource-id-#{project.id}").set(true) find_by_id("js-bulk-actions-button").click - click_button "Change category" + click_on "Change category" select translated(category.name), from: "category_id" - click_button "Update" + click_on "Update" expect(page).to have_admin_callout "Projects successfully updated to the category" within "tr[data-id='#{project.id}']" do @@ -52,9 +52,9 @@ it "changes projects scope" do find(".js-resource-id-#{project.id}").set(true) find_by_id("js-bulk-actions-button").click - click_button "Change scope" + click_on "Change scope" select translated(scope.name), from: :scope_id - click_button "Update" + click_on "Update" expect(page).to have_admin_callout "Projects successfully updated to the scope" within "tr[data-id='#{project.id}']" do @@ -74,9 +74,9 @@ find_by_id("projects_bulk").set(true) find_by_id("js-bulk-actions-button").click - click_button "Change selected" + click_on "Change selected" select "Select", from: "selected_value" - click_button "Update" + click_on "Update" expect(page).to have_admin_callout "These projects were successfully selected for implementation" within "tr[data-id='#{project.id}']" do @@ -97,7 +97,7 @@ visit current_path find_by_id("projects_bulk").set(true) find_by_id("js-bulk-actions-button").click - click_button "Change budget" + click_on "Change budget" options = ["Select budget", format_title(destination_budget), format_title(budget), format_title(another_budget)] expect(page).to have_select("reference_id", options:) end @@ -105,9 +105,9 @@ it "changes project budget" do find_by_id("projects_bulk").set(true) find_by_id("js-bulk-actions-button").click - click_button "Change budget" + click_on "Change budget" select translated(destination_budget.title), from: "reference_id" - click_button "Update project's budget" + click_on "Update project's budget" within_flash_messages do expect(page).to have_content("Projects successfully updated to the budget: #{translated(project.title)} and #{translated(project2.title)}") end diff --git a/decidim-budgets/spec/system/admin_orders_projects_spec.rb b/decidim-budgets/spec/system/admin_orders_projects_spec.rb index e6fd70cf7425..fcd6b50b49c1 100644 --- a/decidim-budgets/spec/system/admin_orders_projects_spec.rb +++ b/decidim-budgets/spec/system/admin_orders_projects_spec.rb @@ -38,7 +38,7 @@ it "orders projects by ID" do ordered_projects = projects.sort_by(&:id).reverse - click_link "ID" + click_on "ID" rows = page.all("tbody tr") rows.each_with_index do |row, i| @@ -49,7 +49,7 @@ it "orders projects by title" do ordered_projects = projects.sort_by { |project| translated(project.title) } - click_link "Title" + click_on "Title" rows = page.all("tbody tr") rows.each_with_index do |row, i| @@ -60,7 +60,7 @@ it "orders projects by category" do ordered_projects = projects.sort_by { |project| translated(project.category.name) } - click_link "Category" + click_on "Category" rows = page.all("tbody tr") rows.each_with_index do |row, i| @@ -71,7 +71,7 @@ it "orders projects by scope" do ordered_projects = projects.sort_by { |project| translated(project.scope.name) } - click_link "Scope" + click_on "Scope" rows = page.all("tbody tr") rows.each_with_index do |row, i| @@ -80,7 +80,7 @@ end it "orders projects by selected" do - click_link "Selected" + click_on "Selected" rows = page.all("tbody tr") expect(rows[0]).to have_text(translated(projects[2].title)) @@ -117,7 +117,7 @@ end it "orders projects by votes count" do - click_link "Votes count" + click_on "Votes count" rows = page.all("tbody tr") expect(rows[0]).to have_text(translated(projects.second.title)) diff --git a/decidim-budgets/spec/system/admin_reminds_users_with_pending_orders_spec.rb b/decidim-budgets/spec/system/admin_reminds_users_with_pending_orders_spec.rb index 3fc587843289..fceedc7646cf 100644 --- a/decidim-budgets/spec/system/admin_reminds_users_with_pending_orders_spec.rb +++ b/decidim-budgets/spec/system/admin_reminds_users_with_pending_orders_spec.rb @@ -17,7 +17,7 @@ switch_to_host(organization.host) login_as user, scope: :user visit_component_admin - click_link "Send voting reminders" + click_on "Send voting reminders" end describe "new vote reminder" do @@ -34,7 +34,7 @@ end it "sends reminders" do - perform_enqueued_jobs { click_button "Send" } + perform_enqueued_jobs { click_on "Send" } expect(page).to have_content("2 users will be reminded") expect(emails.count).to eq(2) @@ -46,10 +46,10 @@ end it "does not send reminders twice" do - perform_enqueued_jobs { click_button "Send" } + perform_enqueued_jobs { click_on "Send" } expect(page).to have_content("2 users will be reminded") - click_link "Send voting reminders" - perform_enqueued_jobs { click_button "Send" } + click_on "Send voting reminders" + perform_enqueued_jobs { click_on "Send" } expect(page).to have_content("0 users will be reminded") end end diff --git a/decidim-budgets/spec/system/comments_spec.rb b/decidim-budgets/spec/system/comments_spec.rb index 3e87eb0c413a..00f5b3a48b38 100644 --- a/decidim-budgets/spec/system/comments_spec.rb +++ b/decidim-budgets/spec/system/comments_spec.rb @@ -27,14 +27,14 @@ another_window = window_opened_by do within(".comment", match: :first) do page.find("[id^='dropdown-trigger']").click - click_link "Get link" + click_on "Get link" end end within_window(another_window) do - expect(page).to have_content(commentable.title["en"]) - expect(page).to have_content(comments.first.body["en"]) - expect(page).to have_no_content(comments.second.body["en"]) + expect(page).to have_content(decidim_sanitize_translated(commentable.title)) + expect(page).to have_content(decidim_sanitize_translated(comments.first.body)) + expect(page).to have_no_content(decidim_sanitize_translated(comments.second.body)) end end end diff --git a/decidim-budgets/spec/system/explore_budget_notifications_spec.rb b/decidim-budgets/spec/system/explore_budget_notifications_spec.rb index b1fd53734ddf..e736d4a8a129 100644 --- a/decidim-budgets/spec/system/explore_budget_notifications_spec.rb +++ b/decidim-budgets/spec/system/explore_budget_notifications_spec.rb @@ -33,7 +33,7 @@ visit_notifications within "#notifications" do - expect(page).to have_content(translated(project.title)) + expect(page).to have_content(decidim_sanitize_translated(project.title)) end end end diff --git a/decidim-budgets/spec/system/explore_budgets_spec.rb b/decidim-budgets/spec/system/explore_budgets_spec.rb index 0e24cf2a1921..be36447cc412 100644 --- a/decidim-budgets/spec/system/explore_budgets_spec.rb +++ b/decidim-budgets/spec/system/explore_budgets_spec.rb @@ -127,7 +127,7 @@ expect(item).to have_content("delete your vote") within item do - accept_confirm { click_link "delete your vote" } + accept_confirm { click_on "delete your vote" } expect(Decidim::Budgets::Order.where(budget:)).to be_blank end end diff --git a/decidim-budgets/spec/system/explore_projects_spec.rb b/decidim-budgets/spec/system/explore_projects_spec.rb index e9d2b930d4c0..efd80191c371 100644 --- a/decidim-budgets/spec/system/explore_projects_spec.rb +++ b/decidim-budgets/spec/system/explore_projects_spec.rb @@ -19,7 +19,7 @@ before do visit_budget - click_link translated(project.title) + click_on translated(project.title) end it_behaves_like "has embedded video in description", :description @@ -55,7 +55,7 @@ fill_in "filter[search_text_cont]", with: translated(project.title) within "div.filter-search" do - click_button + click_on end end @@ -73,7 +73,7 @@ within "aside form.new_filter" do fill_in("filter[search_text_cont]", with: "foobar") within "div.filter-search" do - click_button + click_on end end @@ -109,7 +109,7 @@ visit_budget within "#panel-dropdown-menu-category" do - click_filter_item translated(category.name) + click_filter_item decidim_escape_translated(category.name) end within "#projects" do diff --git a/decidim-budgets/spec/system/orders_spec.rb b/decidim-budgets/spec/system/orders_spec.rb index 02fe390b6808..642165c30490 100644 --- a/decidim-budgets/spec/system/orders_spec.rb +++ b/decidim-budgets/spec/system/orders_spec.rb @@ -309,7 +309,7 @@ expect(page).to have_content "You have not yet voted" - click_button "Return to voting" + click_on "Return to voting" expect(page).to have_no_content("You have not yet voted") expect(page).to have_current_path budget_projects_path @@ -319,7 +319,7 @@ visit_budget within_user_menu do - click_link("Log out") + click_on("Log out") end expect(page).to have_content "You have not yet voted" @@ -349,7 +349,7 @@ page.visit Decidim::EngineRouter.main_proxy(component).budget_project_path(budget, expensive_project) within "#project-#{expensive_project.id}-budget-button" do - click_button + click_on end expect(page).to have_css("#budget-excess", visible: :visible) @@ -428,7 +428,7 @@ before do find("[data-dialog-open='budget-confirm']", match: :first).click - click_button "Confirm" + click_on "Confirm" expect(page).to have_css(".flash.success") end @@ -646,8 +646,8 @@ end it "shows the component" do - expect(page).to have_i18n_content(project.title) - expect(page).to have_i18n_content(project.description) + expect(page).to have_i18n_content(project.title, strip_tags: true) + expect(page).to have_i18n_content(project.description, strip_tags: true) end context "with linked proposals" do @@ -662,7 +662,7 @@ it "shows related proposals" do visit_budget - click_link translated(project.title) + click_on translated(project.title) proposals.each do |proposal| expect(page).to have_content(translated(proposal.title)) @@ -680,7 +680,7 @@ it "does not show the amount of supports" do visit_budget - click_link translated(project.title) + click_on translated(project.title) expect(page).to have_no_css(".card__list-metadata", text: "5") end diff --git a/decidim-budgets/spec/system/sorting_projects_spec.rb b/decidim-budgets/spec/system/sorting_projects_spec.rb index b27d6b0d6e9a..1d7ead591079 100644 --- a/decidim-budgets/spec/system/sorting_projects_spec.rb +++ b/decidim-budgets/spec/system/sorting_projects_spec.rb @@ -32,7 +32,7 @@ within ".order-by" do expect(page).to have_css("div.order-by a", text: "Random order") page.find("a", text: "Random order").click - click_link(selected_option) + click_on(selected_option) end end diff --git a/decidim-budgets/spec/types/integration_schema_spec.rb b/decidim-budgets/spec/types/integration_schema_spec.rb index 6c1adc92a555..13df6c2d71ce 100644 --- a/decidim-budgets/spec/types/integration_schema_spec.rb +++ b/decidim-budgets/spec/types/integration_schema_spec.rb @@ -52,7 +52,7 @@ { "__typename" => "Budgets", "id" => current_component.id.to_s, - "name" => { "translation" => "Budgets" }, + "name" => { "translation" => translated(current_component.name) }, "budgets" => { "edges" => [ { @@ -116,7 +116,7 @@ ) end - it "executes sucessfully" do + it "executes successfully" do expect { response }.not_to raise_error end @@ -178,7 +178,7 @@ ) end - it "executes sucessfully" do + it "executes successfully" do expect { response }.not_to raise_error end diff --git a/decidim-comments/app/models/decidim/comments/seed.rb b/decidim-comments/app/models/decidim/comments/seed.rb index 191370eff4ca..2ff14b481307 100644 --- a/decidim-comments/app/models/decidim/comments/seed.rb +++ b/decidim-comments/app/models/decidim/comments/seed.rb @@ -9,7 +9,7 @@ class Seed class << self # Adds a random amount of comments for a given resource. # - # @param resource [Object] - the Decidim resource to add the coments to. + # @param resource [Object] - the Decidim resource to add the comments to. # examples: Decidim::Proposals::CollaborativeDraft, Decidim::Proposals::Proposal, # # @return nil diff --git a/decidim-comments/app/packs/src/decidim/comments/comments.component.test.js b/decidim-comments/app/packs/src/decidim/comments/comments.component.test.js index a6e8a2e1e707..377c8994d448 100644 --- a/decidim-comments/app/packs/src/decidim/comments/comments.component.test.js +++ b/decidim-comments/app/packs/src/decidim/comments/comments.component.test.js @@ -102,7 +102,7 @@ describe("CommentsComponent", () => {
      -
      - Your opinion about this topic + Your opinion about this topic
      diff --git a/decidim-comments/lib/decidim/comments/test/factories.rb b/decidim-comments/lib/decidim/comments/test/factories.rb index d9fd5fbf083e..ef0ffed7fbb3 100644 --- a/decidim-comments/lib/decidim/comments/test/factories.rb +++ b/decidim-comments/lib/decidim/comments/test/factories.rb @@ -4,8 +4,11 @@ FactoryBot.define do factory :comment, class: "Decidim::Comments::Comment" do - author { build(:user, organization: commentable.organization) } - commentable { build(:dummy_resource) } + transient do + skip_injection { false } + end + author { build(:user, organization: commentable.organization, skip_injection:) } + commentable { build(:dummy_resource, skip_injection:) } root_commentable { commentable } body { Decidim::Faker::Localized.paragraph } participatory_space { commentable.try(:participatory_space) } @@ -25,22 +28,26 @@ end trait :comment_on_comment do - author { build(:user, organization: root_commentable.organization) } + author { build(:user, organization: root_commentable.organization, skip_injection:) } commentable do build( :comment, author:, root_commentable:, - commentable: root_commentable + commentable: root_commentable, + skip_injection: ) end - root_commentable { build(:dummy_resource) } + root_commentable { build(:dummy_resource, skip_injection:) } end end factory :comment_vote, class: "Decidim::Comments::CommentVote" do - comment { build(:comment) } - author { build(:user, organization: comment.organization) } + transient do + skip_injection { false } + end + comment { build(:comment, skip_injection:) } + author { build(:user, organization: comment.organization, skip_injection:) } weight { [-1, 1].sample } trait :up_vote do diff --git a/decidim-comments/lib/decidim/comments/test/shared_examples/comment_event.rb b/decidim-comments/lib/decidim/comments/test/shared_examples/comment_event.rb index e26dc5891af4..b4f4fb0e474e 100644 --- a/decidim-comments/lib/decidim/comments/test/shared_examples/comment_event.rb +++ b/decidim-comments/lib/decidim/comments/test/shared_examples/comment_event.rb @@ -16,7 +16,7 @@ let(:comment_author_name) { decidim_html_escape comment.author.name } let(:extra) { { comment_id: comment.id } } - let(:resource_title) { decidim_escape_translated(resource.title) } + let(:resource_title) { decidim_sanitize_translated(resource.title) } let(:user_group) do user_group = create(:user_group, :verified, organization:, users: [comment_author]) comment.update!(user_group:) diff --git a/decidim-comments/lib/decidim/comments/test/shared_examples/comment_voted_event.rb b/decidim-comments/lib/decidim/comments/test/shared_examples/comment_voted_event.rb index 1cf78c3d4821..2b554063f536 100644 --- a/decidim-comments/lib/decidim/comments/test/shared_examples/comment_voted_event.rb +++ b/decidim-comments/lib/decidim/comments/test/shared_examples/comment_voted_event.rb @@ -12,7 +12,7 @@ let(:comment_vote_author) { comment_vote.author } let(:extra) { { comment_id: comment.id, author_id: comment_vote_author.id, weight:, downvotes: 100, upvotes: 999 } } - let(:resource_title) { decidim_escape_translated(resource.title) } + let(:resource_title) { decidim_sanitize_translated(resource.title) } let(:resource_text) { subject.resource_text } let(:verb) { weight.positive? ? "upvoted" : "downvoted" } diff --git a/decidim-comments/spec/events/decidim/comments/comment_downvoted_event_spec.rb b/decidim-comments/spec/events/decidim/comments/comment_downvoted_event_spec.rb index 0d258eebc671..3cb30b19b532 100644 --- a/decidim-comments/spec/events/decidim/comments/comment_downvoted_event_spec.rb +++ b/decidim-comments/spec/events/decidim/comments/comment_downvoted_event_spec.rb @@ -10,8 +10,8 @@ it_behaves_like "a comment voted event" do let(:parent_comment) { create(:comment) } let(:comment) { create(:comment, commentable: parent_comment, root_commentable: parent_comment.root_commentable) } - let(:resource_title) { decidim_escape_translated(resource.commentable.title) } let(:resource_path) { resource_locator(resource.commentable).path } + let(:resource_title) { decidim_sanitize_translated(parent_comment.root_commentable.title) } end end @@ -19,7 +19,6 @@ it_behaves_like "a comment voted event" do let(:resource) { comment.commentable } let(:comment) { create(:comment) } - let(:resource_title) { decidim_escape_translated(resource.title) } it_behaves_like "a translated comment event" do let(:translatable) { false } diff --git a/decidim-comments/spec/events/decidim/comments/comment_upvoted_event_spec.rb b/decidim-comments/spec/events/decidim/comments/comment_upvoted_event_spec.rb index 5597fcd8f6ca..d4f6b794ceee 100644 --- a/decidim-comments/spec/events/decidim/comments/comment_upvoted_event_spec.rb +++ b/decidim-comments/spec/events/decidim/comments/comment_upvoted_event_spec.rb @@ -10,8 +10,8 @@ it_behaves_like "a comment voted event" do let(:parent_comment) { create(:comment) } let(:comment) { create(:comment, commentable: parent_comment, root_commentable: parent_comment.root_commentable) } - let(:resource_title) { decidim_escape_translated(resource.commentable.title) } let(:resource_path) { resource_locator(resource.commentable).path } + let(:resource_title) { decidim_sanitize_translated(parent_comment.root_commentable.title) } end end @@ -19,7 +19,6 @@ it_behaves_like "a comment voted event" do let(:resource) { comment.commentable } let(:comment) { create(:comment) } - let(:resource_title) { decidim_escape_translated(resource.title) } it_behaves_like "a translated comment event" do let(:translatable) { false } diff --git a/decidim-comments/spec/events/decidim/comments/reply_created_event_spec.rb b/decidim-comments/spec/events/decidim/comments/reply_created_event_spec.rb index d06cc8373279..f234f31ab892 100644 --- a/decidim-comments/spec/events/decidim/comments/reply_created_event_spec.rb +++ b/decidim-comments/spec/events/decidim/comments/reply_created_event_spec.rb @@ -8,10 +8,10 @@ let(:comment) { create(:comment, commentable: parent_comment, root_commentable: parent_comment.root_commentable) } let(:parent_comment) { create(:comment) } let(:resource) { comment.root_commentable } - let(:email_subject) { "#{comment_author_name} has replied your comment in #{translated resource.title}" } + let(:email_subject) { "#{comment_author_name} has replied your comment in #{resource_title}" } let(:email_intro) { "#{comment_author_name} has replied your comment in #{resource_title}. You can read it in this page:" } let(:email_outro) { "You have received this notification because your comment was replied." } - let(:notification_title) { "#{comment_author_name} @#{comment_author.nickname} has replied your comment in #{translated resource.title}" } + let(:notification_title) { "#{comment_author_name} @#{comment_author.nickname} has replied your comment in #{resource_title}" } it_behaves_like "a simple event email" it_behaves_like "a simple event notification" diff --git a/decidim-comments/spec/events/decidim/comments/user_group_mentioned_event_spec.rb b/decidim-comments/spec/events/decidim/comments/user_group_mentioned_event_spec.rb index 4f0b4f9c457e..b8695307a607 100644 --- a/decidim-comments/spec/events/decidim/comments/user_group_mentioned_event_spec.rb +++ b/decidim-comments/spec/events/decidim/comments/user_group_mentioned_event_spec.rb @@ -24,9 +24,9 @@ let(:parsed_body) { Decidim::ContentProcessor.parse("Comment mentioning some user group, @#{group.nickname}", current_organization: organization) } let(:parsed_ca_body) { Decidim::ContentProcessor.parse("Un commentaire pour @#{group.nickname}", current_organization: organization) } let(:body) { { en: parsed_body.rewrite, machine_translations: { ca: parsed_ca_body.rewrite } } } - let(:email_subject) { "You have been mentioned in #{html_escape(translated(resource.title))} as a member of #{html_escape(group.name)}" } + let(:email_subject) { "You have been mentioned in #{resource_title} as a member of #{html_escape(group.name)}" } let(:email_intro) { "A group you belong to has been mentioned" } - let(:email_outro) { "You have received this notification because you are a member of the group #{html_escape(group.name)} that has been mentioned in #{html_escape(translated(resource.title))}." } + let(:email_outro) { "You have received this notification because you are a member of the group #{html_escape(group.name)} that has been mentioned in #{resource_title}." } it_behaves_like "a comment event" it_behaves_like "a simple event email" @@ -61,7 +61,7 @@ describe "notification_title" do it "is generated correctly" do expect(subject.notification_title) - .to include("You have been mentioned in #{html_escape(translated(resource.title))}") + .to include("You have been mentioned in #{resource_title}") expect(subject.notification_title) .to include(" as a member of #{html_escape(group.name)} @#{group.nickname}") diff --git a/decidim-comments/spec/events/decidim/comments/user_mentioned_event_spec.rb b/decidim-comments/spec/events/decidim/comments/user_mentioned_event_spec.rb index 14e8e039cb45..eff70c46b9ab 100644 --- a/decidim-comments/spec/events/decidim/comments/user_mentioned_event_spec.rb +++ b/decidim-comments/spec/events/decidim/comments/user_mentioned_event_spec.rb @@ -22,10 +22,10 @@ let(:author) { create(:user, organization:) } let!(:comment) { create(:comment, body:, author:, commentable:) } let(:user) { create(:user, organization:, locale: "ca") } - let(:notification_title) { "You have been mentioned in #{translated resource.title} by #{author.name} @#{author.nickname}" } - let(:email_subject) { "You have been mentioned in #{translated resource.title}" } + let(:notification_title) { "You have been mentioned in #{resource_title} by #{author.name} @#{author.nickname}" } + let(:email_subject) { "You have been mentioned in #{resource_title}" } let(:email_intro) { "You have been mentioned" } - let(:email_outro) { "You have received this notification because you have been mentioned in #{translated resource.title}." } + let(:email_outro) { "You have received this notification because you have been mentioned in #{resource_title}." } it_behaves_like "a comment event" it_behaves_like "a simple event email" diff --git a/decidim-comments/spec/types/comment_type_spec.rb b/decidim-comments/spec/types/comment_type_spec.rb index dd02d0b9ba1e..ab51e1394f58 100644 --- a/decidim-comments/spec/types/comment_type_spec.rb +++ b/decidim-comments/spec/types/comment_type_spec.rb @@ -91,7 +91,7 @@ module Comments let(:query) { "{ comments { id } }" } - it "return comment's comments comments data" do + it "return comment's comments data" do replies.each do |reply| expect(response["comments"]).to include("id" => reply.id.to_s) end diff --git a/decidim-conferences/app/cells/decidim/conferences/conference_speaker_cell.rb b/decidim-conferences/app/cells/decidim/conferences/conference_speaker_cell.rb index 36c419a93397..ae318065b1fc 100644 --- a/decidim-conferences/app/cells/decidim/conferences/conference_speaker_cell.rb +++ b/decidim-conferences/app/cells/decidim/conferences/conference_speaker_cell.rb @@ -50,7 +50,7 @@ def affiliation def short_bio return unless model.short_bio.presence - translated_attribute model.short_bio + decidim_escape_translated model.short_bio end def twitter_handle diff --git a/decidim-conferences/config/initializers/wicked_pdf.rb b/decidim-conferences/config/initializers/wicked_pdf.rb index 37eb9bd5e8b2..150d9b175c5c 100644 --- a/decidim-conferences/config/initializers/wicked_pdf.rb +++ b/decidim-conferences/config/initializers/wicked_pdf.rb @@ -10,14 +10,14 @@ # # https://github.com/mileszs/wicked_pdf/blob/master/README.md -WickedPdf.config = { +WickedPdf.configure do |config| # Path to the wkhtmltopdf executable: This usually is not needed if using # one of the wkhtmltopdf-binary family of gems. - # exe_path: '/usr/local/bin/wkhtmltopdf', # or - exe_path: Gem.bin_path("wkhtmltopdf-binary", "wkhtmltopdf") + # config.exe_path = '/usr/local/bin/wkhtmltopdf', + config.exe_path = Gem.bin_path("wkhtmltopdf-binary", "wkhtmltopdf") # Layout file to be used for all PDFs # (but can be overridden in `render :pdf` calls) - # layout: 'pdf.html', -} + # config.layout = 'pdf.html' +end diff --git a/decidim-conferences/lib/decidim/conferences/test/factories.rb b/decidim-conferences/lib/decidim/conferences/test/factories.rb index be18b730a6c1..416f0b17f588 100644 --- a/decidim-conferences/lib/decidim/conferences/test/factories.rb +++ b/decidim-conferences/lib/decidim/conferences/test/factories.rb @@ -10,13 +10,16 @@ end factory :conference, class: "Decidim::Conference" do - title { generate_localized_title } + transient do + skip_injection { false } + end + title { generate_localized_title(:conference_title, skip_injection:) } slug { generate(:conference_slug) } weight { 1 } - slogan { generate_localized_title } - short_description { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } - description { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } - objectives { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } + slogan { generate_localized_title(:conference_slogan, skip_injection:) } + short_description { generate_localized_description(:conference_short_description, skip_injection:) } + description { generate_localized_description(:conference_description, skip_injection:) } + objectives { generate_localized_description(:conference_objectives, skip_injection:) } organization hero_image { Decidim::Dev.test_file("city.jpeg", "image/jpeg") } # Keep after organization banner_image { Decidim::Dev.test_file("city2.jpeg", "image/jpeg") } # Keep after organization @@ -25,7 +28,7 @@ show_statistics { true } start_date { 1.month.ago } end_date { 1.month.ago + 3.days } - registration_terms { generate_localized_title } + registration_terms { generate_localized_title(:conference_registration_terms, skip_injection:) } registrations_enabled { true } trait :promoted do @@ -49,14 +52,18 @@ end factory :conference_user_role, class: "Decidim::ConferenceUserRole" do + transient do + skip_injection { false } + end user - conference { create :conference, organization: user.organization } + conference { create :conference, organization: user.organization, skip_injection: } role { "admin" } end factory :conference_admin, parent: :user, class: "Decidim::User" do transient do - conference { create(:conference) } + skip_injection { false } + conference { create(:conference, skip_injection:) } end organization { conference.organization } @@ -66,13 +73,15 @@ create :conference_user_role, user:, conference: evaluator.conference, - role: :admin + role: :admin, + skip_injection: evaluator.skip_injection end end factory :conference_moderator, parent: :user, class: "Decidim::User" do transient do - conference { create(:conference) } + skip_injection { false } + conference { create(:conference, skip_injection:) } end organization { conference.organization } @@ -82,13 +91,15 @@ create :conference_user_role, user:, conference: evaluator.conference, - role: :moderator + role: :moderator, + skip_injection: evaluator.skip_injection end end factory :conference_collaborator, parent: :user, class: "Decidim::User" do transient do - conference { create(:conference) } + skip_injection { false } + conference { create(:conference, skip_injection:) } end organization { conference.organization } @@ -98,13 +109,15 @@ create :conference_user_role, user:, conference: evaluator.conference, - role: :collaborator + role: :collaborator, + skip_injection: evaluator.skip_injection end end factory :conference_valuator, parent: :user, class: "Decidim::User" do transient do - conference { create(:conference) } + skip_injection { false } + conference { create(:conference, skip_injection:) } end organization { conference.organization } @@ -114,17 +127,21 @@ create :conference_user_role, user:, conference: evaluator.conference, - role: :valuator + role: :valuator, + skip_injection: evaluator.skip_injection end end factory :conference_speaker, class: "Decidim::ConferenceSpeaker" do - conference { create(:conference) } + transient do + skip_injection { false } + end + conference { create(:conference, skip_injection:) } full_name { Faker::Name.name } position { Decidim::Faker::Localized.word } affiliation { Decidim::Faker::Localized.word } - short_bio { generate_localized_title } + short_bio { generate_localized_title(:conference_speaker_short_bio, skip_injection:) } twitter_handle { Faker::Internet.user_name } personal_url { Faker::Internet.url } @@ -133,58 +150,66 @@ end trait :with_user do - user { create(:user, organization: conference.organization) } + user { create(:user, organization: conference.organization, skip_injection:) } end trait :with_meeting do transient do - meetings_component { create(:meetings_component, participatory_space: conference.participatory_space) } + meetings_component { create(:meetings_component, participatory_space: conference.participatory_space, skip_injection:) } end after :build do |conference_speaker, evaluator| conference_speaker.conference_speaker_conference_meetings << build(:conference_speaker_conference_meeting, meetings_component: evaluator.meetings_component, - conference_speaker:) + conference_speaker:, + skip_injection: evaluator.skip_injection) end end end factory :conference_speaker_conference_meeting, class: "Decidim::ConferenceSpeakerConferenceMeeting" do transient do - conference { create(:conference) } - meetings_component { create(:meetings_component, participatory_space: conference.participatory_space) } + skip_injection { false } + conference { create(:conference, skip_injection:) } + meetings_component { create(:meetings_component, skip_injection:, participatory_space: conference.participatory_space) } end - conference_meeting { create(:conference_meeting, :published, conference:, component: meetings_component) } - conference_speaker { create(:conference_speaker, conference:) } + conference_meeting { create(:conference_meeting, :published, conference:, skip_injection:, component: meetings_component) } + conference_speaker { create(:conference_speaker, conference:, skip_injection:) } end factory :conference_meeting_registration_type, class: "Decidim::Conferences::ConferenceMeetingRegistrationType" do transient do - conference { create(:conference) } + skip_injection { false } + conference { create(:conference, skip_injection:) } end conference_meeting - registration_type { build(:registration_type, conference:) } + registration_type { build(:registration_type, conference:, skip_injection:) } end factory :conference_meeting, parent: :meeting, class: "Decidim::ConferenceMeeting" do transient do + skip_injection { false } conference { create(:conference) } end after :build do |conference_meeting, evaluator| conference_meeting.conference_meeting_registration_types << build(:conference_meeting_registration_type, conference_meeting:, - conference: evaluator.conference) + conference: evaluator.conference, + skip_injection: evaluator.skip_injection) end end factory :registration_type, class: "Decidim::Conferences::RegistrationType" do + transient do + skip_injection { false } + end conference - title { generate_localized_title } - description { Decidim::Faker::Localized.wrapped("

      ", "

      ") { generate_localized_title } } + title { generate_localized_title(:registration_type_title, skip_injection:) } + description { generate_localized_description(:registration_type_description, skip_injection:) } published_at { Time.current } price { Faker::Number.between(from: 1, to: 300) } weight { Faker::Number.between(from: 1, to: 10) } @@ -199,6 +224,9 @@ end factory :conference_registration, class: "Decidim::Conferences::ConferenceRegistration" do + transient do + skip_injection { false } + end conference user registration_type @@ -214,6 +242,9 @@ end factory :conference_invite, class: "Decidim::Conferences::ConferenceInvite" do + transient do + skip_injection { false } + end conference user sent_at { 1.day.ago } @@ -231,6 +262,9 @@ end factory :partner, class: "Decidim::Conferences::Partner" do + transient do + skip_injection { false } + end conference name { Faker::Name.name } @@ -249,8 +283,11 @@ end factory :media_link, class: "Decidim::Conferences::MediaLink" do + transient do + skip_injection { false } + end conference - title { generate_localized_title } + title { generate_localized_title(:media_link_title, skip_injection:) } weight { Faker::Number.between(from: 1, to: 10) } link { Faker::Internet.url } date { 1.month.ago } diff --git a/decidim-conferences/spec/commands/join_conference_spec.rb b/decidim-conferences/spec/commands/join_conference_spec.rb index 31a488d1e24d..e910184821d1 100644 --- a/decidim-conferences/spec/commands/join_conference_spec.rb +++ b/decidim-conferences/spec/commands/join_conference_spec.rb @@ -52,7 +52,7 @@ module Decidim::Conferences email = last_email expect(email.subject).to include("pending") - expect(email.body.encoded).to include(translated(registration_type.title)) + expect(email.text_part.body.to_s).to include(translated(registration_type.title).first(60)) end it "sends a notification to the user with the pending validation" do diff --git a/decidim-conferences/spec/services/decidim/conferences/searchable_conferences_resource_spec.rb b/decidim-conferences/spec/services/decidim/conferences/searchable_conferences_resource_spec.rb index 5586de57da13..25194ab11734 100644 --- a/decidim-conferences/spec/services/decidim/conferences/searchable_conferences_resource_spec.rb +++ b/decidim-conferences/spec/services/decidim/conferences/searchable_conferences_resource_spec.rb @@ -37,7 +37,7 @@ module Decidim d += I18n.transliterate(translated(space.objectives, locale:)) { "content_a" => I18n.transliterate(translated(space.title, locale:)), - "content_b" => I18n.transliterate(translated(space.slogan, locale:)), + "content_b" => I18n.transliterate(strip_tags(translated(space.slogan, locale:))), "content_c" => I18n.transliterate(translated(space.short_description, locale:)), "content_d" => d } diff --git a/decidim-conferences/spec/shared/copy_conferences_examples.rb b/decidim-conferences/spec/shared/copy_conferences_examples.rb index 90dc4920c994..25a39bc17d9e 100644 --- a/decidim-conferences/spec/shared/copy_conferences_examples.rb +++ b/decidim-conferences/spec/shared/copy_conferences_examples.rb @@ -18,7 +18,7 @@ context "without any context" do it "copies the conference with the basic fields" do - click_link "Duplicate", match: :first + click_on "Duplicate", match: :first within ".copy_conference" do fill_in_i18n( @@ -29,7 +29,7 @@ ca: "Còpia del procés participatiu" ) fill_in :conference_slug, with: "pp-copy" - click_button "Copy" + click_on "Copy" end expect(page).to have_content("successfully") @@ -40,7 +40,7 @@ context "with context" do before do - click_link "Duplicate", match: :first + click_on "Duplicate", match: :first within ".copy_conference" do fill_in_i18n( @@ -56,15 +56,15 @@ it "copies the conference with categories" do page.check("conference[copy_categories]") - click_button "Copy" + click_on "Copy" expect(page).to have_content("successfully") within "tr", text: "Copy conference" do - click_link "Configure" + click_on "Configure" end within_admin_sidebar_menu do - click_link "Categories" + click_on "Categories" end within ".table-list" do @@ -76,15 +76,15 @@ it "copies the conference with components" do page.check("conference[copy_components]") - click_button "Copy" + click_on "Copy" expect(page).to have_content("successfully") within "tr", text: "Copy conference" do - click_link "Configure" + click_on "Configure" end within_admin_sidebar_menu do - click_link "Components" + click_on "Components" end within ".table-list" do diff --git a/decidim-conferences/spec/shared/manage_conference_admins_examples.rb b/decidim-conferences/spec/shared/manage_conference_admins_examples.rb index d1430cfc1bda..29d3a9e4f9de 100644 --- a/decidim-conferences/spec/shared/manage_conference_admins_examples.rb +++ b/decidim-conferences/spec/shared/manage_conference_admins_examples.rb @@ -15,7 +15,7 @@ login_as user, scope: :user visit decidim_admin_conferences.edit_conference_path(conference) within_admin_sidebar_menu do - click_link "Conference admins" + click_on "Conference admins" end end @@ -26,7 +26,7 @@ end it "creates a new conference admin" do - click_link "New conference admin" + click_on "New conference admin" within ".new_conference_user_role" do fill_in :conference_user_role_email, with: other_user.email @@ -52,7 +52,7 @@ it "updates a conference admin" do within "#conference_admins" do within "#conference_admins tr", text: other_user.email do - click_link "Edit" + click_on "Edit" end end @@ -71,7 +71,7 @@ it "deletes a conference_user_role" do within "#conference_admins tr", text: other_user.email do - accept_confirm { click_link "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_admin_callout("successfully") @@ -102,7 +102,7 @@ it "resends the invitation to the user" do within "#conference_admins tr", text: "test@example.org" do - click_link "Resend invitation" + click_on "Resend invitation" end expect(page).to have_admin_callout("successfully") diff --git a/decidim-conferences/spec/shared/manage_conference_categories_examples.rb b/decidim-conferences/spec/shared/manage_conference_categories_examples.rb index 93506446f70b..09a8ac664b67 100644 --- a/decidim-conferences/spec/shared/manage_conference_categories_examples.rb +++ b/decidim-conferences/spec/shared/manage_conference_categories_examples.rb @@ -8,7 +8,7 @@ login_as user, scope: :user visit decidim_admin_conferences.edit_conference_path(conference) within_admin_sidebar_menu do - click_link "Categories" + click_on "Categories" end end diff --git a/decidim-conferences/spec/shared/manage_conference_components_examples.rb b/decidim-conferences/spec/shared/manage_conference_components_examples.rb index 2e708b01e53d..8d8efd6210c2 100644 --- a/decidim-conferences/spec/shared/manage_conference_components_examples.rb +++ b/decidim-conferences/spec/shared/manage_conference_components_examples.rb @@ -43,7 +43,7 @@ all("input[type=checkbox]").first.click end - click_button "Add component" + click_on "Add component" end end @@ -55,7 +55,7 @@ context "and then edit it" do before do within "tr", text: "My component" do - click_link "Configure" + click_on "Configure" end end @@ -70,7 +70,7 @@ end it "successfully edits it" do - click_button "Update" + click_on "Update" expect(page).to have_admin_callout("successfully") end @@ -96,7 +96,7 @@ it "updates the component" do within ".component-#{component.id}" do - click_link "Configure" + click_on "Configure" end within ".edit_component" do @@ -116,14 +116,14 @@ all("input[type=checkbox]").first.click end - click_button "Update" + click_on "Update" end expect(page).to have_admin_callout("successfully") expect(page).to have_content("My updated component") within "tr", text: "My updated component" do - click_link "Configure" + click_on "Configure" end within ".global-settings" do @@ -155,7 +155,7 @@ it "removes the component" do within ".component-#{component.id}" do - click_link "Delete" + click_on "Delete" end expect(page).to have_no_content("My component") @@ -176,7 +176,7 @@ context "when the component is unpublished" do it "publishes the component" do within ".component-#{component.id}" do - click_link "Publish" + click_on "Publish" end within ".component-#{component.id}" do @@ -189,7 +189,7 @@ create(:follow, followable: conference, user: follower) within ".component-#{component.id}" do - click_link "Publish" + click_on "Publish" end expect(enqueued_jobs.last[:args]).to include("decidim.events.components.component_published") @@ -203,7 +203,7 @@ it "unpublishes the component" do within ".component-#{component.id}" do - click_link "Unpublish" + click_on "Unpublish" end within ".component-#{component.id}" do diff --git a/decidim-conferences/spec/shared/manage_conference_speakers_examples.rb b/decidim-conferences/spec/shared/manage_conference_speakers_examples.rb index db2e8ceacf44..40d194a29ed3 100644 --- a/decidim-conferences/spec/shared/manage_conference_speakers_examples.rb +++ b/decidim-conferences/spec/shared/manage_conference_speakers_examples.rb @@ -8,7 +8,7 @@ login_as user, scope: :user visit decidim_admin_conferences.edit_conference_path(conference) within_admin_sidebar_menu do - click_link "Speakers" + click_on "Speakers" end end @@ -20,7 +20,7 @@ context "without existing user" do it "creates a new conference speaker" do - click_link "New speaker" + click_on "New speaker" within ".new_conference_speaker" do fill_in( @@ -44,7 +44,7 @@ let!(:speaker_user) { create(:user, organization: conference.organization) } it "creates a new conference speaker" do - click_link "New speaker" + click_on "New speaker" within ".new_conference_speaker" do select "Existing participant", from: :conference_speaker_existing_user @@ -69,7 +69,7 @@ it "updates a conference speaker" do within "#conference_speakers tr", text: conference_speaker.full_name do - click_link "Edit" + click_on "Edit" end within ".edit_conference_speaker" do diff --git a/decidim-conferences/spec/shared/manage_conferences_examples.rb b/decidim-conferences/spec/shared/manage_conferences_examples.rb index aa1ec2f58fa1..a9c53bde4103 100644 --- a/decidim-conferences/spec/shared/manage_conferences_examples.rb +++ b/decidim-conferences/spec/shared/manage_conferences_examples.rb @@ -9,7 +9,7 @@ let(:image2_path) { Decidim::Dev.asset(image2_filename) } before do - click_link "New conference" + click_on "New conference" end %w(description short_description objectives).each do |field| @@ -78,7 +78,7 @@ before do within "tr", text: translated(conference.title) do - click_link "Configure" + click_on "Configure" end end @@ -108,7 +108,7 @@ describe "updating a conference without images" do before do within "tr", text: translated(conference.title) do - click_link "Configure" + click_on "Configure" end end @@ -119,9 +119,9 @@ it "update an conference without images does not delete them" do within_admin_sidebar_menu do - click_link "About this conference" + click_on "About this conference" end - click_button "Update" + click_on "Update" expect(page).to have_admin_callout("successfully") @@ -136,7 +136,7 @@ it "allows the user to preview the unpublished conference" do within "tr", text: translated(conference.title) do - click_link "Preview" + click_on "Preview" end expect(page).to have_content(translated(conference.title)) @@ -149,7 +149,7 @@ it "allows the user to preview the unpublished conference" do new_window = window_opened_by do within "tr", text: translated(conference.title) do - click_link "Preview" + click_on "Preview" end end @@ -172,12 +172,12 @@ before do within "tr", text: translated(conference.title) do - click_link "Configure" + click_on "Configure" end end it "publishes the conference" do - click_link "Publish" + click_on "Publish" expect(page).to have_content("successfully published") expect(page).to have_content("Unpublish") expect(page).to have_current_path decidim_admin_conferences.edit_conference_path(conference) @@ -192,12 +192,12 @@ before do within "tr", text: translated(conference.title) do - click_link "Configure" + click_on "Configure" end end it "unpublishes the conference" do - click_link "Unpublish" + click_on "Unpublish" expect(page).to have_content("successfully unpublished") expect(page).to have_content("Publish") expect(page).to have_current_path decidim_admin_conferences.edit_conference_path(conference) @@ -226,7 +226,7 @@ it "disables the scope for the conference" do within "tr", text: translated(conference.title) do - click_link "Configure" + click_on "Configure" end uncheck :conference_scopes_enabled diff --git a/decidim-conferences/spec/shared/manage_diplomas_examples.rb b/decidim-conferences/spec/shared/manage_diplomas_examples.rb index 3677fa1a150e..96e35d99fee2 100644 --- a/decidim-conferences/spec/shared/manage_diplomas_examples.rb +++ b/decidim-conferences/spec/shared/manage_diplomas_examples.rb @@ -10,11 +10,11 @@ context "when diploma configuration not exists" do it "configure the diploma settings" do within "tr", text: translated(conference.title) do - click_link "Configure" + click_on "Configure" end within_admin_sidebar_menu do - click_link "Certificate of Attendance" + click_on "Certificate of Attendance" end dynamically_attach_file(:conference_main_logo, main_logo_path) @@ -24,7 +24,7 @@ fill_in_datepicker :conference_sign_date_date, with: 5.days.from_now.strftime("%d/%m/%Y") fill_in :conference_signature_name, with: "Signature name" - click_button "Save" + click_on "Save" end expect(page).to have_admin_callout("successfully") @@ -40,11 +40,11 @@ context "and diplomas has not been sent" do before do within "tr", text: translated(conference.title) do - click_link "Configure" + click_on "Configure" end within_admin_sidebar_menu do - click_link "Certificate of Attendance" + click_on "Certificate of Attendance" end end @@ -54,7 +54,7 @@ end it "is successfully created" do - click_link "Send certificates of attendance" + click_on "Send certificates of attendance" expect(page).to have_admin_callout("successfully") end end @@ -70,11 +70,11 @@ it "cannot send the diplomas" do within "tr", text: translated(conference.title) do - click_link "Configure" + click_on "Configure" end within_admin_sidebar_menu do - click_link "Certificate of Attendance" + click_on "Certificate of Attendance" end expect(page).to have_css("#send-diplomas.disabled") @@ -88,11 +88,11 @@ it "cannot send the diplomas" do within "tr", text: translated(conference.title) do - click_link "Configure" + click_on "Configure" end within_admin_sidebar_menu do - click_link "Certificate of Attendance" + click_on "Certificate of Attendance" end expect(page).to have_no_css("#send-diplomas") diff --git a/decidim-conferences/spec/shared/manage_media_links_examples.rb b/decidim-conferences/spec/shared/manage_media_links_examples.rb index c9d640fa0bb7..8612b12dbf2d 100644 --- a/decidim-conferences/spec/shared/manage_media_links_examples.rb +++ b/decidim-conferences/spec/shared/manage_media_links_examples.rb @@ -6,13 +6,13 @@ login_as user, scope: :user visit decidim_admin_conferences.edit_conference_path(conference) within_admin_sidebar_menu do - click_link "Media Links" + click_on "Media Links" end end describe "creating media link" do before do - click_link "New media link" + click_on "New media link" end it "creates a new media link" do @@ -58,7 +58,7 @@ it "updates a conference media links" do within "#media_links tr", text: translated(media_link.title) do - click_link "Edit" + click_on "Edit" end within ".edit_media_link" do @@ -110,7 +110,7 @@ it "lists 10 media links per page by default" do expect(page).to have_css(resource_selector, count: 10) expect(page).to have_css("[data-pages] [data-page]", count: 2) - click_link "Next" + click_on "Next" expect(page).to have_css("[data-pages] [data-page][aria-current='page']", text: "2") expect(page).to have_css(resource_selector, count: 5) end diff --git a/decidim-conferences/spec/shared/manage_partners_examples.rb b/decidim-conferences/spec/shared/manage_partners_examples.rb index d9b863956a33..f3c618a91722 100644 --- a/decidim-conferences/spec/shared/manage_partners_examples.rb +++ b/decidim-conferences/spec/shared/manage_partners_examples.rb @@ -8,7 +8,7 @@ login_as user, scope: :user visit decidim_admin_conferences.edit_conference_path(conference) within_admin_sidebar_menu do - click_link "Partners" + click_on "Partners" end end @@ -25,7 +25,7 @@ it "updates a conference partners" do within "#partners tr", text: conference_partner.name do - click_link "Edit" + click_on "Edit" end within ".edit_partner" do diff --git a/decidim-conferences/spec/shared/manage_registration_types_examples.rb b/decidim-conferences/spec/shared/manage_registration_types_examples.rb index 5d35257565ea..9f6963e6c61b 100644 --- a/decidim-conferences/spec/shared/manage_registration_types_examples.rb +++ b/decidim-conferences/spec/shared/manage_registration_types_examples.rb @@ -8,7 +8,7 @@ login_as user, scope: :user visit decidim_admin_conferences.edit_conference_path(conference) within_admin_sidebar_menu do - click_link "Registration Types" + click_on "Registration Types" end end @@ -25,7 +25,7 @@ it "updates a conference registration types" do within "#registration_types tr", text: translated(registration_type.title) do - click_link "Edit" + click_on "Edit" end within ".edit_registration_type" do diff --git a/decidim-conferences/spec/system/admin/admin_manages_conference_attachment_collections_spec.rb b/decidim-conferences/spec/system/admin/admin_manages_conference_attachment_collections_spec.rb index eceb19908efc..0514a84d4810 100644 --- a/decidim-conferences/spec/system/admin/admin_manages_conference_attachment_collections_spec.rb +++ b/decidim-conferences/spec/system/admin/admin_manages_conference_attachment_collections_spec.rb @@ -12,9 +12,9 @@ login_as user, scope: :user visit decidim_admin_conferences.edit_conference_path(conference) within_admin_sidebar_menu do - click_link "Attachments" + click_on "Attachments" end - click_link "Folders" + click_on "Folders" end it_behaves_like "manage attachment collections examples" diff --git a/decidim-conferences/spec/system/admin/admin_manages_conference_attachments_spec.rb b/decidim-conferences/spec/system/admin/admin_manages_conference_attachments_spec.rb index 631dee987015..d4cc94b35b93 100644 --- a/decidim-conferences/spec/system/admin/admin_manages_conference_attachments_spec.rb +++ b/decidim-conferences/spec/system/admin/admin_manages_conference_attachments_spec.rb @@ -13,7 +13,7 @@ login_as user, scope: :user visit decidim_admin_conferences.edit_conference_path(conference) within_admin_sidebar_menu do - click_link "Attachments" + click_on "Attachments" end end diff --git a/decidim-conferences/spec/system/admin/conference_admin_accesses_admin_sections_spec.rb b/decidim-conferences/spec/system/admin/conference_admin_accesses_admin_sections_spec.rb index 16743b3d610e..7e442ea2b597 100644 --- a/decidim-conferences/spec/system/admin/conference_admin_accesses_admin_sections_spec.rb +++ b/decidim-conferences/spec/system/admin/conference_admin_accesses_admin_sections_spec.rb @@ -10,7 +10,7 @@ login_as user, scope: :user visit decidim_admin_conferences.conferences_path - click_link "Configure" + click_on "Configure" end it "can access all sections" do diff --git a/decidim-conferences/spec/system/admin/valuator_checks_components_spec.rb b/decidim-conferences/spec/system/admin/valuator_checks_components_spec.rb index 3fc456d7ee94..8e3cf8629de6 100644 --- a/decidim-conferences/spec/system/admin/valuator_checks_components_spec.rb +++ b/decidim-conferences/spec/system/admin/valuator_checks_components_spec.rb @@ -33,7 +33,7 @@ context "when listing components in the space components page" do it "can only see the proposals component" do within_admin_sidebar_menu do - click_link "Components" + click_on "Components" end within ".card" do diff --git a/decidim-conferences/spec/system/conference_program_spec.rb b/decidim-conferences/spec/system/conference_program_spec.rb index 4ac15c0ce7bf..6449c9c2e5b6 100644 --- a/decidim-conferences/spec/system/conference_program_spec.rb +++ b/decidim-conferences/spec/system/conference_program_spec.rb @@ -51,7 +51,7 @@ within "aside .conference__nav-container" do expect(page).to have_content(decidim_escape_translated(component.name)) - click_link decidim_escape_translated(component.name) + click_on decidim_escape_translated(component.name) end expect(page).to have_current_path decidim_conferences.conference_conference_program_path(conference, component) diff --git a/decidim-conferences/spec/system/conference_registrations_spec.rb b/decidim-conferences/spec/system/conference_registrations_spec.rb index 2d26a83dcdab..04e6cddd372b 100644 --- a/decidim-conferences/spec/system/conference_registrations_spec.rb +++ b/decidim-conferences/spec/system/conference_registrations_spec.rb @@ -113,12 +113,12 @@ def visit_conference_registration_type visit_conference_registration_types within "#registration-type-#{registration_type.id}" do - click_button "Registration" + click_on "Registration" end within "#conference-registration-confirm-#{registration_type.id}" do expect(page).to have_content "A legal text" - click_button "Confirm" + click_on "Confirm" end expect(page).to have_content("successfully") @@ -155,7 +155,7 @@ def visit_conference_registration_type visit_conference_registration_types within "#registration-type-#{registration_type.id}" do - click_button "Attending" + click_on "Attending" end expect(page).to have_content("successfully") diff --git a/decidim-conferences/spec/system/conference_speakers_spec.rb b/decidim-conferences/spec/system/conference_speakers_spec.rb index 6b813bf4f28b..d693fafd863c 100644 --- a/decidim-conferences/spec/system/conference_speakers_spec.rb +++ b/decidim-conferences/spec/system/conference_speakers_spec.rb @@ -43,7 +43,7 @@ within ".conference__nav-container" do expect(page).to have_content("Speakers") - click_link "Speakers" + click_on "Speakers" end expect(page).to have_current_path decidim_conferences.conference_conference_speakers_path(conference) diff --git a/decidim-conferences/spec/system/conferences_spec.rb b/decidim-conferences/spec/system/conferences_spec.rb index 75cacea27a85..5706492cbf7f 100644 --- a/decidim-conferences/spec/system/conferences_spec.rb +++ b/decidim-conferences/spec/system/conferences_spec.rb @@ -92,7 +92,7 @@ visit decidim.root_path within "#home__menu" do - click_link "Conferences" + click_on "Conferences" end expect(page).to have_current_path decidim_conferences.conferences_path diff --git a/decidim-conferences/spec/system/partners_spec.rb b/decidim-conferences/spec/system/partners_spec.rb index 739b35048109..2c85b9be20c2 100644 --- a/decidim-conferences/spec/system/partners_spec.rb +++ b/decidim-conferences/spec/system/partners_spec.rb @@ -27,7 +27,7 @@ within "aside .conference__nav-container" do expect(page).to have_content("Partners") - click_link "Partners" + click_on "Partners" end end diff --git a/decidim-conferences/spec/types/integration_schema_spec.rb b/decidim-conferences/spec/types/integration_schema_spec.rb index 9a8c4dbcb456..a67afde1a956 100644 --- a/decidim-conferences/spec/types/integration_schema_spec.rb +++ b/decidim-conferences/spec/types/integration_schema_spec.rb @@ -124,7 +124,7 @@ end describe "valid query" do - it "executes sucessfully" do + it "executes successfully" do expect { response }.not_to raise_error end @@ -217,7 +217,7 @@ ) end - it "executes sucessfully" do + it "executes successfully" do expect { response }.not_to raise_error end diff --git a/decidim-core/app/cells/decidim/address/online.erb b/decidim-core/app/cells/decidim/address/online.erb index 9468a58a3e15..c41df517bcec 100644 --- a/decidim-core/app/cells/decidim/address/online.erb +++ b/decidim-core/app/cells/decidim/address/online.erb @@ -2,8 +2,10 @@ <%= icon "map-pin-line" %>
      <%= t(model.type_of_meeting, scope: "decidim.meetings.meetings.filters.type_values") %>
      - - <%= model.online_meeting_url %> + <% if display_online_meeting_url? %> + + <%= model.online_meeting_url %> + <% end %>
      diff --git a/decidim-core/app/cells/decidim/address_cell.rb b/decidim-core/app/cells/decidim/address_cell.rb index 9377db0acedf..2b888b13b573 100644 --- a/decidim-core/app/cells/decidim/address_cell.rb +++ b/decidim-core/app/cells/decidim/address_cell.rb @@ -30,5 +30,12 @@ def location def address decidim_sanitize_translated(model.address) end + + def display_online_meeting_url? + return true unless model.respond_to?(:online?) + return true unless model.respond_to?(:iframe_access_level_allowed_for_user?) + + model.online? && model.iframe_access_level_allowed_for_user?(current_user) + end end end diff --git a/decidim-core/app/cells/decidim/authorization_modal/show.erb b/decidim-core/app/cells/decidim/authorization_modal/show.erb index 85a847b63175..521124db4d9a 100644 --- a/decidim-core/app/cells/decidim/authorization_modal/show.erb +++ b/decidim-core/app/cells/decidim/authorization_modal/show.erb @@ -1,6 +1,10 @@ -
      - <%= icon "lock-line" %> -

      <%= title %>

      +<% add_decidim_page_title(title) %> + +
      +
      + <%= icon "lock-line", class: "w-20 h-20" %> +
      +

      <%= title %>

      <% verifications.each do |verification| %> @@ -25,4 +29,4 @@ <% end %>
      -
      + diff --git a/decidim-core/app/cells/decidim/card_cell.rb b/decidim-core/app/cells/decidim/card_cell.rb index d4d8bafb115e..54516fb65956 100644 --- a/decidim-core/app/cells/decidim/card_cell.rb +++ b/decidim-core/app/cells/decidim/card_cell.rb @@ -3,7 +3,7 @@ module Decidim # This cell renders the card of the given instance of a Component # delegated to the components' cell if specified in the manifest - # otherwise a primary cell wil be shown. + # otherwise a primary cell will be shown. class CardCell < Decidim::ViewModel ICONS_MAPPING = { published_at: "calendar-line", diff --git a/decidim-core/app/cells/decidim/upload_modal_cell.rb b/decidim-core/app/cells/decidim/upload_modal_cell.rb index c36ee465c302..c34febf550c7 100644 --- a/decidim-core/app/cells/decidim/upload_modal_cell.rb +++ b/decidim-core/app/cells/decidim/upload_modal_cell.rb @@ -152,7 +152,7 @@ def file_name_for(attachment) def determine_filename(attachment) return attachment.filename.to_s if attachment.is_a? ActiveStorage::Blob return blob(attachment).filename.to_s if blob(attachment).present? - return attachment.original_filename.to_s.presence || attachhment.path.split("/").last if attachment.is_a? ActionDispatch::Http::UploadedFile + return attachment.original_filename.to_s.presence || attachment.path.split("/").last if attachment.is_a? ActionDispatch::Http::UploadedFile attachment.url.split("/").last end diff --git a/decidim-core/app/cells/decidim/wizard_step_form/wizard_aside.erb b/decidim-core/app/cells/decidim/wizard_step_form/wizard_aside.erb index 6c5a81abd8a0..f4cd9b11b955 100644 --- a/decidim-core/app/cells/decidim/wizard_step_form/wizard_aside.erb +++ b/decidim-core/app/cells/decidim/wizard_step_form/wizard_aside.erb @@ -8,7 +8,7 @@
      <% end %> -
      +
      <%= wizard_stepper %>
      diff --git a/decidim-core/app/commands/decidim/messaging/reply_to_conversation.rb b/decidim-core/app/commands/decidim/messaging/reply_to_conversation.rb index e42ae9e3abe1..658dc7982f8f 100644 --- a/decidim-core/app/commands/decidim/messaging/reply_to_conversation.rb +++ b/decidim-core/app/commands/decidim/messaging/reply_to_conversation.rb @@ -54,11 +54,13 @@ def notify_interlocutors notify(manager) do ConversationMailer.new_group_message(sender, manager, conversation, message, recipient).deliver_later end + Decidim::PushNotificationMessageSender.new.new_group_message(sender, manager, conversation, message, recipient).deliver end else notify(recipient) do ConversationMailer.new_message(sender, recipient, conversation, message).deliver_later end + Decidim::PushNotificationMessageSender.new.new_message(sender, recipient, conversation, message).deliver end end end @@ -68,6 +70,7 @@ def notify_comanagers notify(recipient) do ConversationMailer.comanagers_new_message(sender, recipient, conversation, message, form.context.current_user).deliver_later end + Decidim::PushNotificationMessageSender.new.comanagers_new_message(sender, recipient, conversation, message, form.context.current_user).deliver end end diff --git a/decidim-core/app/commands/decidim/messaging/start_conversation.rb b/decidim-core/app/commands/decidim/messaging/start_conversation.rb index 39fe9c5f6115..250f46600127 100644 --- a/decidim-core/app/commands/decidim/messaging/start_conversation.rb +++ b/decidim-core/app/commands/decidim/messaging/start_conversation.rb @@ -54,11 +54,13 @@ def notify_interlocutors notify(manager) do ConversationMailer.new_group_conversation(originator, manager, conversation, recipient).deliver_later end + Decidim::PushNotificationMessageSender.new.new_group_conversation(originator, manager, conversation, recipient).deliver end else notify(recipient) do ConversationMailer.new_conversation(originator, recipient, conversation).deliver_later end + Decidim::PushNotificationMessageSender.new.new_conversation(originator, recipient, conversation).deliver end end end @@ -68,6 +70,7 @@ def notify_comanagers notify(recipient) do ConversationMailer.comanagers_new_conversation(originator, recipient, conversation, form.context.current_user).deliver_later end + Decidim::PushNotificationMessageSender.new.comanagers_new_conversation(originator, recipient, conversation, form.context.current_user).deliver end end diff --git a/decidim-core/app/controllers/concerns/decidim/use_organization_time_zone.rb b/decidim-core/app/controllers/concerns/decidim/use_organization_time_zone.rb index 9e55cd792df2..1fd847746eaf 100644 --- a/decidim-core/app/controllers/concerns/decidim/use_organization_time_zone.rb +++ b/decidim-core/app/controllers/concerns/decidim/use_organization_time_zone.rb @@ -12,7 +12,7 @@ module UseOrganizationTimeZone around_action :use_organization_time_zone helper_method :organization_time_zone - # Executes a block of code in the context of the the organization's time zone + # Executes a block of code in the context of the organization's time zone # # &action - a block of code to be wrapped around the time zone # diff --git a/decidim-core/app/controllers/concerns/decidim/withdrawable.rb b/decidim-core/app/controllers/concerns/decidim/withdrawable.rb index 73ad64f7b5dd..7e8aaec0e8c2 100644 --- a/decidim-core/app/controllers/concerns/decidim/withdrawable.rb +++ b/decidim-core/app/controllers/concerns/decidim/withdrawable.rb @@ -3,7 +3,7 @@ require "active_support/concern" module Decidim - # A controller concern to enable withawing the controller resources. Only + # A controller concern to enable withdrawing the controller resources. Only # affects the UI, so the actual logic to withdraw the resource will still need # to be implemented. module Withdrawable diff --git a/decidim-core/app/controllers/decidim/endorsements_controller.rb b/decidim-core/app/controllers/decidim/endorsements_controller.rb index 472c9548f1c5..10f548904a34 100644 --- a/decidim-core/app/controllers/decidim/endorsements_controller.rb +++ b/decidim-core/app/controllers/decidim/endorsements_controller.rb @@ -48,7 +48,7 @@ def identities render :identities, layout: false end - # should be pubic in order to be visibe in NeedsPermission#permissions_context + # should be pubic in order to be visible in NeedsPermission#permissions_context def current_component resource.component end diff --git a/decidim-core/app/helpers/concerns/decidim/flash_helper_extensions.rb b/decidim-core/app/helpers/concerns/decidim/flash_helper_extensions.rb index 74e453e73170..d91ca4732f1c 100644 --- a/decidim-core/app/helpers/concerns/decidim/flash_helper_extensions.rb +++ b/decidim-core/app/helpers/concerns/decidim/flash_helper_extensions.rb @@ -43,7 +43,7 @@ def display_flash_messages(closable: true, key_matching: {}) # # @param value [String] - The flash message. # @param alert_class [String] - The foundation class of the alert message. - # @param closable [Boolean] - Wether the close icon is added. + # @param closable [Boolean] - Whether the close icon is added. # # @return [String] the HTML with the alert box def alert_box(value, alert_class, closable, opts = {}) diff --git a/decidim-core/app/helpers/decidim/check_boxes_tree_helper.rb b/decidim-core/app/helpers/decidim/check_boxes_tree_helper.rb index 406943dad4d9..13456dc2c7c1 100644 --- a/decidim-core/app/helpers/decidim/check_boxes_tree_helper.rb +++ b/decidim-core/app/helpers/decidim/check_boxes_tree_helper.rb @@ -3,6 +3,8 @@ module Decidim # This helper include some methods for rendering a checkboxes tree input. module CheckBoxesTreeHelper + include SanitizeHelper + # This method returns a hash with the options for the checkbox and its label # used in filters that uses checkboxes trees def check_boxes_tree_options(value, label, **options) @@ -49,23 +51,21 @@ def filter_origin_values end def filter_categories_values - organization = current_participatory_space.organization - sorted_main_categories = current_participatory_space.categories.first_class.includes(:subcategories).sort_by do |category| - [category.weight, translated_attribute(category.name, organization)] + [category.weight, decidim_escape_translated(category.name)] end categories_values = sorted_main_categories.flat_map do |category| sorted_descendant_categories = category.descendants.includes(:subcategories).sort_by do |subcategory| - [subcategory.weight, translated_attribute(subcategory.name, organization)] + [subcategory.weight, decidim_escape_translated(subcategory.name)] end subcategories = sorted_descendant_categories.flat_map do |subcategory| - TreePoint.new(subcategory.id.to_s, translated_attribute(subcategory.name, organization)) + TreePoint.new(subcategory.id.to_s, decidim_escape_translated(subcategory.name)) end TreeNode.new( - TreePoint.new(category.id.to_s, translated_attribute(category.name, organization)), + TreePoint.new(category.id.to_s, decidim_escape_translated(category.name)), subcategories ) end diff --git a/decidim-core/app/helpers/decidim/layout_helper.rb b/decidim-core/app/helpers/decidim/layout_helper.rb index a21377fd7c9d..458e494f6265 100644 --- a/decidim-core/app/helpers/decidim/layout_helper.rb +++ b/decidim-core/app/helpers/decidim/layout_helper.rb @@ -62,7 +62,7 @@ def icon(name, options = {}) href = Decidim.cors_enabled ? "" : asset_pack_path("media/images/remixicon.symbol.svg") content_tag :svg, html_properties do - content_tag :use, nil, "href" => "#{href}#ri-#{name}", :tabindex => -1 + content_tag :use, nil, "href" => "#{href}#ri-#{name}" end end diff --git a/decidim-core/app/helpers/decidim/modal_helper.rb b/decidim-core/app/helpers/decidim/modal_helper.rb index f57f58f3b5cb..bc44f2f0346d 100644 --- a/decidim-core/app/helpers/decidim/modal_helper.rb +++ b/decidim-core/app/helpers/decidim/modal_helper.rb @@ -8,7 +8,7 @@ module Decidim # you also can add your custom close button through data-dialog-close="" # # Options available: - # - id: String. Unique identificator for the dialog, if the page has distinct modal windows (default: "") + # - id: String. Unique identifier for the dialog, if the page has distinct modal windows (default: "") # - class: String. CSS classes for the modal content. # - closable: Boolean. Whether the modal can be closed or not (default: true) module ModalHelper diff --git a/decidim-core/app/mailers/decidim/messaging/conversation_mailer.rb b/decidim-core/app/mailers/decidim/messaging/conversation_mailer.rb index 2337447991de..809df5a22c87 100644 --- a/decidim-core/app/mailers/decidim/messaging/conversation_mailer.rb +++ b/decidim-core/app/mailers/decidim/messaging/conversation_mailer.rb @@ -5,74 +5,12 @@ module Messaging # A custom mailer for sending notifications to users when they receive # private messages class ConversationMailer < Decidim::ApplicationMailer - def new_conversation(originator, user, conversation) - notification_mail( - from: originator, - to: user, - conversation:, - message: conversation.messages.first.body, - action: "new_conversation" - ) - end - - def new_group_conversation(originator, manager, conversation, group) - notification_mail( - from: originator, - to: manager, - conversation:, - message: conversation.messages.first.body, - action: "new_group_conversation", - third_party: group - ) - end - - def comanagers_new_conversation(group, user, conversation, manager) - notification_mail( - from: group, - to: user, - conversation:, - message: conversation.messages.first.body, - action: "comanagers_new_conversation", - third_party: manager - ) - end - - def new_message(sender, user, conversation, message) - notification_mail( - from: sender, - to: user, - conversation:, - message: message.body, - action: "new_message" - ) - end - - def new_group_message(sender, user, conversation, message, group) - notification_mail( - from: sender, - to: user, - conversation:, - message: message.body, - action: "new_group_message", - third_party: group - ) - end - - def comanagers_new_message(sender, user, conversation, message, manager) - notification_mail( - from: sender, - to: user, - conversation:, - message: message.body, - action: "comanagers_new_message", - third_party: manager - ) - end + include HasConversations private # rubocop:disable Metrics/ParameterLists - def notification_mail(from:, to:, conversation:, action:, message: nil, third_party: nil) + def send_notification(from:, to:, conversation:, action:, message: nil, third_party: nil) with_user(to) do @organization = to.organization @conversation = conversation @@ -81,14 +19,7 @@ def notification_mail(from:, to:, conversation:, action:, message: nil, third_pa @third_party = third_party @message = message @host = @organization.host - - subject = I18n.t( - "conversation_mailer.#{action}.subject", - scope: "decidim.messaging", - sender: @sender.name, - manager: @third_party&.name, - group: @third_party&.name - ) + subject = get_subject(action:, sender: @sender, third_party: @third_party) mail(to: to.email, subject:) end diff --git a/decidim-core/app/models/decidim/area_type.rb b/decidim-core/app/models/decidim/area_type.rb index 56c171a56adb..66a251d3f846 100644 --- a/decidim-core/app/models/decidim/area_type.rb +++ b/decidim-core/app/models/decidim/area_type.rb @@ -2,7 +2,7 @@ module Decidim # Area types allows to use different types of areas in participatory space - # (terriotrial, sectorial, etc.) + # (territorial, sectorial, etc.) class AreaType < ApplicationRecord include Decidim::TranslatableResource include Decidim::Traceable diff --git a/decidim-core/app/models/decidim/authorization.rb b/decidim-core/app/models/decidim/authorization.rb index 57f21a4961f1..b7937496395b 100644 --- a/decidim-core/app/models/decidim/authorization.rb +++ b/decidim-core/app/models/decidim/authorization.rb @@ -101,7 +101,7 @@ def workflow_manifest @workflow_manifest ||= Decidim::Verifications.find_workflow_manifest(name) end - # Calculates when this authorization can be reseted, if desired. + # Calculates when this authorization can be reset, if desired. # # **time_between_renewals** is defined in `workflow_manifest.time_between_renewals` # defaults to 1 day diff --git a/decidim-core/app/models/decidim/newsletter.rb b/decidim-core/app/models/decidim/newsletter.rb index bf3eb04ff6fe..b497f027f49a 100644 --- a/decidim-core/app/models/decidim/newsletter.rb +++ b/decidim-core/app/models/decidim/newsletter.rb @@ -46,7 +46,7 @@ def sended_to_participants? extended_data["send_to_participants"] end - def sended_to_partipatory_spaces + def sent_to_participatory_spaces extended_data["participatory_space_types"] end diff --git a/decidim-core/app/models/decidim/push_notification_message.rb b/decidim-core/app/models/decidim/push_notification_message.rb new file mode 100644 index 000000000000..cbf9a82b2f0d --- /dev/null +++ b/decidim-core/app/models/decidim/push_notification_message.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +module Decidim + # A message from a conversation that will be sent as a push notification + class PushNotificationMessage + class InvalidActionError < StandardError; end + + include SanitizeHelper + + def initialize(recipient:, conversation:, message:) + @recipient = recipient + @conversation = conversation + @message = message + end + + attr_reader :recipient, :conversation, :message + + alias user recipient + + def body + decidim_escape_translated(message) + end + + def icon + organization.attached_uploader(:favicon).variant_url(:big, host: organization.host) + end + + def url + EngineRouter.new("decidim", {}).public_send(:conversation_path, host: organization.host, id: @conversation) + end + + private + + def organization + @organization ||= recipient.organization + end + end +end diff --git a/decidim-core/app/packs/src/decidim/a11y.js b/decidim-core/app/packs/src/decidim/a11y.js index 3efb945138c3..18ecfefa32f0 100644 --- a/decidim-core/app/packs/src/decidim/a11y.js +++ b/decidim-core/app/packs/src/decidim/a11y.js @@ -136,7 +136,7 @@ const createDialog = (component) => { enableAutoFocus: false, onOpen: (params, trigger) => { setFocusOnTitle(params); - window.focusGuard.trap(trigger); + window.focusGuard.trap(params, trigger); params.dispatchEvent(new CustomEvent("open.dialog")); }, onClose: (params) => { diff --git a/decidim-core/app/packs/src/decidim/data_consent/consent_manager.test.js b/decidim-core/app/packs/src/decidim/data_consent/consent_manager.test.js index d861614c7134..8d10b836bc08 100644 --- a/decidim-core/app/packs/src/decidim/data_consent/consent_manager.test.js +++ b/decidim-core/app/packs/src/decidim/data_consent/consent_manager.test.js @@ -75,7 +75,7 @@ describe("ConsentManager", () => {
@@ -119,7 +119,7 @@ describe("ConsentManager", () => {
@@ -139,7 +139,7 @@ describe("ConsentManager", () => {
@@ -159,7 +159,7 @@ describe("ConsentManager", () => {
diff --git a/decidim-core/app/packs/src/decidim/editor/extensions/indent/index.js b/decidim-core/app/packs/src/decidim/editor/extensions/indent/index.js index 138087aa8923..f18dcc9e25e6 100644 --- a/decidim-core/app/packs/src/decidim/editor/extensions/indent/index.js +++ b/decidim-core/app/packs/src/decidim/editor/extensions/indent/index.js @@ -13,7 +13,7 @@ const allowedNodeTypes = ["heading", "paragraph"]; const allowedNodeActive = (editor) => allowedNodeTypes.some((type) => editor.isActive(type)); /** - * Finds the closest allowed type node from the given position. Traversese the + * Finds the closest allowed type node from the given position. Traverses the * document depth upwards to search through all the node parents. * * @param {Object} position The position where to look for diff --git a/decidim-core/app/packs/src/decidim/editor/extensions/video_embed/index.js b/decidim-core/app/packs/src/decidim/editor/extensions/video_embed/index.js index 88b23e6ca258..eeede73c9902 100644 --- a/decidim-core/app/packs/src/decidim/editor/extensions/video_embed/index.js +++ b/decidim-core/app/packs/src/decidim/editor/extensions/video_embed/index.js @@ -9,7 +9,7 @@ const YOUTUBE_REGEX_GLOBAL = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu const VIMEO_REGEX = /^(https?:\/\/)?(www\.|player\.)?(vimeo\.com)(.+)?$/; const VIMEO_REGEX_GLOBAL = /^(https?:\/\/)?(www\.|player\.)?(vimeo\.com)(.+)?$/g; -const isValidYoutubeUrl = (url) => { +const isValidYouTubeUrl = (url) => { return url.match(YOUTUBE_REGEX); } @@ -17,7 +17,7 @@ const isValidVimeoUrl = (url) => { return url.match(VIMEO_REGEX); }; -const getEmbedUrlFromYoutubeUrl = (options) => { +const getEmbedUrlFromYouTubeUrl = (options) => { const embedUrl = "https://www.youtube-nocookie.com/embed/"; const { url } = options; @@ -74,8 +74,8 @@ const getEmbedUrlFromVimeoUrl = (options) => { const getEmbedUrlFromVideoUrl = (options) => { const { url } = options; - if (isValidYoutubeUrl(url)) { - return getEmbedUrlFromYoutubeUrl(options); + if (isValidYouTubeUrl(url)) { + return getEmbedUrlFromYouTubeUrl(options); } else if (isValidVimeoUrl(url)) { return getEmbedUrlFromVimeoUrl(options); } diff --git a/decidim-core/app/packs/src/decidim/editor/utilities/paste_transform.js b/decidim-core/app/packs/src/decidim/editor/utilities/paste_transform.js index 59b168809e40..28ff6720e6d2 100644 --- a/decidim-core/app/packs/src/decidim/editor/utilities/paste_transform.js +++ b/decidim-core/app/packs/src/decidim/editor/utilities/paste_transform.js @@ -40,7 +40,7 @@ const getMsoListStyle = (type, level, styleDefs) => { return Object.assign(typeStyle, levelStyle); }; -const converMsoListStyleToHtml = (listStyle) => { +const convertMsoListStyleToHtml = (listStyle) => { let tag = "ol", type = null; switch (listStyle["mso-level-number-format"]) { @@ -108,7 +108,7 @@ export const transformMsDesktop = (html) => { elements.forEach((paragraph) => { const { type: msoType, level } = detectMsoList(paragraph); const listStyle = getMsoListStyle(msoType, level, listStyles); - const { tag, type } = converMsoListStyleToHtml(listStyle); + const { tag, type } = convertMsoListStyleToHtml(listStyle); const li = document.createElement("li"); const pa = document.createElement("p"); diff --git a/decidim-core/app/packs/src/decidim/focus_guard.js b/decidim-core/app/packs/src/decidim/focus_guard.js index d341b1eace2e..1a2ece848623 100644 --- a/decidim-core/app/packs/src/decidim/focus_guard.js +++ b/decidim-core/app/packs/src/decidim/focus_guard.js @@ -1,5 +1,3 @@ -import { Keyboard } from "foundation-sites" - const focusGuardClass = "focusguard"; const focusableNodes = ["A", "IFRAME", "OBJECT", "EMBED"]; const focusableDisableableNodes = ["BUTTON", "INPUT", "TEXTAREA", "SELECT"]; @@ -8,21 +6,13 @@ export default class FocusGuard { constructor(container) { this.container = container; this.guardedElement = null; + this.triggerElement = null; } - trap(element) { - if (this.guardedElement) { - Keyboard.releaseFocus($(this.guardedElement)); - } - + trap(element, trigger) { this.enable(); this.guardedElement = element; - - // Call the release focus first so that we do not accidentally add the - // keyboard trap twice. Note that the Foundation methods expect the elements - // to be jQuery elements which is why we pass them through jQuery. - Keyboard.releaseFocus($(element)); - Keyboard.trapFocus($(element)); + this.triggerElement = trigger; } enable() { @@ -58,12 +48,11 @@ export default class FocusGuard { const guards = this.container.querySelectorAll(`:scope > .${focusGuardClass}`); guards.forEach((guard) => guard.remove()); - if (this.guardedElement) { - // Note that the Foundation methods expect the elements to be jQuery - // elements which is why we pass them through jQuery. - Keyboard.releaseFocus($(this.guardedElement)); - this.guardedElement.focus(); - this.guardedElement = null; + this.guardedElement = null; + + if (this.triggerElement) { + this.triggerElement.focus(); + this.triggerElement = null; } } @@ -89,7 +78,6 @@ export default class FocusGuard { let target = null; if (guard.dataset.position === "start") { - // Focus at the start guard, so focus the first focusable element after that for (let ind = 0; ind < visibleNodes.length; ind += 1) { if (!this.isFocusGuard(visibleNodes[ind]) && this.isFocusable(visibleNodes[ind])) { diff --git a/decidim-core/app/packs/src/decidim/index.js b/decidim-core/app/packs/src/decidim/index.js index bf3d9f5f3787..4d3a77fbce6b 100644 --- a/decidim-core/app/packs/src/decidim/index.js +++ b/decidim-core/app/packs/src/decidim/index.js @@ -9,6 +9,9 @@ import "core-js/stable"; import "regenerator-runtime/runtime"; import "jquery" +// REDESIGN_PENDING: deprecated +import "foundation-sites"; + // external deps that require initialization import Rails from "@rails/ujs" import svg4everybody from "svg4everybody" diff --git a/decidim-core/app/packs/src/decidim/input_character_counter.js b/decidim-core/app/packs/src/decidim/input_character_counter.js index af9c841b752a..221c22f27aa6 100644 --- a/decidim-core/app/packs/src/decidim/input_character_counter.js +++ b/decidim-core/app/packs/src/decidim/input_character_counter.js @@ -232,7 +232,7 @@ export default class InputCharacterCounter { } else if (this.maxCharacters - srLength === this.announceThreshold) { return this.announcedAt || currentLength; // The third branch checks that when deleting characters, we should - // announce the next threshold to get accurate annoucement. E.g. when we + // announce the next threshold to get accurate announcement. E.g. when we // have 750 characters left and the user deletes 100 characters at once, // we should announce "700 characters left" after that deletion. } else if (srLength < currentLength) { diff --git a/decidim-core/app/packs/src/decidim/tooltips.js b/decidim-core/app/packs/src/decidim/tooltips.js index 1fb0b840fd16..c817bbf000e8 100644 --- a/decidim-core/app/packs/src/decidim/tooltips.js +++ b/decidim-core/app/packs/src/decidim/tooltips.js @@ -19,7 +19,7 @@ const getAbsolutePosition = (node, relativeParent) => { let [pageX, pageY] = [window.pageXOffset, window.pageYOffset] if (relativeParent) { // in order to calculate the relative parent position, we reuse this function, - // using the parent regarding the window and substracting the topLeft corner (its relative position [0,0]) + // using the parent regarding the window and subtracting the topLeft corner (its relative position [0,0]) const { topLeft: [parentX, parentY] } = getAbsolutePosition(relativeParent); [pageX, pageY] = [pageX - parentX, pageY - parentY] } diff --git a/decidim-core/app/packs/src/decidim/vendor/modernizr.js b/decidim-core/app/packs/src/decidim/vendor/modernizr.js index cf65a63099b6..cc33992ce6cc 100644 --- a/decidim-core/app/packs/src/decidim/vendor/modernizr.js +++ b/decidim-core/app/packs/src/decidim/vendor/modernizr.js @@ -1,5 +1,5 @@ /* eslint-disable */ -/*! modernizr 3.3.1 (Custom Build) | MIT * +/*! modernizr 3.6.0 (Custom Build) | MIT * * https://modernizr.com/download/?-setclasses !*/ -!function(n,e,s){function o(n,e){return typeof n===e}function a(){var n,e,s,a,i,l,r;for(var c in f)if(f.hasOwnProperty(c)){if(n=[],e=f[c],e.name&&(n.push(e.name.toLowerCase()),e.options&&e.options.aliases&&e.options.aliases.length))for(s=0;s, nil] the result of the dispatch or nil if user or subscription are empty + def perform(notification, title = nil) return unless Rails.application.secrets.dig(:vapid, :enabled) + raise ArgumentError, "Need to provide a title if the notification is a PushNotificationMessage" if notification.is_a?(Decidim::PushNotificationMessage) && title.nil? + + user = notification.user - I18n.with_locale(notification.user.locale || notification.user.organization.default_locale) do - notification.user.notifications_subscriptions.values.map do |subscription| - message_params = notification_params(Decidim::PushNotificationPresenter.new(notification)) - payload = build_payload(message_params, subscription) + I18n.with_locale(user.locale || user.organization.default_locale) do + user.notifications_subscriptions.values.map do |subscription| + payload = build_payload(message_params(notification, title), subscription) # Capture webpush exceptions in order to avoid this call to be repeated by the background job runner # Webpush::Error class is the parent class of all defined errors begin @@ -36,9 +41,18 @@ def perform(notification) private - def notification_params(notification) + def message_params(notification, title = nil) + case notification + when Decidim::PushNotificationMessage + notification_params(notification, title) + else # when Decidim::Notification + notification_params(Decidim::PushNotificationPresenter.new(notification)) + end + end + + def notification_params(notification, title = nil) { - title: notification.title, + title: title.presence || notification.title, body: notification.body, icon: notification.icon, data: { url: notification.url } diff --git a/decidim-core/app/validators/passthru_validator.rb b/decidim-core/app/validators/passthru_validator.rb index 44ff99d5a0be..a54b4b8421cb 100644 --- a/decidim-core/app/validators/passthru_validator.rb +++ b/decidim-core/app/validators/passthru_validator.rb @@ -69,7 +69,7 @@ def validation_record(record) def validation_record_context(dummy, record) if dummy.is_a?(Decidim::Form) dummy.with_context( - current_organization: record.try(:current_organization) || record.try(:ganization), + current_organization: record.try(:current_organization) || record.try(:organization), current_participatory_space: record.try(:current_participatory_space) || record.try(:participatory_space), current_component: record.try(:current_component) || record.try(:component) ) diff --git a/decidim-core/app/views/decidim/shared/_extended_navigation_bar.html.erb b/decidim-core/app/views/decidim/shared/_extended_navigation_bar.html.erb index b1e39fffc6e9..c2b62a4eef2e 100644 --- a/decidim-core/app/views/decidim/shared/_extended_navigation_bar.html.erb +++ b/decidim-core/app/views/decidim/shared/_extended_navigation_bar.html.erb @@ -11,7 +11,7 @@
" id="process-nav-content" data-toggler=".is-active">
    <% items.each_with_index do |item, index| %> -
  • <%= "hide-for-medium" if index > max_items %>"> +
  • "> <%= link_to item[:url], class: "process-nav__link #{item[:active] ? "active" : nil}" do %> <%= item[:name] %> <% end %> @@ -20,7 +20,7 @@
<% if extra_items.any? %> -