diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 8e432a63a..42a2677f9 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -519,6 +519,17 @@ } } + .debate-content, .proposal-content, + .investment-project-content, .budget-investment-content { + margin: 0; + min-height: rem-calc(180); + position: relative; + + .tags { + display: block; + } + } + .icon-debates, .icon-proposals, .icon-budget { font-size: rem-calc(18); line-height: $line-height; diff --git a/app/views/budgets/investments/_investment.html.erb b/app/views/budgets/investments/_investment.html.erb index 21b67939d..f65b9cfe5 100644 --- a/app/views/budgets/investments/_investment.html.erb +++ b/app/views/budgets/investments/_investment.html.erb @@ -36,6 +36,7 @@
<%= investment.description %>
+ <%= render "shared/tags", taggable: investment, limit: 5 %> <% end %> diff --git a/app/views/debates/_debate.html.erb b/app/views/debates/_debate.html.erb index 4d0de9a0f..03c53979d 100644 --- a/app/views/debates/_debate.html.erb +++ b/app/views/debates/_debate.html.erb @@ -42,6 +42,7 @@ <%= debate.description %> + <%= render "shared/tags", taggable: debate, limit: 5 %> diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb index 41eb5c51b..c269146ab 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -45,6 +45,7 @@<%= proposal.summary %>
+ <%= render "shared/tags", taggable: proposal, limit: 5 %> <% end %> diff --git a/spec/features/tags/budget_investments_spec.rb b/spec/features/tags/budget_investments_spec.rb index 73655ebb2..4c978c740 100644 --- a/spec/features/tags/budget_investments_spec.rb +++ b/spec/features/tags/budget_investments_spec.rb @@ -7,18 +7,44 @@ feature 'Tags' do let(:group) { create(:budget_group, name: "Health", budget: budget) } let!(:heading) { create(:budget_heading, name: "More hospitals", group: group) } - scenario 'Does not show on index' do + scenario 'Index' do earth = create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente') money = create(:budget_investment, heading: heading, tag_list: 'Economía') visit budget_investments_path(budget, heading_id: heading.id) within "#budget_investment_#{earth.id}" do - expect(page).to_not have_content "Medio Ambiente" + expect(page).to have_content "Medio Ambiente" end within "#budget_investment_#{money.id}" do - expect(page).to_not have_content "Economía" + expect(page).to have_content "Economía" + end + end + + scenario 'Index shows 3 tags with no plus link' do + tag_list = ["Medio Ambiente", "Corrupción", "Fiestas populares"] + create :budget_investment, heading: heading, tag_list: tag_list + + visit budget_investments_path(budget, heading_id: heading.id) + + within('.budget-investment .tags') do + tag_list.each do |tag| + expect(page).to have_content tag + end + expect(page).not_to have_content '+' + 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 @@ -114,18 +140,21 @@ feature 'Tags' do end context "Filter" do - scenario "Does not from index" do + + scenario "From index" do + investment1 = create(:budget_investment, heading: heading, tag_list: 'Education') investment2 = create(:budget_investment, heading: heading, tag_list: 'Health') visit budget_investments_path(budget, heading_id: heading.id) within "#budget_investment_#{investment1.id}" do - expect(page).to_not have_link('Education') + click_link "Education" end - within "#budget_investment_#{investment2.id}" do - expect(page).to_not have_link('Health') + within("#budget-investments") do + expect(page).to have_css('.budget-investment', count: 1) + expect(page).to have_content(investment1.title) end end diff --git a/spec/features/tags/debates_spec.rb b/spec/features/tags/debates_spec.rb index 522abf86d..6bfca4772 100644 --- a/spec/features/tags/debates_spec.rb +++ b/spec/features/tags/debates_spec.rb @@ -2,18 +2,43 @@ require 'rails_helper' feature 'Tags' do - scenario 'Does not show on index' do + scenario 'Index' do earth = create(:debate, tag_list: 'Medio Ambiente') money = create(:debate, tag_list: 'Economía') visit debates_path within "#debate_#{earth.id}" do - expect(page).to_not have_content "Medio Ambiente" + expect(page).to have_content "Medio Ambiente" end within "#debate_#{money.id}" do - expect(page).to_not have_content "Economía" + expect(page).to have_content "Economía" + end + end + + scenario 'Index shows up to 5 tags per proposal' do + tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa"] + create :debate, tag_list: tag_list + + visit debates_path + + within('.debate .tags') do + expect(page).to have_content '1+' + end + end + + scenario 'Index shows 3 tags with no plus link' do + tag_list = ["Medio Ambiente", "Corrupción", "Fiestas populares"] + create :debate, tag_list: tag_list + + visit debates_path + + within('.debate .tags') do + tag_list.each do |tag| + expect(page).to have_content tag + end + expect(page).not_to have_content '+' end end @@ -126,18 +151,19 @@ feature 'Tags' do context "Filter" do - scenario "Does not from index" do + scenario "From index" do debate1 = create(:debate, tag_list: 'Education') debate2 = create(:debate, tag_list: 'Health') visit debates_path within "#debate_#{debate1.id}" do - expect(page).to_not have_link('Education') + click_link "Education" end - within "#debate_#{debate2.id}" do - expect(page).to_not have_link('Health') + within("#debates") do + expect(page).to have_css('.debate', count: 1) + expect(page).to have_content(debate1.title) end end diff --git a/spec/features/tags/proposals_spec.rb b/spec/features/tags/proposals_spec.rb index f3d00e546..dbab6a95f 100644 --- a/spec/features/tags/proposals_spec.rb +++ b/spec/features/tags/proposals_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' feature 'Tags' do - scenario 'Does not show on index' do + scenario 'Index' do create_featured_proposals earth = create(:proposal, tag_list: 'Medio Ambiente') money = create(:proposal, tag_list: 'Economía') @@ -10,11 +10,23 @@ feature 'Tags' do visit proposals_path within "#proposal_#{earth.id}" do - expect(page).to_not have_content "Medio Ambiente" + expect(page).to have_content "Medio Ambiente" end within "#proposal_#{money.id}" do - expect(page).to_not have_content "Economía" + expect(page).to have_content "Economía" + 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 :proposal, tag_list: tag_list + + visit proposals_path + + within('.proposal .tags') do + expect(page).to have_content '1+' end end @@ -28,6 +40,21 @@ feature 'Tags' do expect(page).to_not have_selector('#featured-proposals') end + scenario 'Index shows 3 tags with no plus link' do + create_featured_proposals + tag_list = ["Medio Ambiente", "Corrupción", "Fiestas populares"] + create :proposal, tag_list: tag_list + + visit proposals_path + + within('.proposal .tags') do + tag_list.each do |tag| + expect(page).to have_content tag + end + expect(page).not_to have_content '+' + end + end + scenario 'Show' do proposal = create(:proposal, tag_list: 'Hacienda, Economía') @@ -169,7 +196,7 @@ feature 'Tags' do context "Filter" do - scenario "Does not from index" do + scenario "From index" do create_featured_proposals proposal1 = create(:proposal, tag_list: 'Education') proposal2 = create(:proposal, tag_list: 'Health') @@ -177,11 +204,12 @@ feature 'Tags' do visit proposals_path within "#proposal_#{proposal1.id}" do - expect(page).to_not have_link('Education') + click_link "Education" end - within "#proposal_#{proposal2.id}" do - expect(page).to_not have_link('Health') + within("#proposals") do + expect(page).to have_css('.proposal', count: 1) + expect(page).to have_content(proposal1.title) end end diff --git a/spec/features/tags_spec.rb b/spec/features/tags_spec.rb index 9e3d65a6e..4ca42f5eb 100644 --- a/spec/features/tags_spec.rb +++ b/spec/features/tags_spec.rb @@ -2,18 +2,18 @@ require 'rails_helper' feature 'Tags' do - scenario 'Does not show on Index' do + scenario 'Index' do earth = create(:debate, tag_list: 'Medio Ambiente') money = create(:debate, tag_list: 'Economía') visit debates_path within "#debate_#{earth.id}" do - expect(page).to_not have_content "Medio Ambiente" + expect(page).to have_content "Medio Ambiente" end within "#debate_#{money.id}" do - expect(page).to_not have_content "Economía" + expect(page).to have_content "Economía" end end