Fix tag links on legislation proposals
On commit 1a902a96 we removed this helper to make use of polymorphic
routes but when it's called for Legislation::Proposal fails as the
namespace does not match the model namespace.
Now we recover the removed helper but only the parts that do not work
with polymorphic_url helper.
Co-Authored-By: Javi Martín <javim@elretirao.net>
This commit is contained in:
committed by
Javi Martín
parent
35db41827c
commit
450b157a5e
10
app/helpers/tags_helper.rb
Normal file
10
app/helpers/tags_helper.rb
Normal file
@@ -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
|
||||
@@ -7,7 +7,7 @@
|
||||
<% taggable.tag_list_with_limit(limit).each do |tag| %>
|
||||
<li>
|
||||
<%= link_to sanitize(tag.name),
|
||||
polymorphic_path(taggable.class, search: tag.name) %></li>
|
||||
taggables_path(taggable, tag.name) %></li>
|
||||
<% end %>
|
||||
|
||||
<% if taggable.tags_count_out_of_limit(limit) > 0 %>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user