Merge pull request #4683 from consul/empty_sdg_tags

Don't render empty SDG tag list div
This commit is contained in:
Javi Martín
2021-10-04 16:07:28 +02:00
committed by GitHub
2 changed files with 12 additions and 0 deletions

View File

@@ -7,6 +7,10 @@ class SDG::TagListComponent < ApplicationComponent
@linkable = linkable
end
def render?
record.sdg_goals.any? || record.sdg_targets.any?
end
private
def goals_list

View File

@@ -22,6 +22,14 @@ describe SDG::TagListComponent do
expect(page).to have_link "target 3.2.1"
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
let(:component) { SDG::TagListComponent.new(debate, linkable: false) }