diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index e91d20de9..f778b2ca0 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -25,6 +25,7 @@ class ProposalsController < ApplicationController def index_customization if params[:retired].present? @resources = @resources.retired + @resources = @resources.where(retired_reason: params[:retired]) if Proposal::RETIRE_OPTIONS.include?(params[:retired]) else @resources = @resources.not_retired end diff --git a/app/views/proposals/_retired.html.erb b/app/views/proposals/_retired.html.erb index 73d8a7844..ddf1dc36d 100644 --- a/app/views/proposals/_retired.html.erb +++ b/app/views/proposals/_retired.html.erb @@ -2,5 +2,12 @@

- <%= link_to t("proposals.index.retired_proposals_link"), proposals_path(retired: 1), class: "small" %>
+<% if params[:retired].blank? %> + <%= link_to t("proposals.index.retired_proposals_link"), proposals_path(retired: 'all'), class: "small" %>
+<% else %> + <%= link_to t("proposals.index.retired_links.all"), proposals_path(retired: 'all'), ({class: "small"} unless params[:retired] == 'all') %>
+ <% Proposal::RETIRE_OPTIONS.each do |option| %> + <%= link_to t("proposals.index.retired_links.#{option}"), proposals_path(retired: option), ({class: "small"} unless params[:retired] == option) %>
+ <% end %> +<% end %>

diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb index 065553cce..67ee98f67 100644 --- a/app/views/proposals/index.html.erb +++ b/app/views/proposals/index.html.erb @@ -40,7 +40,7 @@ <% end %> - <%= render "shared/advanced_search", search_path: proposals_path(page: 1)%> + <%= render("shared/advanced_search", search_path: proposals_path(page: 1)) unless params[:retired].present? %> <%= render 'shared/order_links', i18n_namespace: "proposals.index" %> @@ -55,11 +55,13 @@
diff --git a/config/locales/en.yml b/config/locales/en.yml index a79ceaca6..d797bef40 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -297,7 +297,14 @@ en: most_commented: most commented relevance: relevance retired_proposals: Retired proposals - retired_proposals_link: "Proposals retired by the author (duplicated, unfeasibles, done, etc.)" + retired_proposals_link: "Proposals retired by the author" + retired_links: + all: All + duplicated: Duplicated + started: Underway + unfeasible: Unfeasible + done: Done + other: Other search_form: button: Search placeholder: Search proposals... diff --git a/config/locales/es.yml b/config/locales/es.yml index 38da0cb2c..16982ed6c 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -297,7 +297,14 @@ es: most_commented: Más comentadas relevance: Más relevantes retired_proposals: Propuestas retiradas - retired_proposals_link: "Propuestas retiradas por sus autores (realizadas, en ejecución, inviables, duplicadas, etc.)" + retired_proposals_link: "Propuestas retiradas por sus autores" + retired_links: + all: Todas + duplicated: Duplicadas + started: Empezadas + unfeasible: Inviables + done: Hechas + other: Otras search_form: button: Buscar placeholder: Buscar propuestas... diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index d770f9d9a..4a3ea58a1 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -489,11 +489,39 @@ feature 'Proposals' do visit proposals_path expect(page).to_not have_content retired.title - click_link 'Proposals retired by the author (duplicated, unfeasibles, done, etc.)' + click_link 'Proposals retired by the author' expect(page).to have_content retired.title expect(page).to_not have_content not_retired.title end + + scenario 'Retired proposals index interface elements' do + visit proposals_path(retired: 'all') + + expect(page).to_not have_content 'Advanced search' + expect(page).to_not have_content 'Categories' + expect(page).to_not have_content 'Districts' + end + + scenario 'Retired proposals index has links to filter by retired_reason' do + unfeasible = create(:proposal, retired_at: Time.now, retired_reason: 'unfeasible') + duplicated = create(:proposal, retired_at: Time.now, retired_reason: 'duplicated') + + visit proposals_path(retired: 'all') + + expect(page).to have_content unfeasible.title + expect(page).to have_content duplicated.title + expect(page).to have_link 'Duplicated' + expect(page).to have_link 'Underway' + expect(page).to have_link 'Unfeasible' + expect(page).to have_link 'Done' + expect(page).to have_link 'Other' + + click_link 'Unfeasible' + + expect(page).to have_content unfeasible.title + expect(page).to_not have_content duplicated.title + end end scenario 'Update should not be posible if logged user is not the author' do