From c5c9efee16623a4756e0e3a05efd3ad055980d1d Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 5 Jun 2017 13:12:04 +0200 Subject: [PATCH 1/8] removes redundant label on index views --- app/assets/stylesheets/participation.scss | 34 ++----------------- .../budgets/investments/_investment.html.erb | 2 -- app/views/debates/_debate.html.erb | 2 -- app/views/proposals/_proposal.html.erb | 2 -- 4 files changed, 2 insertions(+), 38 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index ba819ec3b..de9588d65 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -16,14 +16,13 @@ @mixin votes { border-top: 1px solid $border; margin-top: $line-height; - padding: $line-height 0; + padding: $line-height/2 0; position: relative; @include breakpoint(medium) { border-left: 1px solid $border; border-top: 0; margin-top: 0; - padding-top: $line-height*2; } .icon-like, .icon-unlike { @@ -511,38 +510,9 @@ padding-bottom: rem-calc(12); } - .label-debate, .label-proposal, .label-investment-project, .label-budget-investment { - background: none; - clear: both; - display: block; - font-size: rem-calc(12); - font-weight: bold; - line-height: $line-height; - padding-bottom: 0; - padding-left: 0; - padding-top: 0; - text-transform: uppercase; - } - - .label-debate { - color: $debates; - } - - .label-proposal { - color: $proposals-dark; - } - - .label-investment-project { - color: $budget; - } - - .label-budget-investment { - color: $budget; - } - h3 { font-weight: bold; - margin: 0; + margin-top: $line-height/2; a { color: $text; diff --git a/app/views/budgets/investments/_investment.html.erb b/app/views/budgets/investments/_investment.html.erb index 3155853cd..f65b9cfe5 100644 --- a/app/views/budgets/investments/_investment.html.erb +++ b/app/views/budgets/investments/_investment.html.erb @@ -6,8 +6,6 @@
<% cache [locale_and_user_status(investment), 'index', investment, investment.author] do %> - <%= t("budgets.investments.investment.title") %> -

<%= link_to investment.title, namespaced_budget_investment_path(investment) %>

diff --git a/app/views/debates/_debate.html.erb b/app/views/debates/_debate.html.erb index d084a0241..03c53979d 100644 --- a/app/views/debates/_debate.html.erb +++ b/app/views/debates/_debate.html.erb @@ -5,8 +5,6 @@

- <%= t("debates.debate.debate") %> -

<%= link_to debate.title, debate %>

  diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb index 735e8bcec..dba8b3772 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -8,8 +8,6 @@

<% cache [locale_and_user_status(proposal), 'index', proposal, proposal.author] do %> - <%= t("proposals.proposal.proposal") %> -

<%= link_to proposal.title, namespaced_proposal_path(proposal) %>

  From 10d09686c355abbe43328588c00339e917b50f83 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 5 Jun 2017 13:39:42 +0200 Subject: [PATCH 2/8] removes tags list on index views --- app/assets/stylesheets/participation.scss | 10 ---------- app/views/budgets/investments/_investment.html.erb | 1 - app/views/debates/_debate.html.erb | 1 - app/views/proposals/_proposal.html.erb | 1 - 4 files changed, 13 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index de9588d65..8e432a63a 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -519,16 +519,6 @@ } } - .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 f65b9cfe5..21b67939d 100644 --- a/app/views/budgets/investments/_investment.html.erb +++ b/app/views/budgets/investments/_investment.html.erb @@ -36,7 +36,6 @@

<%= 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 03c53979d..4d0de9a0f 100644 --- a/app/views/debates/_debate.html.erb +++ b/app/views/debates/_debate.html.erb @@ -42,7 +42,6 @@ <%= 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 dba8b3772..41eb5c51b 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -46,7 +46,6 @@
<% end %> - <%= render "shared/tags", taggable: proposal, limit: 5 %> From f374478ddf856bea4130ec524900deb13d14d8eb Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 5 Jun 2017 16:18:32 +0200 Subject: [PATCH 3/8] improves styles displaying search results --- app/assets/stylesheets/layout.scss | 7 +--- app/assets/stylesheets/print.css | 2 - app/views/budgets/investments/index.html.erb | 38 +++++++++++-------- app/views/debates/index.html.erb | 40 ++++++++++++-------- app/views/proposals/index.html.erb | 40 ++++++++++++-------- config/locales/budgets.en.yml | 6 +-- config/locales/budgets.es.yml | 6 +-- config/locales/en.yml | 13 ++++--- config/locales/es.yml | 13 ++++--- config/locales/kaminari.en.yml | 6 +-- config/locales/kaminari.es.yml | 6 +-- 11 files changed, 98 insertions(+), 79 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 7f8379919..d25b7d1e0 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -1106,10 +1106,6 @@ img.avatar, img.admin-avatar, img.moderator-avatar, img.initialjs-avatar { // 09. Search // ---------- -.search-results h2 { - margin-bottom: 0; -} - .advanced-search { float: left; margin: $line-height 0; @@ -1118,7 +1114,7 @@ img.avatar, img.admin-avatar, img.moderator-avatar, img.initialjs-avatar { @include breakpoint(medium) { float: right; margin-bottom: 0; - margin-top: rem-calc(28); + margin-top: $line-height/4; position: absolute; right: 0; z-index: 2; @@ -1126,7 +1122,6 @@ img.avatar, img.admin-avatar, img.moderator-avatar, img.initialjs-avatar { } .advanced-search-form { - margin-top: $line-height; select { height: $line-height*2; diff --git a/app/assets/stylesheets/print.css b/app/assets/stylesheets/print.css index de5a56a31..6b3e5d6f6 100644 --- a/app/assets/stylesheets/print.css +++ b/app/assets/stylesheets/print.css @@ -42,8 +42,6 @@ input[type="submit"] { display: none !important; } .filters h2 { margin: 0 !important; font-size: 20px !important; line-height: 20px !important; width: auto !important; } -.search-results h2 { margin: 0 !important; font-size: 20px !important; line-height: 20px !important; } - .admin h2 { font-size: 20px !important; line-height: 20px !important; } .select-order { diff --git a/app/views/budgets/investments/index.html.erb b/app/views/budgets/investments/index.html.erb index 4c6871826..4c96d3319 100644 --- a/app/views/budgets/investments/index.html.erb +++ b/app/views/budgets/investments/index.html.erb @@ -18,28 +18,36 @@ <%= render '/budgets/investments/header' %> <% end %> -
+ <% if params[:search].present? %> +
+
+
+

<%= t("shared.search_results") %>

+

+ <%= page_entries_info @investments %> + <%= t("budgets.investments.index.search_results_html", count: @investments.size, search_term: params[:search]) %> +

+
+
+
+ <% end %> + +
-
- - <% if @current_filter == "unfeasible" %> + <% if @current_filter == "unfeasible" %> +

<%= t("budgets.investments.index.unfeasible") %>: <%= @heading.name %>

<%= t("budgets.investments.index.unfeasible_text", definitions: link_to(t("budgets.investments.index.unfeasible_text_definitions"), "https://decide.madrid.es/participatory_budget_info#20")).html_safe %>
- <% else %> - <%= content_tag(:h2, t("budgets.investments.index.by_heading", heading: @heading.name)) if @heading.present? %> - <% end %> - - <% if params[:search].present? %> -

- <%= page_entries_info @investments %> - <%= t("budgets.investments.index.search_results", count: @investments.size, search_term: params[:search]) %> -

- <% end %> -
+
+ <% elsif @heading.present? %> +
+

<%= t("budgets.investments.index.by_heading", heading: @heading.name) %>

+
+ <% end %> <%= render('shared/order_links', i18n_namespace: "budgets.investments.index") unless @current_filter == "unfeasible" %> diff --git a/app/views/debates/index.html.erb b/app/views/debates/index.html.erb index b7796f0ba..a92735c2d 100644 --- a/app/views/debates/index.html.erb +++ b/app/views/debates/index.html.erb @@ -11,25 +11,33 @@

<%= t("shared.outline.debates") %>

+ <% if @search_terms || @advanced_search_terms || @tag_filter %> +
+
+
+ <% if @search_terms || @advanced_search_terms %> +

<%= t("shared.search_results") %>

+

+ <%= page_entries_info @debates %> + <% if !@advanced_search_terms %> + <%= t("debates.index.search_results_html", count: @debates.size, search_term: @search_terms) %> + <% end %> +

+ <% elsif @tag_filter %> +

<%= t("shared.search_results") %>

+

+ <%= page_entries_info @debates %> + <%= t("debates.index.filter_topic", count: @debates.size, topic: @tag_filter) %> +

+ <% end %> +
+
+
+ <% end %> +
-
- <% if @search_terms || @advanced_search_terms %> -

- <%= page_entries_info @debates %> - <% if !@advanced_search_terms %> - <%= t("debates.index.search_results", count: @debates.size, search_term: @search_terms) %> - <% end %> -

- <% elsif @tag_filter %> -

- <%= page_entries_info @debates %> - <%= t("debates.index.filter_topic", count: @debates.size, topic: @tag_filter) %> -

- <% end %> -
- <% if has_banners? %> <%= render "shared/banner" %> <% end %> diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb index fb31e9af0..65a02a9c1 100644 --- a/app/views/proposals/index.html.erb +++ b/app/views/proposals/index.html.erb @@ -11,26 +11,34 @@

<%= t("shared.outline.proposals") %>

-
-
- -
- <% if @search_terms || @advanced_search_terms %> -

+ <% if @search_terms || @advanced_search_terms || @tag_filter || params[:retired].present? %> +
+
+
+ <% if @search_terms || @advanced_search_terms %> +

<%= t("shared.search_results") %>

+

<%= page_entries_info @proposals %> <% if !@advanced_search_terms %> - <%= t("proposals.index.search_results", count: @proposals.size, search_term: @search_terms) %> + <%= t("proposals.index.search_results_html", count: @proposals.size, search_term: @search_terms) %> <% end %> -

- <% elsif @tag_filter %> -

- <%= page_entries_info @proposals %> - <%= t("proposals.index.filter_topic", count: @proposals.size, topic: @tag_filter) %> -

- <% elsif params[:retired].present? %> -

<%= t("proposals.index.retired_proposals") %> - <% end %> +

+ <% elsif @tag_filter %> +

<%= t("shared.search_results") %>

+

+ <%= page_entries_info @proposals %> + <%= t("proposals.index.filter_topic", count: @proposals.size, topic: @tag_filter) %> +

+ <% elsif params[:retired].present? %> +

<%= t("proposals.index.retired_proposals") %>

+ <% end %> +
+
+ <% end %> + +
+
<% if has_banners? %> <%= render "shared/banner" %> diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml index 6fba08534..8647b0c92 100644 --- a/config/locales/budgets.en.yml +++ b/config/locales/budgets.en.yml @@ -54,9 +54,9 @@ en: button: Search placeholder: Search investment projects... title: Search - search_results: - one: " containing the term '%{search_term}'" - other: " containing the term '%{search_term}'" + search_results_html: + one: " containing the term '%{search_term}'" + other: " containing the term '%{search_term}'" sidebar: my_ballot: My ballot voted_html: diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml index 1cb308472..f3acbe271 100644 --- a/config/locales/budgets.es.yml +++ b/config/locales/budgets.es.yml @@ -54,9 +54,9 @@ es: button: Buscar placeholder: Buscar propuestas de inversión... title: Buscar - search_results: - one: " que contiene '%{search_term}'" - other: " que contienen '%{search_term}'" + search_results_html: + one: " que contiene '%{search_term}'" + other: " que contienen '%{search_term}'" sidebar: my_ballot: Mis votos voted_html: diff --git a/config/locales/en.yml b/config/locales/en.yml index fdfd821bd..90b8ceadb 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -104,9 +104,9 @@ en: button: Search placeholder: Search debates... title: Search - search_results: - one: " containing the term '%{search_term}'" - other: " containing the term '%{search_term}'" + search_results_html: + one: " containing the term '%{search_term}'" + other: " containing the term '%{search_term}'" select_order: Order by start_debate: Start a debate title: Debates @@ -330,9 +330,9 @@ en: button: Search placeholder: Search proposals... title: Search - search_results: - one: " containing the term '%{search_term}'" - other: " containing the term '%{search_term}'" + search_results_html: + one: " containing the term '%{search_term}'" + other: " containing the term '%{search_term}'" select_order: Order by select_order_long: 'You are viewing proposals according to:' start_proposal: Create a proposal @@ -470,6 +470,7 @@ en: login_to_comment: 'You must %{signin} or %{signup} to leave a comment.' "yes": "Yes" "no": "No" + search_results: "Search results" advanced_search: author_type: 'By author category' author_type_blank: 'Select a category' diff --git a/config/locales/es.yml b/config/locales/es.yml index ca5b33a4e..4f38fc369 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -104,9 +104,9 @@ es: button: Buscar placeholder: Buscar debates... title: Buscar - search_results: - one: " que contiene '%{search_term}'" - other: " que contienen '%{search_term}'" + search_results_html: + one: " que contiene '%{search_term}'" + other: " que contienen '%{search_term}'" select_order: Ordenar por start_debate: Empieza un debate title: Debates @@ -330,9 +330,9 @@ es: button: Buscar placeholder: Buscar propuestas... title: Buscar - search_results: - one: " que contiene '%{search_term}'" - other: " que contienen '%{search_term}'" + search_results_html: + one: " que contiene '%{search_term}'" + other: " que contienen '%{search_term}'" select_order: Ordenar por select_order_long: Estas viendo las propuestas start_proposal: Crea una propuesta @@ -470,6 +470,7 @@ es: login_to_comment: 'Necesitas %{signin} o %{signup} para comentar.' "yes": "Sí" "no": "No" + search_results: "Resultados de búsqueda" advanced_search: author_type: 'Por categoría de autor' author_type_blank: 'Elige una categoría' diff --git a/config/locales/kaminari.en.yml b/config/locales/kaminari.en.yml index 35590c1ca..aa04df74c 100755 --- a/config/locales/kaminari.en.yml +++ b/config/locales/kaminari.en.yml @@ -7,11 +7,11 @@ en: other: Entries zero: Entries more_pages: - display_entries: Displaying %{first} - %{last} of %{total} %{entry_name} + display_entries: Displaying %{first} - %{last} of %{total} %{entry_name} one_page: display_entries: - one: There is 1 %{entry_name} - other: There are %{count} %{entry_name} + one: There is 1 %{entry_name} + other: There are %{count} %{entry_name} zero: "%{entry_name} cannot be found" views: pagination: diff --git a/config/locales/kaminari.es.yml b/config/locales/kaminari.es.yml index 7869cea2a..7cf5bf57e 100644 --- a/config/locales/kaminari.es.yml +++ b/config/locales/kaminari.es.yml @@ -7,11 +7,11 @@ es: other: entradas zero: entradas more_pages: - display_entries: Mostrando %{first} - %{last} de un total de %{total} %{entry_name} + display_entries: Mostrando %{first} - %{last} de un total de %{total} %{entry_name} one_page: display_entries: - one: Hay 1 %{entry_name} - other: Hay %{count} %{entry_name} + one: Hay 1 %{entry_name} + other: Hay %{count} %{entry_name} zero: No se han encontrado %{entry_name} views: pagination: From c76bd65b400bdf6dd3097ed3d380b0a256e12ace Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 5 Jun 2017 16:29:48 +0200 Subject: [PATCH 4/8] removes old proposals successful banner --- app/controllers/debates_controller.rb | 1 - app/controllers/proposals_controller.rb | 7 ------- app/views/debates/index.html.erb | 6 +----- app/views/proposals/_successful_banner.html.erb | 9 --------- app/views/proposals/index.html.erb | 4 +--- config/locales/en.yml | 3 --- config/locales/es.yml | 3 --- 7 files changed, 2 insertions(+), 31 deletions(-) delete mode 100644 app/views/proposals/_successful_banner.html.erb diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index 9b29080dd..b8d6bdf10 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -19,7 +19,6 @@ class DebatesController < ApplicationController def index_customization @featured_debates = @debates.featured - @proposal_successfull_exists = Proposal.successful.exists? end def show diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 3a9db4c5d..b4599676d 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -35,8 +35,6 @@ class ProposalsController < ApplicationController def index_customization discard_archived load_retired - load_successful_proposals - load_featured unless @proposal_successful_exists end def vote @@ -115,9 +113,4 @@ class ProposalsController < ApplicationController @resources = @resources.where('proposals.id NOT IN (?)', @featured_proposals.map(&:id)) end end - - def load_successful_proposals - @proposal_successful_exists = Proposal.successful.exists? - end - end diff --git a/app/views/debates/index.html.erb b/app/views/debates/index.html.erb index a92735c2d..73cafe392 100644 --- a/app/views/debates/index.html.erb +++ b/app/views/debates/index.html.erb @@ -42,11 +42,7 @@ <%= render "shared/banner" %> <% end %> - <% if @proposal_successful_exists %> - <%= render "proposals/successful_banner" %> - <% end %> - - <% unless @tag_filter || @search_terms || !has_featured? || @proposal_successful_exists %> + <% unless @tag_filter || @search_terms || !has_featured? %> <%= render "featured_debates" %> <% end %> diff --git a/app/views/proposals/_successful_banner.html.erb b/app/views/proposals/_successful_banner.html.erb deleted file mode 100644 index 3bde0e097..000000000 --- a/app/views/proposals/_successful_banner.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -
- <%= link_to polls_path do %> -
-
-

<%= t("poll_questions.banner.featured_title") %>

-

<%= t("poll_questions.banner.info") %>

-
- <% end %> -
diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb index 65a02a9c1..77a551fc6 100644 --- a/app/views/proposals/index.html.erb +++ b/app/views/proposals/index.html.erb @@ -44,9 +44,7 @@ <%= render "shared/banner" %> <% end %> - <% if @proposal_successful_exists %> - <%= render "successful_banner" %> - <% elsif @featured_proposals.present? %> + <% if @featured_proposals.present? %> + <%= 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