Merge pull request #4251 from consul/add-global-sdg-setting
Add global SDG feature setting
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
class SDGManagement::BaseController < ApplicationController
|
||||
include FeatureFlags
|
||||
feature_flag :sdg
|
||||
|
||||
layout "admin"
|
||||
|
||||
before_action :authenticate_user!
|
||||
|
||||
@@ -100,6 +100,7 @@ class Setting < ApplicationRecord
|
||||
"feature.remote_census": nil,
|
||||
"feature.valuation_comment_notification": true,
|
||||
"feature.graphql_api": true,
|
||||
"feature.sdg": false,
|
||||
"homepage.widgets.feeds.debates": true,
|
||||
"homepage.widgets.feeds.processes": true,
|
||||
"homepage.widgets.feeds.proposals": true,
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
<h2><%= t("admin.settings.index.sdg.title") %></h2>
|
||||
<% if feature?(:sdg) %>
|
||||
<h2><%= t("admin.settings.index.sdg.title") %></h2>
|
||||
|
||||
<%= render "featured_settings_table", features: @sdg_settings, tab: "#tab-sdg-configuration" %>
|
||||
<%= render "featured_settings_table", features: @sdg_settings, tab: "#tab-sdg-configuration" %>
|
||||
<% else %>
|
||||
<div class="callout primary">
|
||||
<%= t("admin.settings.index.sdg.how_to_enable") %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if current_user.administrator? %>
|
||||
<% if feature?(:sdg) && current_user.administrator? %>
|
||||
<li>
|
||||
<%= link_to t("sdg_management.header.title"), sdg_management_root_path %>
|
||||
</li>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -130,6 +130,8 @@ en:
|
||||
dashboard:
|
||||
notification_emails: "Dashboard notification emails"
|
||||
notification_emails_description: "Enable sending dashboard notification emails to proposal's authors"
|
||||
sdg: SDG
|
||||
sdg_description: Enable Sustainable Development Goals sections in the administration menu and in the Global Settings.
|
||||
remote_census:
|
||||
general:
|
||||
endpoint: "Endpoint"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -130,6 +130,8 @@ es:
|
||||
dashboard:
|
||||
notification_emails: "Emails del panel de progreso"
|
||||
notification_emails_description: "Activar el envío de emails de notificaciones a los autores de las propuestas en la sección de panel de progreso"
|
||||
sdg: ODS
|
||||
sdg_description: Habilitar secciones relacionadas con Objetivos de Desarrollo Sostenible en el menú de administración y en la sección de Configuración Global.
|
||||
remote_census:
|
||||
general:
|
||||
endpoint: "Endpoint"
|
||||
|
||||
@@ -5,6 +5,7 @@ section "Creating Settings" do
|
||||
"facebook_handle": "CONSUL",
|
||||
"feature.featured_proposals": "true",
|
||||
"feature.map": "true",
|
||||
"feature.sdg": "true",
|
||||
"instagram_handle": "CONSUL",
|
||||
"mailer_from_address": "noreply@consul.dev",
|
||||
"mailer_from_name": "CONSUL",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -5,6 +5,8 @@ describe "Goals", :js do
|
||||
|
||||
describe "Index" do
|
||||
scenario "Visit the index" do
|
||||
Setting["feature.sdg"] = true
|
||||
|
||||
visit sdg_management_root_path
|
||||
|
||||
within("#side_menu") do
|
||||
|
||||
31
spec/system/sdg_management/sdg_spec.rb
Normal file
31
spec/system/sdg_management/sdg_spec.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "SDG Management" do
|
||||
before { login_as(create(:administrator).user) }
|
||||
|
||||
context "SDG feature flag is enabled", :js do
|
||||
before { Setting["feature.sdg"] = true }
|
||||
|
||||
scenario "shows the SDG content link" do
|
||||
visit root_path
|
||||
click_link "Menu"
|
||||
|
||||
expect(page).to have_link "SDG content"
|
||||
end
|
||||
end
|
||||
|
||||
context "SDG feature is disabled" do
|
||||
before { Setting["feature.sdg"] = false }
|
||||
|
||||
scenario "does not show the SDG Content link", :js do
|
||||
visit root_path
|
||||
click_link "Menu"
|
||||
|
||||
expect(page).not_to have_link "SDG content"
|
||||
end
|
||||
|
||||
scenario "does not allow visits to the SDG content" do
|
||||
expect { visit sdg_management_root_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user