From 9d79f09a2d38c87feb28725670d6cc1f55c22072 Mon Sep 17 00:00:00 2001 From: Alexandru Emil Lupu Date: Thu, 11 Jul 2024 13:06:39 +0300 Subject: [PATCH] Backport 'Refactor malformed titles in admin logs (part 2)' to v0.27 (#13085) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refactor malformed titles in admin logs (part 2) * Refactor admin logs * Component presenters * Various logs * More logs * Add logs for moderation * Fix spec * Apply suggestions from code review Co-authored-by: Andrés Pereira de Lucena * Add missing spec --------- Co-authored-by: Andrés Pereira de Lucena * Fix syntax errors in PR * Fix specs * Add specs * Fix failing spec --------- Co-authored-by: Andrés Pereira de Lucena --- .../manage_attachment_collections_examples.rb | 23 ++++++++-------- .../admin/test/manage_categories_examples.rb | 19 ++++++++------ .../admin/test/manage_moderations_examples.rb | 9 ------- .../admin_manage_moderated_users_spec.rb | 22 ++++++++++++++++ .../admin_manages_global_moderations_spec.rb | 12 +++++++++ .../admin_manages_help_sections_spec.rb | 3 +++ .../system/admin_manages_newsletters_spec.rb | 19 ++++++++------ ...in_manages_organization_area_types_spec.rb | 23 +++++++++------- .../admin_manages_organization_areas_spec.rb | 19 ++++++++------ ...n_manages_organization_scope_types_spec.rb | 23 +++++++++------- .../admin_manages_organization_scopes_spec.rb | 19 ++++++++------ .../system/admin_manages_organization_spec.rb | 6 ++++- .../spec/system/static_pages_spec.rb | 23 +++++++++------- .../manage_assembly_components_examples.rb | 26 ++++++++++++------- .../manage_assembly_private_users_examples.rb | 3 +++ .../manage_conference_components_examples.rb | 26 ++++++++++++------- .../admin_log/organization_presenter.rb | 2 +- ...dmin_manages_initiative_components_spec.rb | 25 +++++++++++------- .../admin_manages_initiatives_types_spec.rb | 26 ++++++++++++------- .../system/admin/update_initiative_spec.rb | 21 +++++++++++++++ ...cipatory_process_private_users_examples.rb | 3 +++ .../manage_process_components_examples.rb | 26 ++++++++++++------- 22 files changed, 245 insertions(+), 133 deletions(-) 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 dc5758d8ebbfb..d9594699d4ee0 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 @@ -2,6 +2,7 @@ shared_examples "manage attachment collections examples" do let!(:attachment_collection) { create(:attachment_collection, collection_for: collection_for) } + let(:attributes) { attributes_for(:attachment_collection) } before do visit current_path @@ -30,17 +31,13 @@ fill_in_i18n( :attachment_collection_name, "#attachment_collection-name-tabs", - en: "Application forms", - es: "Formularios de solicitud", - ca: "Formularis de sol·licitud" + **attributes[:name].except("machine_translations") ) fill_in_i18n( :attachment_collection_description, "#attachment_collection-description-tabs", - en: "Contains the application forms", - es: "Contiene los formularios de solicitud", - ca: "Conté els formularis de sol·licitud" + **attributes[:description].except("machine_translations") ) find("*[type=submit]").click @@ -49,8 +46,11 @@ expect(page).to have_admin_callout("successfully") within "#attachment_collections table" do - expect(page).to have_link("Application forms") + expect(page).to have_content(translated(attributes[:name])) end + + visit decidim_admin.root_path + expect(page).to have_content("created the #{translated(attributes[:name])} attachment collection") end it "can update an attachment collection" do @@ -64,9 +64,7 @@ fill_in_i18n( :attachment_collection_name, "#attachment_collection-name-tabs", - en: "Latest application forms", - es: "Últimos formularios de solicitud", - ca: "Últims formularis de sol·licitud" + **attributes[:name].except("machine_translations") ) find("*[type=submit]").click @@ -75,8 +73,11 @@ expect(page).to have_admin_callout("successfully") within "#attachment_collections table" do - expect(page).to have_link("Latest application forms") + expect(page).to have_content(translated(attributes[:name])) end + + visit decidim_admin.root_path + expect(page).to have_content("updated the #{translated(attributes[:name])} attachment collection") end context "when deleting a attachment collection" do 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 10b5d9495eee0..7e855654caa04 100644 --- a/decidim-admin/lib/decidim/admin/test/manage_categories_examples.rb +++ b/decidim-admin/lib/decidim/admin/test/manage_categories_examples.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true shared_examples "manage categories examples" do + let(:attributes) { attributes_for(:category) } it "lists all the categories for the process" do within "#categories table" do expect(page).to have_content(translated(category.name, locale: :en)) @@ -25,9 +26,7 @@ fill_in_i18n( :category_name, "#category-name-tabs", - en: "My category", - es: "Mi categoría", - ca: "La meva categoria" + **attributes[:name].except("machine_translations") ) find("*[type=submit]").click @@ -36,8 +35,11 @@ expect(page).to have_admin_callout("successfully") within "#categories table" do - expect(page).to have_content("My category") + expect(page).to have_content(translated(attributes[:name])) end + + visit decidim_admin.root_path + expect(page).to have_content("added the #{translated(attributes[:name])} category to the") end it "updates a category" do @@ -51,9 +53,7 @@ fill_in_i18n( :category_name, "#category-name-tabs", - en: "My new name", - es: "Mi nuevo nombre", - ca: "El meu nou nom" + **attributes[:name].except("machine_translations") ) find("*[type=submit]").click @@ -62,8 +62,11 @@ expect(page).to have_admin_callout("successfully") within "#categories table" do - expect(page).to have_content("My new name") + expect(page).to have_content(translated(attributes[:name])) end + + visit decidim_admin.root_path + expect(page).to have_content("updated the #{translated(attributes[:name])} category in the") end context "when deleting a category" do 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 90362d13085fb..4512623fcefe6 100644 --- a/decidim-admin/lib/decidim/admin/test/manage_moderations_examples.rb +++ b/decidim-admin/lib/decidim/admin/test/manage_moderations_examples.rb @@ -77,15 +77,6 @@ expect(page).to have_admin_callout("Resource successfully unreported") end - it "user can hide a resource" do - within "tr[data-id=\"#{moderation.id}\"]" do - click_link "Hide" - end - - expect(page).to have_admin_callout("Resource successfully hidden") - expect(page).to have_no_content(moderation.reportable.reported_content_url) - end - it "user can sort by report count" do moderations.each_with_index { |moderation, index| moderation.update(report_count: index + 1) } moderations_ordered_by_report_count_asc = moderations.sort_by(&:report_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 73c070d192202..24851c9284772 100644 --- a/decidim-admin/spec/system/admin_manage_moderated_users_spec.rb +++ b/decidim-admin/spec/system/admin_manage_moderated_users_spec.rb @@ -176,5 +176,27 @@ it_behaves_like "a paginated collection", url: true end + + context "when the user is blocked" do + let!(:first_user) { create(:user, :confirmed, organization: organization) } + + before do + visit decidim_admin.moderated_users_path + end + + it "displays the proper log" do + within find("tr", text: first_user.name) do + click_link "Block" + end + fill_in :block_user_justification, with: "This user is a spammer" * 2 # to have at least 15 chars + + click_on I18n.t("decidim.admin.block_user.new.action") + + expect(first_user.reload).to be_blocked + + visit decidim_admin.root_path + expect(page).to have_content("blocked user") + end + end end end diff --git a/decidim-admin/spec/system/admin_manages_global_moderations_spec.rb b/decidim-admin/spec/system/admin_manages_global_moderations_spec.rb index 905f56c42fda2..4740029a57411 100644 --- a/decidim-admin/spec/system/admin_manages_global_moderations_spec.rb +++ b/decidim-admin/spec/system/admin_manages_global_moderations_spec.rb @@ -28,6 +28,18 @@ it_behaves_like "manage moderations" do let(:moderations_link_text) { "Global moderations" } + + it "user can hide a resource" do + within "tr[data-id=\"#{moderation.id}\"]" do + click_link "Hide" + end + + expect(page).to have_admin_callout("Resource successfully hidden") + expect(page).to have_no_content(moderation.reportable.reported_content_url) + + visit decidim_admin.root_path + expect(page).to have_content("hid a resource of type") + end end it_behaves_like "sorted moderations" do 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 ecbd0121b029d..daddca47138ce 100644 --- a/decidim-admin/spec/system/admin_manages_help_sections_spec.rb +++ b/decidim-admin/spec/system/admin_manages_help_sections_spec.rb @@ -30,6 +30,9 @@ help_content = Decidim::ContextualHelpSection.find_content(organization, :participatory_processes) expect(help_content).to include("en" => "

Well hello!

") + + visit decidim_admin.root_path + expect(page).to have_content("updated the Participatory processes help section") end it "destroys the section when it is empty" do diff --git a/decidim-admin/spec/system/admin_manages_newsletters_spec.rb b/decidim-admin/spec/system/admin_manages_newsletters_spec.rb index 7c6812b2ca86c..03e8310c1b5cc 100644 --- a/decidim-admin/spec/system/admin_manages_newsletters_spec.rb +++ b/decidim-admin/spec/system/admin_manages_newsletters_spec.rb @@ -7,6 +7,7 @@ describe "Admin manages newsletters", type: :system do let(:organization) { create(:organization) } + let!(:attributes) { attributes_for(:newsletter, organization: organization) } let(:user) { create(:user, :admin, :confirmed, name: "Sarah Kerrigan", organization: organization) } let!(:deliverable_users) { create_list(:user, 5, :confirmed, newsletter_notifications_at: Time.current, organization: organization) } @@ -43,9 +44,7 @@ fill_in_i18n( :newsletter_subject, "#newsletter-subject-tabs", - en: "A fancy newsletter for %{name}", - es: "Un correo electrónico muy chulo para %{name}", - ca: "Un correu electrònic flipant per a %{name}" + **attributes[:subject].except("machine_translations") ) fill_in_i18n_editor( @@ -84,7 +83,10 @@ end expect(page).to have_content("Preview") - expect(page).to have_content("A fancy newsletter for #{user.name}") + expect(page).to have_content(translated(attributes[:subject])) + + visit decidim_admin.root_path + expect(page).to have_content("created the #{translated(attributes[:subject])} newsletter") end end @@ -128,9 +130,7 @@ fill_in_i18n( :newsletter_subject, "#newsletter-subject-tabs", - en: "A fancy newsletter", - es: "Un correo electrónico muy chulo", - ca: "Un correu electrònic flipant" + **attributes[:subject].except("machine_translations") ) fill_in_i18n_editor( @@ -145,7 +145,10 @@ end expect(page).to have_content("Preview") - expect(page).to have_content("A fancy newsletter") + expect(page).to have_content(translated(attributes[:subject])) + + visit decidim_admin.root_path + expect(page).to have_content("updated the #{translated(attributes[:subject])} newsletter") end end 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 e5fbfbf80b5e5..1ede90110e274 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 @@ -5,6 +5,7 @@ describe "Admin manages area types", type: :system do let(:admin) { create :user, :admin, :confirmed } let(:organization) { admin.organization } + let(:attributes) { attributes_for(:area_type) } before do switch_to_host(organization.host) @@ -23,17 +24,13 @@ fill_in_i18n( :area_type_name, "#area_type-name-tabs", - en: "Sectorial en", - es: "Sectorial es", - ca: "Sectorial ca" + **attributes[:name].except("machine_translations") ) fill_in_i18n( :area_type_plural, "#area_type-plural-tabs", - en: "Sectorials en", - es: "Sectoriales es", - ca: "Sectorials ca" + **attributes[:plural].except("machine_translations") ) find("*[type=submit]").click @@ -42,8 +39,11 @@ expect(page).to have_admin_callout("successfully") within "table" do - expect(page).to have_content("Sectorial en") + expect(page).to have_content(translated(attributes[:name])) end + + visit decidim_admin.root_path + expect(page).to have_content("created the #{translated(attributes[:name])} area type") end context "with existing area_types" do @@ -68,13 +68,13 @@ fill_in_i18n( :area_type_name, "#area_type-name-tabs", - en: "Not Sectorial en" + **attributes[:name].except("machine_translations") ) fill_in_i18n( :area_type_plural, "#area_type-plural-tabs", - en: "This is the new pluarl" + **attributes[:plural].except("machine_translations") ) find("*[type=submit]").click end @@ -82,8 +82,11 @@ expect(page).to have_admin_callout("successfully") within "table" do - expect(page).to have_content("Not Sectorial en") + expect(page).to have_content(translated(attributes[:name])) end + + visit decidim_admin.root_path + expect(page).to have_content("updated the #{translated(attributes[:name])} area type") end it "can delete them" do 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 8f5a572d567f0..085c42a6da0e9 100644 --- a/decidim-admin/spec/system/admin_manages_organization_areas_spec.rb +++ b/decidim-admin/spec/system/admin_manages_organization_areas_spec.rb @@ -7,6 +7,7 @@ let(:admin) { create :user, :admin, :confirmed } let(:organization) { admin.organization } + let(:attributes) { attributes_for(:area) } before do switch_to_host(organization.host) @@ -26,9 +27,7 @@ click_link "Add" within ".new_area" do - fill_in_i18n :area_name, "#area-name-tabs", en: "My area", - es: "Mi area", - ca: "La meva area" + fill_in_i18n :area_name, "#area-name-tabs", **attributes[:name].except("machine_translations") select area_type.name["en"], from: :area_area_type_id find("*[type=submit]").click @@ -37,8 +36,11 @@ expect(page).to have_admin_callout("successfully") within "table" do - expect(page).to have_content("My area") + expect(page).to have_content(translated(attributes[:name])) end + + visit decidim_admin.root_path + expect(page).to have_content("created the #{translated(attributes[:name])} area") end context "with existing areas" do @@ -61,17 +63,18 @@ end within ".edit_area" do - fill_in_i18n :area_name, "#area-name-tabs", en: "Another area", - es: "Otra area", - ca: "Una altra area" + fill_in_i18n :area_name, "#area-name-tabs", **attributes[:name].except("machine_translations") find("*[type=submit]").click end expect(page).to have_admin_callout("successfully") within "table" do - expect(page).to have_content("Another area") + expect(page).to have_content(translated(attributes[:name])) end + + visit decidim_admin.root_path + expect(page).to have_content("updated the #{translated(attributes[:name])} area") end it "can delete them" do 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 199cfd934ade3..193363ee9637f 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 @@ -5,6 +5,7 @@ describe "Admin manages scope types", type: :system do let(:admin) { create :user, :admin, :confirmed } let(:organization) { admin.organization } + let!(:attributes) { attributes_for(:scope_type) } before do switch_to_host(organization.host) @@ -23,17 +24,13 @@ fill_in_i18n( :scope_type_name, "#scope_type-name-tabs", - en: "Territorial en", - es: "Territorial es", - ca: "Territorial ca" + **attributes[:name].except("machine_translations") ) fill_in_i18n( :scope_type_plural, "#scope_type-plural-tabs", - en: "Territorials en", - es: "Territoriales es", - ca: "Territorials ca" + **attributes[:plural].except("machine_translations") ) find("*[type=submit]").click @@ -42,8 +39,11 @@ expect(page).to have_admin_callout("successfully") within "table" do - expect(page).to have_content("Territorial en") + expect(page).to have_content(translated(attributes[:name])) end + + visit decidim_admin.root_path + expect(page).to have_content("created the #{translated(attributes[:name])} scope type") end context "with existing scope_types" do @@ -68,13 +68,13 @@ fill_in_i18n( :scope_type_name, "#scope_type-name-tabs", - en: "Not Territorial en" + **attributes[:name].except("machine_translations") ) fill_in_i18n( :scope_type_plural, "#scope_type-plural-tabs", - en: "This is the new pluarl" + **attributes[:plural].except("machine_translations") ) find("*[type=submit]").click end @@ -82,8 +82,11 @@ expect(page).to have_admin_callout("successfully") within "table" do - expect(page).to have_content("Not Territorial en") + expect(page).to have_content(translated(attributes[:name])) end + + visit decidim_admin.root_path + expect(page).to have_content("updated the #{translated(attributes[:name])} scope type") end it "can delete them" do 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 f7981b1fa11cf..b5a354439c90b 100644 --- a/decidim-admin/spec/system/admin_manages_organization_scopes_spec.rb +++ b/decidim-admin/spec/system/admin_manages_organization_scopes_spec.rb @@ -7,6 +7,7 @@ let(:admin) { create :user, :admin, :confirmed } let(:organization) { admin.organization } + let!(:attributes) { attributes_for(:scope) } before do switch_to_host(organization.host) @@ -26,9 +27,7 @@ click_link "Add" within ".new_scope" do - fill_in_i18n :scope_name, "#scope-name-tabs", en: "My nice district", - es: "Mi lindo distrito", - ca: "El meu bonic barri" + fill_in_i18n :scope_name, "#scope-name-tabs", **attributes[:name].except("machine_translations") fill_in "Code", with: "MY-DISTRICT" select scope_type.name["en"], from: :scope_scope_type_id @@ -38,8 +37,11 @@ expect(page).to have_admin_callout("successfully") within "table" do - expect(page).to have_content("My nice district") + expect(page).to have_content(translated(attributes[:name])) end + + visit decidim_admin.root_path + expect(page).to have_content("created the #{translated(attributes[:name])} scope") end context "with existing scopes" do @@ -55,17 +57,18 @@ end within ".edit_scope" do - fill_in_i18n :scope_name, "#scope-name-tabs", en: "Another district", - es: "Otro distrito", - ca: "Un altre districte" + fill_in_i18n :scope_name, "#scope-name-tabs", **attributes[:name].except("machine_translations") find("*[type=submit]").click end expect(page).to have_admin_callout("successfully") within "table" do - expect(page).to have_content("Another district") + expect(page).to have_content(translated(attributes[:name])) end + + visit decidim_admin.root_path + expect(page).to have_content("updated the #{translated(attributes[:name])} scope") end it "can delete them" do diff --git a/decidim-admin/spec/system/admin_manages_organization_spec.rb b/decidim-admin/spec/system/admin_manages_organization_spec.rb index 1789c1b755ff4..0c821fadffe43 100644 --- a/decidim-admin/spec/system/admin_manages_organization_spec.rb +++ b/decidim-admin/spec/system/admin_manages_organization_spec.rb @@ -6,6 +6,7 @@ include ActionView::Helpers::SanitizeHelper let(:organization) { create(:organization) } + let(:attributes) { attributes_for(:organization) } let(:user) { create(:user, :admin, :confirmed, organization: organization) } before do @@ -17,7 +18,7 @@ it "updates the values from the form" do visit decidim_admin.edit_organization_path - fill_in "Name", with: "My super-uber organization" + fill_in :organization_name, with: attributes[:name] %w(X Facebook Instagram YouTube GitHub).each do |network| within "#organization_social_handlers" do @@ -38,6 +39,9 @@ click_button "Update" expect(page).to have_content("updated successfully") + + visit decidim_admin.root_path + expect(page).to have_content("updated the organization settings") end it "marks the comments_max_length as required" do diff --git a/decidim-admin/spec/system/static_pages_spec.rb b/decidim-admin/spec/system/static_pages_spec.rb index 81805ef1b2aa4..4e2493bf12e16 100644 --- a/decidim-admin/spec/system/static_pages_spec.rb +++ b/decidim-admin/spec/system/static_pages_spec.rb @@ -137,6 +137,7 @@ describe "Managing pages" do let!(:topic) { create(:static_page_topic, organization: organization) } + let(:attributes) { attributes_for(:static_page) } before do login_as admin, scope: :user @@ -163,17 +164,13 @@ fill_in_i18n( :static_page_title, "#static_page-title-tabs", - en: "Welcome to Decidim", - es: "Te damos la bienvendida a Decidim", - ca: "Et donem la benvinguda a Decidim" + **attributes[:title].except("machine_translations") ) fill_in_i18n_editor( :static_page_content, "#static_page-content-tabs", - en: "

Some HTML content

", - es: "

Contenido HTML

", - ca: "

Contingut HTML

" + **attributes[:content].except("machine_translations") ) select topic.title[I18n.locale.to_s], from: "Topic" @@ -183,8 +180,11 @@ expect(page).to have_admin_callout("successfully") within find(".card", text: topic.title[I18n.locale.to_s]) do - expect(page).to have_css("tr", text: "Welcome to Decidim") + expect(page).to have_css("tr", text: translated(attributes[:title])) end + + visit decidim_admin.root_path + expect(page).to have_content("created the #{translated(attributes[:title])} static page") end context "with existing pages" do @@ -214,12 +214,12 @@ fill_in_i18n( :static_page_title, "#static_page-title-tabs", - en: "Not welcomed anymore" + **attributes[:title].except("machine_translations") ) fill_in_i18n_editor( :static_page_content, "#static_page-content-tabs", - en: "This is the new content" + **attributes[:content].except("machine_translations") ) select topic.title[I18n.locale.to_s], from: "Topic" find("*[type=submit]").click @@ -228,8 +228,11 @@ expect(page).to have_admin_callout("successfully") within find(".card", text: topic.title[I18n.locale.to_s]) do - expect(page).to have_css("tr", text: "Not welcomed anymore") + expect(page).to have_css("tr", text: translated(attributes[:title])) end + + visit decidim_admin.root_path + expect(page).to have_content("updated the #{translated(attributes[:title])} static page") end it "can delete them" do diff --git a/decidim-assemblies/spec/shared/manage_assembly_components_examples.rb b/decidim-assemblies/spec/shared/manage_assembly_components_examples.rb index c8b2e9a5aa592..a05220fc091df 100644 --- a/decidim-assemblies/spec/shared/manage_assembly_components_examples.rb +++ b/decidim-assemblies/spec/shared/manage_assembly_components_examples.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true shared_examples "manage assembly components" do + let!(:attributes) { attributes_for(:component, participatory_space: assembly) } + before do switch_to_host(organization.host) login_as user, scope: :user @@ -20,9 +22,7 @@ fill_in_i18n( :component_name, "#component-name-tabs", - en: "My component", - ca: "La meva funcionalitat", - es: "Mi funcionalitat" + **attributes[:name].except("machine_translations") ) within ".global-settings" do @@ -49,12 +49,17 @@ it "is successfully created" do expect(page).to have_admin_callout("successfully") - expect(page).to have_content("My component") + expect(page).to have_content(translated(attributes[:name])) + end + + it "has a successful admin log" do + visit decidim_admin.root_path + expect(page).to have_content("created #{translated(attributes[:name])} in #{translated(assembly.title)}") end context "and then edit it" do before do - within find("tr", text: "My component") do + within "tr", text: translated(attributes[:name]) do click_link "Configure" end end @@ -103,9 +108,7 @@ fill_in_i18n( :component_name, "#component-name-tabs", - en: "My updated component", - ca: "La meva funcionalitat actualitzada", - es: "Mi funcionalidad actualizada" + **attributes[:name].except("machine_translations") ) within ".global-settings" do @@ -120,9 +123,9 @@ end expect(page).to have_admin_callout("successfully") - expect(page).to have_content("My updated component") + expect(page).to have_content(translated(attributes[:name])) - within find("tr", text: "My updated component") do + within "tr", text: translated(attributes[:name]) do click_link "Configure" end @@ -133,6 +136,9 @@ within ".default-step-settings" do expect(all("input[type=checkbox]").first).to be_checked end + + visit decidim_admin.root_path + expect(page).to have_content("updated #{translated(attributes[:name])} in #{translated(assembly.title)}") end 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 756a7b4a14910..4a0b109431afe 100644 --- a/decidim-assemblies/spec/shared/manage_assembly_private_users_examples.rb +++ b/decidim-assemblies/spec/shared/manage_assembly_private_users_examples.rb @@ -33,6 +33,9 @@ within "#private_users table" do expect(page).to have_content(other_user.email) end + + visit decidim_admin.root_path + expect(page).to have_content("invited #{other_user.name} to be a private participant") end describe "when import a batch of private users from csv" do diff --git a/decidim-conferences/spec/shared/manage_conference_components_examples.rb b/decidim-conferences/spec/shared/manage_conference_components_examples.rb index 80ad3d9b91280..3ae1bd8acc185 100644 --- a/decidim-conferences/spec/shared/manage_conference_components_examples.rb +++ b/decidim-conferences/spec/shared/manage_conference_components_examples.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true shared_examples "manage conference components" do + let!(:attributes) { attributes_for(:component, participatory_space: conference) } + before do switch_to_host(organization.host) login_as user, scope: :user @@ -20,9 +22,7 @@ fill_in_i18n( :component_name, "#component-name-tabs", - en: "My component", - ca: "La meva funcionalitat", - es: "Mi funcionalitat" + **attributes[:name].except("machine_translations") ) within ".global-settings" do @@ -49,12 +49,17 @@ it "is successfully created" do expect(page).to have_admin_callout("successfully") - expect(page).to have_content("My component") + expect(page).to have_content(translated(attributes[:name])) + end + + it "has a successful admin log" do + visit decidim_admin.root_path + expect(page).to have_content("created #{translated(attributes[:name])} in #{translated(conference.title)}") end context "and then edit it" do before do - within find("tr", text: "My component") do + within "tr", text: translated(attributes[:name]) do click_link "Configure" end end @@ -103,9 +108,7 @@ fill_in_i18n( :component_name, "#component-name-tabs", - en: "My updated component", - ca: "La meva funcionalitat actualitzada", - es: "Mi funcionalidad actualizada" + **attributes[:name].except("machine_translations") ) within ".global-settings" do @@ -120,9 +123,9 @@ end expect(page).to have_admin_callout("successfully") - expect(page).to have_content("My updated component") + expect(page).to have_content(translated(attributes[:name])) - within find("tr", text: "My updated component") do + within "tr", text: translated(attributes[:name]) do click_link "Configure" end @@ -133,6 +136,9 @@ within ".default-step-settings" do expect(all("input[type=checkbox]").first).to be_checked end + + visit decidim_admin.root_path + expect(page).to have_content("updated #{translated(attributes[:name])} in #{translated(conference.title)}") end end diff --git a/decidim-core/app/presenters/decidim/admin_log/organization_presenter.rb b/decidim-core/app/presenters/decidim/admin_log/organization_presenter.rb index 25b1b00cf96c7..6707058b49442 100644 --- a/decidim-core/app/presenters/decidim/admin_log/organization_presenter.rb +++ b/decidim-core/app/presenters/decidim/admin_log/organization_presenter.rb @@ -26,7 +26,7 @@ def diff_fields_mapping def settings_attributes_mapping { - name: :string, + name: :i18n, default_locale: :locale, reference_prefix: :string, twitter_handler: :string, diff --git a/decidim-initiatives/spec/system/admin/admin_manages_initiative_components_spec.rb b/decidim-initiatives/spec/system/admin/admin_manages_initiative_components_spec.rb index bc95d5accb6bf..3f80717efd0a2 100644 --- a/decidim-initiatives/spec/system/admin/admin_manages_initiative_components_spec.rb +++ b/decidim-initiatives/spec/system/admin/admin_manages_initiative_components_spec.rb @@ -7,6 +7,7 @@ let(:user) { create(:user, :admin, :confirmed, organization: organization) } let!(:initiative) { create(:initiative, organization: organization) } + let!(:attributes) { attributes_for(:component, participatory_space: initiative) } before do switch_to_host(organization.host) @@ -27,9 +28,7 @@ fill_in_i18n( :component_name, "#component-name-tabs", - en: "My component", - ca: "El meu component", - es: "Mi componente" + **attributes[:name].except("machine_translations") ) within ".global-settings" do @@ -59,12 +58,17 @@ expect(page).to have_content("successfully") end - expect(page).to have_content("My component") + expect(page).to have_content(translated(attributes[:name])) + end + + it "has a successful admin log" do + visit decidim_admin.root_path + expect(page).to have_content("created #{translated(attributes[:name])} in #{translated(initiative.title)}") end context "and then edit it" do before do - within find("tr", text: "My component") do + within "tr", text: translated(attributes[:name]) do page.find(".action-icon--configure").click end end @@ -115,9 +119,7 @@ fill_in_i18n( :component_name, "#component-name-tabs", - en: "My updated component", - ca: "El meu component actualitzat", - es: "Mi componente actualizado" + **attributes[:name].except("machine_translations") ) within ".global-settings" do @@ -135,9 +137,9 @@ expect(page).to have_content("successfully") end - expect(page).to have_content("My updated component") + expect(page).to have_content(translated(attributes[:name])) - within find("tr", text: "My updated component") do + within "tr", text: translated(attributes[:name]) do page.find(".action-icon--configure").click end @@ -148,6 +150,9 @@ within ".default-step-settings" do expect(all("input[type=checkbox]").first).to be_checked end + + visit decidim_admin.root_path + expect(page).to have_content("updated #{translated(attributes[:name])} in #{translated(initiative.title)}") end end diff --git a/decidim-initiatives/spec/system/admin/admin_manages_initiatives_types_spec.rb b/decidim-initiatives/spec/system/admin/admin_manages_initiatives_types_spec.rb index 75a65894fd5fe..55f5a7f33a542 100644 --- a/decidim-initiatives/spec/system/admin/admin_manages_initiatives_types_spec.rb +++ b/decidim-initiatives/spec/system/admin/admin_manages_initiatives_types_spec.rb @@ -6,6 +6,7 @@ let(:organization) { create(:organization) } let(:user) { create(:user, :admin, :confirmed, organization: organization) } let!(:initiatives_type) { create(:initiatives_type, organization: organization) } + let(:attributes) { attributes_for(:initiatives_type) } before do switch_to_host(organization.host) @@ -26,13 +27,13 @@ fill_in_i18n( :initiatives_type_title, "#initiatives_type-title-tabs", - en: "My initiative type" + **attributes[:title].except("machine_translations") ) fill_in_i18n_editor( :initiatives_type_description, "#initiatives_type-description-tabs", - en: "A longer description" + **attributes[:description].except("machine_translations") ) select("Online", from: "Signature type") @@ -41,9 +42,10 @@ click_button "Create" - within ".callout-wrapper" do - expect(page).to have_content("A new initiative type has been successfully created") - end + expect(page).to have_admin_callout("A new initiative type has been successfully created") + + visit decidim_admin.root_path + expect(page).to have_content("created the #{translated(attributes[:title])} initiatives type") end end @@ -56,7 +58,12 @@ fill_in_i18n( :initiatives_type_title, "#initiatives_type-title-tabs", - en: "My updated initiative type" + **attributes[:title].except("machine_translations") + ) + fill_in_i18n_editor( + :initiatives_type_description, + "#initiatives_type-description-tabs", + **attributes[:description].except("machine_translations") ) select("Mixed", from: "Signature type") @@ -68,9 +75,10 @@ click_button "Update" - within ".callout-wrapper" do - expect(page).to have_content("The initiative type has been successfully updated") - end + expect(page).to have_admin_callout("The initiative type has been successfully updated") + + visit decidim_admin.root_path + expect(page).to have_content("updated the #{translated(attributes[:title])} initiatives type") end end diff --git a/decidim-initiatives/spec/system/admin/update_initiative_spec.rb b/decidim-initiatives/spec/system/admin/update_initiative_spec.rb index 5d9cb554b8016..49470d2165351 100644 --- a/decidim-initiatives/spec/system/admin/update_initiative_spec.rb +++ b/decidim-initiatives/spec/system/admin/update_initiative_spec.rb @@ -15,6 +15,8 @@ def submit_and_validate context "when initiative update" do context "and user is admin" do + let(:attributes) { attributes_for(:initiative, organization: organization) } + before do switch_to_host(organization.host) login_as user, scope: :user @@ -29,6 +31,25 @@ def submit_and_validate submit_and_validate end + it "updates the initiative" do + page.find(".action-icon--edit").click + + fill_in_i18n( + :initiative_title, + "#initiative-title-tabs", + **attributes[:title].except("machine_translations") + ) + fill_in_i18n_editor( + :initiative_description, + "#initiative-description-tabs", + **attributes[:description].except("machine_translations") + ) + submit_and_validate + + visit decidim_admin.root_path + expect(page).to have_content("updated the #{translated(attributes[:title])} initiative") + end + context "when initiative is in created state" do before do initiative.created! diff --git a/decidim-participatory_processes/spec/shared/manage_participatory_process_private_users_examples.rb b/decidim-participatory_processes/spec/shared/manage_participatory_process_private_users_examples.rb index 268d1cbf84350..7564d6966a26a 100644 --- a/decidim-participatory_processes/spec/shared/manage_participatory_process_private_users_examples.rb +++ b/decidim-participatory_processes/spec/shared/manage_participatory_process_private_users_examples.rb @@ -33,6 +33,9 @@ within "#private_users table" do expect(page).to have_content(other_user.email) end + + visit decidim_admin.root_path + expect(page).to have_content("invited #{other_user.name} to be a private participant") end describe "when import a batch of private users from csv" do diff --git a/decidim-participatory_processes/spec/shared/manage_process_components_examples.rb b/decidim-participatory_processes/spec/shared/manage_process_components_examples.rb index 8901da23e0dc7..97dfa8e3b6c6f 100644 --- a/decidim-participatory_processes/spec/shared/manage_process_components_examples.rb +++ b/decidim-participatory_processes/spec/shared/manage_process_components_examples.rb @@ -4,6 +4,8 @@ let!(:participatory_process) do create(:participatory_process, :with_steps, organization: organization) end + let!(:attributes) { attributes_for(:component, participatory_space: participatory_process) } + let(:step_id) { participatory_process.steps.first.id } before do @@ -30,9 +32,7 @@ fill_in_i18n( :component_name, "#component-name-tabs", - en: "My component", - ca: "La meva funcionalitat", - es: "Mi funcionalitat" + **attributes[:name].except("machine_translations") ) within ".global-settings" do @@ -59,12 +59,17 @@ it "is successfully created" do expect(page).to have_admin_callout("successfully") - expect(page).to have_content("My component") + expect(page).to have_content(translated(attributes[:name])) + end + + it "has a successful admin log" do + visit decidim_admin.root_path + expect(page).to have_content("created #{translated(attributes[:name])} in #{translated(participatory_process.title)}") end context "and then edit it" do before do - within find("tr", text: "My component") do + within "tr", text: translated(attributes[:name]) do click_link "Configure" end end @@ -194,9 +199,7 @@ fill_in_i18n( :component_name, "#component-name-tabs", - en: "My updated component", - ca: "La meva funcionalitat actualitzada", - es: "Mi funcionalidad actualizada" + **attributes[:name].except("machine_translations") ) within ".global-settings" do @@ -211,9 +214,9 @@ end expect(page).to have_admin_callout("successfully") - expect(page).to have_content("My updated component") + expect(page).to have_content(translated(attributes[:name])) - within find("tr", text: "My updated component") do + within "tr", text: translated(attributes[:name]) do click_link "Configure" end @@ -224,6 +227,9 @@ within ".step-settings" do expect(all("input[type=checkbox]").first).to be_checked end + + visit decidim_admin.root_path + expect(page).to have_content("updated #{translated(attributes[:name])} in #{translated(participatory_process.title)}") end context "when the process doesn't have active steps" do