From c3635f4182265d7f0842adfea7357bc8a85750fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Wed, 18 Jan 2017 18:17:02 +0100 Subject: [PATCH 1/2] adds taggables/s path helper --- app/helpers/tags_helper.rb | 16 +++++++++++++++- app/views/shared/_tag_cloud.html.erb | 2 +- app/views/shared/_tags.html.erb | 4 ++-- 3 files changed, 18 insertions(+), 4 deletions(-) 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 @@ From c918c9e081e22ec255f8dbc5d73fabe7e988c25b Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 19 Jan 2017 10:03:38 +0100 Subject: [PATCH 2/2] adds specs for many tags in a budget investment --- spec/features/tags/budget_investments_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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')