Merge pull request #4683 from consul/empty_sdg_tags
Don't render empty SDG tag list div
This commit is contained in:
@@ -7,6 +7,10 @@ class SDG::TagListComponent < ApplicationComponent
|
|||||||
@linkable = linkable
|
@linkable = linkable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render?
|
||||||
|
record.sdg_goals.any? || record.sdg_targets.any?
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def goals_list
|
def goals_list
|
||||||
|
|||||||
@@ -22,6 +22,14 @@ describe SDG::TagListComponent do
|
|||||||
expect(page).to have_link "target 3.2.1"
|
expect(page).to have_link "target 3.2.1"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "does not render when there are no tags" do
|
||||||
|
record = build(:debate, sdg_goals: [], sdg_targets: [])
|
||||||
|
|
||||||
|
render_inline SDG::TagListComponent.new(record)
|
||||||
|
|
||||||
|
expect(page.native.inner_html).to be_empty
|
||||||
|
end
|
||||||
|
|
||||||
context "when linkable is false" do
|
context "when linkable is false" do
|
||||||
let(:component) { SDG::TagListComponent.new(debate, linkable: false) }
|
let(:component) { SDG::TagListComponent.new(debate, linkable: false) }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user