From edbef4fd889a6606c481c86773ac8a8dc0871a08 Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 30 Jan 2021 11:52:40 +0100 Subject: [PATCH] Add tag list component to debate feed --- app/assets/stylesheets/layout.scss | 3 ++- .../widgets/feeds/participation.scss | 4 +++ .../widget/feeds/debate_component.html.erb | 1 + .../widget/feeds/debate_component_spec.rb | 25 +++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 spec/components/widget/feeds/debate_component_spec.rb diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index daef4a5ae..62cb2edd3 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -2785,7 +2785,8 @@ table { } } - p { + p, + .sdg-tag-list { padding: 0 $line-height / 4; } } diff --git a/app/assets/stylesheets/widgets/feeds/participation.scss b/app/assets/stylesheets/widgets/feeds/participation.scss index 350eb9a6f..0778effc2 100644 --- a/app/assets/stylesheets/widgets/feeds/participation.scss +++ b/app/assets/stylesheets/widgets/feeds/participation.scss @@ -22,6 +22,10 @@ } } + .sdg-tag-list { + margin-top: $line-height / 2; + } + .feed-debates, .feed-proposals { @include grid-col; diff --git a/app/components/widget/feeds/debate_component.html.erb b/app/components/widget/feeds/debate_component.html.erb index ba93fa7c1..460d88d54 100644 --- a/app/components/widget/feeds/debate_component.html.erb +++ b/app/components/widget/feeds/debate_component.html.erb @@ -1,3 +1,4 @@
<%= link_to debate.title, url_for(debate) %> + <%= render SDG::TagListComponent.new(debate, limit: 5) %>
diff --git a/spec/components/widget/feeds/debate_component_spec.rb b/spec/components/widget/feeds/debate_component_spec.rb new file mode 100644 index 000000000..c0adb0785 --- /dev/null +++ b/spec/components/widget/feeds/debate_component_spec.rb @@ -0,0 +1,25 @@ +require "rails_helper" + +describe Widget::Feeds::DebateComponent, type: :component do + let(:debate) { create(:debate, sdg_goals: [SDG::Goal[1]]) } + let(:component) { Widget::Feeds::DebateComponent.new(debate) } + + before do + Setting["feature.sdg"] = true + Setting["sdg.process.debates"] = true + end + + it "renders a title with link" do + render_inline component + + expect(page).to have_link debate.title, href: "/debates/#{debate.to_param}" + end + + it "renders a tag list" do + render_inline component + + expect(page).to have_link "1. No Poverty", + title: "See all Debates related to goal 1", + href: "/debates?advanced_search#{CGI.escape("[goal]")}=1" + end +end