diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index 36ba8d048..4cabae278 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -1,6 +1,6 @@ module TagsHelper - def taggable_path(taggable_type, tag_name) + def taggables_path(taggable_type, tag_name) case taggable_type when 'debate' debates_path(search: tag_name) @@ -13,4 +13,18 @@ module TagsHelper end end + def taggable_path(taggable) + taggable_type = taggable.class.name.underscore + case taggable_type + when 'debate' + debate_path(taggable) + when 'proposal' + proposal_path(taggable) + when 'budget/investment' + budget_investment_path(taggable.budget_id, taggable) + else + '#' + end + end + end diff --git a/app/views/shared/_tag_cloud.html.erb b/app/views/shared/_tag_cloud.html.erb index baa966a77..1d59f752b 100644 --- a/app/views/shared/_tag_cloud.html.erb +++ b/app/views/shared/_tag_cloud.html.erb @@ -5,7 +5,7 @@ diff --git a/spec/features/tags/budget_investments_spec.rb b/spec/features/tags/budget_investments_spec.rb index 0b22297bf..28d19333f 100644 --- a/spec/features/tags/budget_investments_spec.rb +++ b/spec/features/tags/budget_investments_spec.rb @@ -36,6 +36,18 @@ feature 'Tags' do end end + scenario 'Index shows up to 5 tags per proposal' do + create_featured_proposals + tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa"] + create :budget_investment, heading: heading, tag_list: tag_list + + visit budget_investments_path(budget, heading_id: heading.id) + + within('.budget-investment .tags') do + expect(page).to have_content '1+' + end + end + scenario 'Show' do investment = create(:budget_investment, heading: heading, tag_list: 'Hacienda, Economía')