From ca36dd56f04f4efd1091de22b9c392bd1d3e341f Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 30 Jan 2021 11:53:03 +0100 Subject: [PATCH] Add tag list component to proposal feed --- .../widget/feeds/proposal_component.html.erb | 1 + .../widget/feeds/proposal_component_spec.rb | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 spec/components/widget/feeds/proposal_component_spec.rb diff --git a/app/components/widget/feeds/proposal_component.html.erb b/app/components/widget/feeds/proposal_component.html.erb index b94696d51..8f683776a 100644 --- a/app/components/widget/feeds/proposal_component.html.erb +++ b/app/components/widget/feeds/proposal_component.html.erb @@ -3,6 +3,7 @@ <%= "medium-6 large-9" if proposal.image.present? %>"> <%= link_to proposal.title, url_for(proposal) %>

<%= proposal.summary %>

+ <%= render SDG::TagListComponent.new(proposal, limit: 5) %> <% if proposal.image.present? %> diff --git a/spec/components/widget/feeds/proposal_component_spec.rb b/spec/components/widget/feeds/proposal_component_spec.rb new file mode 100644 index 000000000..027efbf3e --- /dev/null +++ b/spec/components/widget/feeds/proposal_component_spec.rb @@ -0,0 +1,25 @@ +require "rails_helper" + +describe Widget::Feeds::ProposalComponent, type: :component do + let(:proposal) { create(:proposal, sdg_goals: [SDG::Goal[1]]) } + let(:component) { Widget::Feeds::ProposalComponent.new(proposal) } + + before do + Setting["feature.sdg"] = true + Setting["sdg.process.proposals"] = true + end + + it "renders a title with link" do + render_inline component + + expect(page).to have_link proposal.title, href: "/proposals/#{proposal.to_param}" + end + + it "renders a tag list" do + render_inline component + + expect(page).to have_link "1. No Poverty", + title: "See all Citizen proposals related to goal 1", + href: "/proposals?advanced_search#{CGI.escape("[goal]")}=1" + end +end