From 72e64bd54325af86a3582e661e6e7a56f7c6284c Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 11 Nov 2020 19:45:37 +0100 Subject: [PATCH] Render 'how to enable' when the related feature setting is disabled Add 'how to enable' information on SDG configuration tab when related sdg feature setting is disabled. --- .../settings/_sdg_configuration_tab.html.erb | 10 ++++++-- config/locales/en/admin.yml | 1 + config/locales/es/admin.yml | 1 + spec/system/admin/settings_spec.rb | 25 +++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/views/admin/settings/_sdg_configuration_tab.html.erb b/app/views/admin/settings/_sdg_configuration_tab.html.erb index 0477ed7ef..e931b67e1 100644 --- a/app/views/admin/settings/_sdg_configuration_tab.html.erb +++ b/app/views/admin/settings/_sdg_configuration_tab.html.erb @@ -1,3 +1,9 @@ -

<%= t("admin.settings.index.sdg.title") %>

+<% if feature?(:sdg) %> +

<%= t("admin.settings.index.sdg.title") %>

-<%= render "featured_settings_table", features: @sdg_settings, tab: "#tab-sdg-configuration" %> + <%= render "featured_settings_table", features: @sdg_settings, tab: "#tab-sdg-configuration" %> +<% else %> +
+ <%= t("admin.settings.index.sdg.how_to_enable") %> +
+<% end %> diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index b26d43e85..cf330ae41 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -1242,6 +1242,7 @@ en: how_to_enable: 'To configure remote census (SOAP) you must enable "Configure connection to remote census (SOAP)" on "Features" tab.' sdg: title: SDG configuration + how_to_enable: 'To show the configuration options from Sustainable Development Goals you must enable "SDG" on "Features" tab.' remote_census_general_name: General Information remote_census_request_name: Request Data remote_census_response_name: Response Data diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 644139a29..18c87db4b 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -1241,6 +1241,7 @@ es: how_to_enable: 'Para configurar la conexión con el Censo Remoto (SOAP) se debe activar "Configurar la conexión al censo remoto (SOAP)" en la pestaña "Funcionalidades".' sdg: title: Configuración ODS + how_to_enable: 'Para mostrar las opciones de configuración de los Objetivos de Desarrollo Sostenible se debe activar "ODS" en la pestaña "Funcionalidades".' remote_census_general_name: Datos Generales remote_census_request_name: Datos Petición remote_census_response_name: Datos Respuesta diff --git a/spec/system/admin/settings_spec.rb b/spec/system/admin/settings_spec.rb index f51dc86a2..558bf41d0 100644 --- a/spec/system/admin/settings_spec.rb +++ b/spec/system/admin/settings_spec.rb @@ -267,6 +267,7 @@ describe "Admin settings", :admin do end scenario "On #tab-sdg-configuration", :js do + Setting["feature.sdg"] = true Setting.create!(key: "sdg.whatever") login_as(create(:administrator).user) @@ -313,4 +314,28 @@ describe "Admin settings", :admin do Setting["feature.user.skip_verification"] = nil end end + + describe "SDG configuration tab", :js do + scenario "is enabled when the sdg feature is enabled" do + Setting["feature.sdg"] = true + login_as(create(:administrator).user) + + visit admin_settings_path + click_link "SDG configuration" + + expect(page).to have_css "h2", exact_text: "SDG configuration" + end + + scenario "is disabled when the sdg feature is disabled" do + Setting["feature.sdg"] = false + login_as(create(:administrator).user) + + visit admin_settings_path + click_link "SDG configuration" + + expect(page).to have_content "To show the configuration options from " \ + "Sustainable Development Goals you must " \ + 'enable "SDG" on "Features" tab.' + end + end end