Reorganize SDG tag list components

So now we've got a component receiving records (goals or targets) and a
related model (Debate, Proposal, ...), with optionally a link to see
more tags.

This way we simplify some logic since the `TagList` classes were dealing
with too many cases (a record is passed, a class name is passed, a limit
is passed), ... Now `TagList` only deal with the natural `TagList` case,
which is listing the tags for a record. The case where a class name is
passed is used in the `TagCloud` class.
This commit is contained in:
Javi Martín
2021-02-02 19:00:11 +01:00
parent a78663120a
commit 7d4e49a090
13 changed files with 94 additions and 116 deletions

View File

@@ -15,11 +15,13 @@ describe SDG::Goals::TagCloudComponent, type: :component do
expect(page).to have_content "Filters by SDG"
end
it "renders all goals" do
it "renders all goals ordered by code" do
component = SDG::Goals::TagCloudComponent.new("Proposal")
render_inline component
expect(page).to have_css ".sdg-goal-icon", count: 17
expect(page).to have_selector ".sdg-goal-icon", count: 17
expect(page.first("a")[:title]).to end_with "goal 1"
expect(page.all("a").last[:title]).to end_with "goal 17"
end
end

View File

@@ -60,16 +60,4 @@ describe SDG::Goals::TagListComponent, type: :component do
title: "One more goal",
href: "/debates/#{debate.to_param}"
end
context "given a class name" do
let(:component) { SDG::Goals::TagListComponent.new("Debate") }
it "renders all goals ordered by code" do
render_inline component
expect(page).to have_selector "li", count: 17
expect(page.first("a")[:title]).to end_with "goal 1"
expect(page.all("a").last[:title]).to end_with "goal 17"
end
end
end