Merge branch 'master' into legislation-module-stable

This commit is contained in:
Amaia Castro
2017-01-19 12:40:07 +01:00
4 changed files with 30 additions and 4 deletions

View File

@@ -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

View File

@@ -5,7 +5,7 @@
<ul class="no-bullet tag-cloud">
<% @tag_cloud.tags.each do |tag| %>
<li class="inline-block">
<%= link_to taggable_path(taggable, tag.name) do %>
<%= link_to taggables_path(taggable, tag.name) do %>
<span class="tag"><%= tag.name %></span>
<% end %>
</li>

View File

@@ -5,14 +5,14 @@
<% taggable.tag_list_with_limit(limit).each do |tag| %>
<li class="inline-block">
<%= link_to sanitize(tag.name),
taggable_path(taggable.class.name.underscore, tag.name),
taggables_path(taggable.class.name.underscore, tag.name),
search: tag.name %></li>
<% end %>
<% if taggable.tags_count_out_of_limit(limit) > 0 %>
<li class="inline-block">
<%= link_to "#{taggable.tags_count_out_of_limit(limit)}+",
send("#{taggable.class.name.underscore}_path", taggable) %>
taggable_path(taggable) %>
</li>
<% end %>
</ul>

View File

@@ -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')