diff --git a/app/components/admin/budgets/actions_component.rb b/app/components/admin/budgets/actions_component.rb index 07c515b81..0ac54df74 100644 --- a/app/components/admin/budgets/actions_component.rb +++ b/app/components/admin/budgets/actions_component.rb @@ -23,7 +23,7 @@ class Admin::Budgets::ActionsComponent < ApplicationComponent html: winners_action }, ballots: { - hint: t("admin.budgets.actions.descriptions.ballots"), + hint: ballots_hint, html: ballots_action }, destroy: { @@ -65,7 +65,17 @@ class Admin::Budgets::ActionsComponent < ApplicationComponent text: t("admin.budgets.actions.ballots"), path: create_budget_poll_path, method: :post, - confirm: t("admin.budgets.actions.confirm.ballots")) + confirm: t("admin.budgets.actions.confirm.ballots"), + disabled: !feature?("polls")) + end + end + + def ballots_hint + if feature?("polls") + t("admin.budgets.actions.descriptions.ballots") + else + link = admin_settings_path(anchor: "tab-participation-processes") + t("admin.budgets.ballots.feature_disabled", link: link) end end diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index b37d5ea0e..bff93b782 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -166,6 +166,8 @@ en: calculate: Calculate Winner Investments calculated: Winners being calculated, it may take a minute. recalculate: Recalculate Winner Investments + ballots: + feature_disabled: 'The feature Polls must be enabled to create booths. You can enable it from the settings configuration page.' budget_groups: name: "Name" headings_name: "Headings" diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index eabcd31bc..e1d3d8dfd 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -166,6 +166,8 @@ es: calculate: Calcular proyectos ganadores calculated: Calculando ganadores, puede tardar un minuto. recalculate: Recalcular proyectos ganadores + ballots: + feature_disabled: 'La funcionalidad de Votaciones debe estar activada para poder crear urnas. Puedes activarla en la pÔgina de configuración.' budget_groups: name: "Nombre" headings_name: "Partidas" diff --git a/spec/components/admin/budgets/actions_component_spec.rb b/spec/components/admin/budgets/actions_component_spec.rb index 106b9b3ea..b67ac8c9d 100644 --- a/spec/components/admin/budgets/actions_component_spec.rb +++ b/spec/components/admin/budgets/actions_component_spec.rb @@ -1,6 +1,7 @@ require "rails_helper" describe Admin::Budgets::ActionsComponent, controller: Admin::BaseController do + include Rails.application.routes.url_helpers before { sign_in(create(:administrator).user) } let(:budget) { create(:budget) } @@ -30,5 +31,23 @@ describe Admin::Budgets::ActionsComponent, controller: Admin::BaseController do expect(page).not_to have_css "form[action*='polls']" expect(page).not_to have_button "Create booths" end + + it "is disabled when the polls feature is disabled" do + Setting["process.polls"] = false + + render_inline component + + expect(page).to have_button "Create booths", disabled: true + expect(page).to have_link href: admin_settings_path(anchor: "tab-participation-processes") + end + + it "is enabled when the polls feature is enabled" do + Setting["process.polls"] = true + + render_inline component + + expect(page).to have_button "Create booths", disabled: false + expect(page).not_to have_link href: admin_settings_path(anchor: "tab-participation-processes") + end end end