Do not render component when the feature is disabled
This commit is contained in:
@@ -28,6 +28,10 @@ class SDG::RelatedListSelectorComponent < ApplicationComponent
|
||||
}
|
||||
end
|
||||
|
||||
def render?
|
||||
SDG::ProcessEnabled.new(f.object).enabled?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def goals
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user