adds links to filter retired proposals by reason

This commit is contained in:
Juanjo Bazán
2016-04-22 17:51:11 +02:00
parent d63cf8b392
commit ed0a4a8525
6 changed files with 62 additions and 10 deletions

View File

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

View File

@@ -2,5 +2,12 @@
<h3 class="sidebar-title"><%= t("proposals.index.retired_proposals") %></h3>
<p>
<%= link_to t("proposals.index.retired_proposals_link"), proposals_path(retired: 1), class: "small" %><br>
<% if params[:retired].blank? %>
<%= link_to t("proposals.index.retired_proposals_link"), proposals_path(retired: 'all'), class: "small" %><br>
<% else %>
<%= link_to t("proposals.index.retired_links.all"), proposals_path(retired: 'all'), ({class: "small"} unless params[:retired] == 'all') %><br>
<% Proposal::RETIRE_OPTIONS.each do |option| %>
<%= link_to t("proposals.index.retired_links.#{option}"), proposals_path(retired: option), ({class: "small"} unless params[:retired] == option) %><br>
<% end %>
<% end %>
</p>

View File

@@ -40,7 +40,7 @@
</div>
<% 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 @@
<div class="small-12 medium-3 column">
<aside class="margin-bottom">
<%= link_to t("proposals.index.start_proposal"), new_proposal_path, class: 'button expanded' %>
<%= render "shared/tag_cloud", taggable: 'proposal' %>
<%= render 'categories' %>
<%= render 'geozones' %>
<%= render 'popular' %>
<%= render 'retired' %>
<% if params[:retired].blank? %>
<%= render "shared/tag_cloud", taggable: 'proposal' %>
<%= render 'categories' %>
<%= render 'geozones' %>
<%= render 'popular' %>
<% end %>
<%= render 'retired' %>
</aside>
</div>

View File

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

View File

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

View File

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