<%= t("sdg.goals.help.description") %>
+<%= sanitize t("sdg.goals.goal_#{goal.code}.description") %>
+ <%= render SDG::Goals::TargetsComponent.new(goal) %> +After decades of steady decline, the number of people who suffer from hunger – as measured by the prevalence of undernourishment – began to slowly increase again in 2015. Current estimates show that nearly 690 million people are hungry, or 8.9 percent of the world population – up by 10 million people in one year and by nearly 60 million in five years.
The world is not on track to achieve Zero Hunger by 2030. If recent trends continue, the number of people affected by hunger would surpass 840 million by 2030.
According to the World Food Programme, 135 million suffer from acute hunger largely due to man-made conflicts, climate change and economic downturns. The COVID-19 pandemic could now double that number, putting an additional 130 million people at risk of suffering acute hunger by the end of 2020.
With more than a quarter of a billion people potentially at the brink of starvation, swift action needs to be taken to provide food and humanitarian relief to the most at-risk regions.
At the same time, a profound change of the global food and agriculture system is needed if we are to nourish the more than 690 million people who are hungry today – and the additional 2 billion people the world will have by 2050. Increasing agricultural productivity and sustainable food production are crucial to help alleviate the perils of hunger.
' targets: target_2_1: @@ -441,6 +441,9 @@ en: title: "By 2020, enhance capacity-building support to developing countries, including for least developed countries and small island developing States, to increase significantly the availability of high-quality, timely and reliable data disaggregated by income, gender, age, race, ethnicity, migratory status, disability, geographic location and other characteristics relevant in national contexts." target_17_19: title: "By 2030, build on existing initiatives to develop measurements of progress on sustainable development that complement gross domestic product, and support statistical capacity-building in developing countries." + help: + title: "Sustainable Development Goals help" + description: "You can align your contributions to the community (debates, citizen proposals and investment projects) with the Sustaniable Development Goals 2030 Agenda, this will allow us to have an overview of our contribution to each of the Sustainable Development Goals. Below you can find out about all the goals, their targets and localized targets." show: read_more: "Read more about %{goal}" read_less: "Read less about %{goal}" @@ -458,7 +461,8 @@ en: goal_list: "You can choose one or several SDGs aligned with your %{record}" help: title: "Which SDGs and targets are aligned with my %{record}?" - hint: "You can introduce the code of a specific goal/target or a text to find one" + text: "SDG help page" + hint: You can introduce the code of a specific goal/target or a text to find one. For more information visit the %{link}. placeholder: "Write a goal or target code or description" remove_tag: "Remove" title: "Sustainable Development Goals and Targets" diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml index 86f05b5ff..65f17649b 100644 --- a/config/locales/es/activerecord.yml +++ b/config/locales/es/activerecord.yml @@ -7,6 +7,7 @@ es: name: Nombre email: Email description: Descripción + related_sdg_list: Objetivos y Metas activerecord: models: activity: diff --git a/config/locales/es/pages.yml b/config/locales/es/pages.yml index faa92e447..aeeb2607e 100644 --- a/config/locales/es/pages.yml +++ b/config/locales/es/pages.yml @@ -56,6 +56,7 @@ es: other: title: "Otra información de interés" how_to_use: "Utiliza %{org_name} en tu municipio" + sdg: "Ayuda Objetivos de Desarrollo Sostenible" how_to_use: text: |- Utilízalo en tu municipio libremente o ayúdanos a mejorarlo, es software libre. diff --git a/config/locales/es/sdg.yml b/config/locales/es/sdg.yml index a3f4f9561..0b4e7e484 100644 --- a/config/locales/es/sdg.yml +++ b/config/locales/es/sdg.yml @@ -441,6 +441,9 @@ es: title: "De aquí a 2020, mejorar el apoyo a la creación de capacidad prestado a los países en desarrollo, incluidos los países menos adelantados y los pequeños Estados insulares en desarrollo, para aumentar significativamente la disponibilidad de datos oportunos, fiables y de gran calidad desglosados por ingresos, sexo, edad, raza, origen étnico, estatus migratorio, discapacidad, ubicación geográfica y otras características pertinentes en los contextos nacionales." target_17_19: title: "De aquí a 2030, aprovechar las iniciativas existentes para elaborar indicadores que permitan medir los progresos en materia de desarrollo sostenible y complementen el producto interno bruto, y apoyar la creación de capacidad estadística en los países en desarrollo." + help: + title: "Ayuda Objetivos de Desarrollo Sostenible" + description: "Puedes alinear tus aportaciones a la comunidad (debates, propuestas ciudadanas y proyectos de inversión) con los Objetivos de Desarrollo Sostenible de la Agenda 2030, esto nos permitirá tener una visión general de nuestra aportación en cada uno de los objetivos de desarrollo sostenible. A continuación puedes informarte de todos los objetivos, sus metas y las metas localizadas." show: read_more: "Leer más sobre %{goal}" read_less: "Leer menos sobre %{goal}" @@ -458,7 +461,8 @@ es: goal_list: "Puedes seleccionar uno o varios ODS con los que se alinea tu %{record}" help: title: "¿Qué ODS y metas se alinean con mi %{record}?" - hint: "Puedes introducir el código de un objetivo/meta específico o un texto para encontrar uno" + text: "página de ayuda de ODS" + hint: Puedes introducir el código de un objetivo/meta específico o un texto para encontrar uno. Para más información visita la %{link}. placeholder: "Escribe las etiquetas que desees" remove_tag: "Eliminar" title: "Objetivos de Desarrollo Sostenible y Metas" diff --git a/config/routes/sdg.rb b/config/routes/sdg.rb index 52525c685..758738f15 100644 --- a/config/routes/sdg.rb +++ b/config/routes/sdg.rb @@ -1,3 +1,4 @@ namespace :sdg do resources :goals, param: :code, only: [:index, :show] + get :help, controller: "goals" end diff --git a/spec/components/sdg/goals/help_page_component_spec.rb b/spec/components/sdg/goals/help_page_component_spec.rb new file mode 100644 index 000000000..6e02f58f0 --- /dev/null +++ b/spec/components/sdg/goals/help_page_component_spec.rb @@ -0,0 +1,28 @@ +require "rails_helper" + +describe SDG::Goals::HelpPageComponent, type: :component do + let(:goals) { SDG::Goal.all } + let(:component) { SDG::Goals::HelpPageComponent.new(goals) } + + before do + Setting["feature.sdg"] = true + end + + it "does not render when the feature is disabled" do + Setting["feature.sdg"] = false + + render_inline component + + expect(page).not_to have_css ".sdg-help-content" + end + + it "renders content when the feature is enabled" do + render_inline component + + expect(page).to have_css ".sdg-help-content" + expect(page).to have_content SDG::Goal[1].title + expect(page).to have_content SDG::Goal[1].description + expect(page).to have_css "#help_tabs" + expect(page).to have_css "#goal_1_tab" + end +end diff --git a/spec/components/sdg/goals/targets_component_spec.rb b/spec/components/sdg/goals/targets_component_spec.rb index b172c0acb..a7c1bbed7 100644 --- a/spec/components/sdg/goals/targets_component_spec.rb +++ b/spec/components/sdg/goals/targets_component_spec.rb @@ -21,13 +21,13 @@ describe SDG::Goals::TargetsComponent, type: :component do it "renders tabs panel" do render_inline component - expect(page).to have_css ".targets" - expect(page).to have_css "#target_tabs" + expect(page).to have_css ".sdg-goal-targets" + expect(page).to have_css "#goal_1_targets" expect(page).to have_css "li", count: 2 expect(page).to have_content "Targets" expect(page).to have_content "Local targets" expect(page).to have_css ".tabs-content" - expect(page).to have_css "#tab_global_targets" + expect(page).to have_css "#goal_1_tab_global_targets" end it "renders code and title for each target" do diff --git a/spec/system/help_page_spec.rb b/spec/system/help_page_spec.rb index d5b178639..7c721ec41 100644 --- a/spec/system/help_page_spec.rb +++ b/spec/system/help_page_spec.rb @@ -25,4 +25,27 @@ describe "Help page" do expect(page).not_to have_link "Help" end end + + scenario "renders the SDG help page link when the feature is enabled" do + Setting["feature.help_page"] = true + Setting["feature.sdg"] = true + + visit root_path + within("#navigation_bar") do + click_link "Help" + end + + expect(page).to have_link "Sustainable Development Goals help", href: sdg_help_path + end + + scenario "does not render the SDG help page link when the feature is disabled" do + Setting["feature.sdg"] = nil + + visit root_path + within("#navigation_bar") do + click_link "Help" + end + + expect(page).not_to have_link "Sustainable Development Goals help" + end end diff --git a/spec/system/sdg/goals_spec.rb b/spec/system/sdg/goals_spec.rb index edf0f7e6b..e13e42bbf 100644 --- a/spec/system/sdg/goals_spec.rb +++ b/spec/system/sdg/goals_spec.rb @@ -122,7 +122,7 @@ describe "SDG Goals", :js do create(:sdg_local_target, code: "15.1.1", title: "SDG local target sample text") visit sdg_goal_path(15) - within "#target_tabs" do + within ".sdg-goal-targets" do expect(page).to have_content "Targets" expect(page).to have_content "Local targets" end @@ -140,4 +140,34 @@ describe "SDG Goals", :js do end end end + + describe "Help" do + scenario "shows all SDGs targets" do + create(:sdg_local_target, code: "15.1.1", title: "SDG local target sample text") + visit sdg_help_path + + expect(page).to have_content "You can align your contributions to the community" + expect(page).to have_css "h2", exact_text: "1. No Poverty" + expect(page).to have_content "End poverty in all its forms, everywhere." + expect(page).to have_content "1.1 By 2030, eradicate extreme poverty for all people everywhere" + + click_link "7. Affordable and Clean Energy" + + expect(page).not_to have_css "h2", exact_text: "1. No Poverty" + expect(page).to have_css "h2", exact_text: "7. Affordable and Clean Energy" + expect(page).to have_content "Ensure access to affordable, reliable, sustainable and modern energy." + expect(page).to have_content "7.1 By 2030, ensure universal access to affordable" + + click_link "15. Life on Land" + + expect(page).to have_css "h2", exact_text: "15. Life on Land" + expect(page).to have_content "Sustainably manage forests, combat desertification, halt and reverse" + expect(page).to have_content "15.1 By 2020, ensure the conservation, restoration and sustainable use" + + click_link "Local targets" + + expect(page).not_to have_content "15.1 By 2020, ensure the conservation, restoration and sustainable use" + expect(page).to have_content "SDG local target sample text" + end + end end diff --git a/spec/system/sdg_management/relations_spec.rb b/spec/system/sdg_management/relations_spec.rb index e6d43513b..8e01c5fab 100644 --- a/spec/system/sdg_management/relations_spec.rb +++ b/spec/system/sdg_management/relations_spec.rb @@ -305,17 +305,17 @@ describe "SDG Relations", :js do create(:sdg_local_target, code: "1.1.1") visit sdg_management_edit_legislation_process_path(process) - fill_in "You can introduce the code of a specific goal/target or a text to find one", with: "3" + fill_in "Goals and Targets", with: "3" within(".amsify-list") { find(:css, "[data-val='3']").click } within(".amsify-suggestags-input-area") { expect(page).to have_content "SDG3" } - fill_in "You can introduce the code of a specific goal/target or a text to find one", with: "1.1" + fill_in "Goals and Targets", with: "1.1" within(".amsify-list") { find(:css, "[data-val='1.1']").click } within(".amsify-suggestags-input-area") { expect(page).to have_content "1.1" } - fill_in "You can introduce the code of a specific goal/target or a text to find one", with: "1.1.1" + fill_in "Goals and Targets", with: "1.1.1" within(".amsify-list") { find(:css, "[data-val='1.1.1']").click } within(".amsify-suggestags-input-area") { expect(page).to have_content "1.1.1" } @@ -333,7 +333,7 @@ describe "SDG Relations", :js do process = create(:legislation_process, title: "SDG process") visit sdg_management_edit_legislation_process_path(process) - fill_in "You can introduce the code of a specific goal/target or a text to find one", with: "tag nonexistent," + fill_in "Goals and Targets", with: "tag nonexistent," within(".amsify-suggestags-input-area") { expect(page).not_to have_content "tag nonexistent" } end @@ -413,6 +413,16 @@ describe "SDG Relations", :js do expect(find("input[data-code='1']")).to be_checked end end + + scenario "Help page link opens in new window" do + process = create(:legislation_process, title: "SDG process") + + visit sdg_management_edit_legislation_process_path(process) + + within_window(window_opened_by { click_link "SDG help page" }) do + expect(page).to have_content "Sustainable Development Goals help" + end + end end describe "help section" do