Do not render component when the feature is disabled

This commit is contained in:
taitus
2021-01-22 09:09:30 +01:00
parent 8a91493fe4
commit 189c299a6e
2 changed files with 25 additions and 0 deletions

View File

@@ -28,6 +28,10 @@ class SDG::RelatedListSelectorComponent < ApplicationComponent
}
end
def render?
SDG::ProcessEnabled.new(f.object).enabled?
end
private
def goals

View File

@@ -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