diff --git a/app/components/sdg/related_list_selector_component.rb b/app/components/sdg/related_list_selector_component.rb index 42584fdad..b183765de 100644 --- a/app/components/sdg/related_list_selector_component.rb +++ b/app/components/sdg/related_list_selector_component.rb @@ -28,6 +28,10 @@ class SDG::RelatedListSelectorComponent < ApplicationComponent } end + def render? + SDG::ProcessEnabled.new(f.object).enabled? + end + private def goals diff --git a/spec/components/sdg/related_list_selector_component_spec.rb b/spec/components/sdg/related_list_selector_component_spec.rb index ca0db193e..7326400e0 100644 --- a/spec/components/sdg/related_list_selector_component_spec.rb +++ b/spec/components/sdg/related_list_selector_component_spec.rb @@ -5,6 +5,27 @@ describe SDG::RelatedListSelectorComponent, type: :component do let(:form) { ConsulFormBuilder.new(:debate, debate, ActionView::Base.new, {}) } let(:component) { SDG::RelatedListSelectorComponent.new(form) } + before do + Setting["feature.sdg"] = true + Setting["sdg.process.debates"] = 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-related-list-selector" + end + + it "does not render when the SDG process feature is disabled" do + Setting["sdg.process.debates"] = false + + render_inline component + + expect(page).not_to have_css ".sdg-related-list-selector" + end + it "renders sdg_related_list field" do render_inline component