diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb new file mode 100644 index 000000000..464a155d0 --- /dev/null +++ b/app/helpers/tags_helper.rb @@ -0,0 +1,10 @@ +module TagsHelper + def taggables_path(taggable, tag_name) + case taggable.class.name + when "Legislation::Proposal" + legislation_process_proposals_path(taggable.process, search: tag_name) + else + polymorphic_path(taggable.class, search: tag_name) + end + end +end diff --git a/app/views/shared/_tags.html.erb b/app/views/shared/_tags.html.erb index 103455017..f4ac1773e 100644 --- a/app/views/shared/_tags.html.erb +++ b/app/views/shared/_tags.html.erb @@ -7,7 +7,7 @@ <% taggable.tag_list_with_limit(limit).each do |tag| %>
  • <%= link_to sanitize(tag.name), - polymorphic_path(taggable.class, search: tag.name) %>
  • + taggables_path(taggable, tag.name) %> <% end %> <% if taggable.tags_count_out_of_limit(limit) > 0 %> diff --git a/spec/system/legislation/proposals_spec.rb b/spec/system/legislation/proposals_spec.rb index db773cf69..22c83211d 100644 --- a/spec/system/legislation/proposals_spec.rb +++ b/spec/system/legislation/proposals_spec.rb @@ -210,4 +210,27 @@ describe "Legislation Proposals" do expect(page).to have_link(process.title) end end + + scenario "Shows proposal tags as proposals filter", :js do + create(:legislation_proposal, process: process, tag_list: "Culture", title: "Open concert") + create(:legislation_proposal, process: process, tag_list: "Sports", title: "Baseball field") + + visit legislation_process_proposals_path(process) + + expect(page).to have_content "Open concert" + expect(page).to have_content "Baseball field" + + click_link "Culture" + + expect(page).not_to have_content "Baseball field" + expect(page).to have_content "Open concert" + end + + scenario "Show proposal tags on show", :js do + proposal = create(:legislation_proposal, process: process, tag_list: "Culture") + + visit legislation_process_proposal_path(proposal.process, proposal) + + expect(page).to have_link("Culture") + end end