Show only random order for unfeasible and unselected investments

This commit is contained in:
decabeza
2019-01-30 11:04:42 +01:00
parent 849dcb7a1a
commit 773302f0d7
3 changed files with 38 additions and 1 deletions

View File

@@ -60,6 +60,10 @@ module BudgetsHelper
Budget::Investment.by_budget(budget).tags_on(:valuation).order(:name).select(:name).distinct
end
def unfeasible_or_unselected_filter
["unselected", "unfeasible"].include?(@current_filter)
end
def budget_published?(budget)
!budget.drafting? || current_user&.administrator?
end

View File

@@ -57,7 +57,18 @@
<%= render("shared/advanced_search", search_path: budget_investments_url(@budget)) %>
<%= render('shared/order_links', i18n_namespace: "budgets.investments.index") unless @current_filter == "unfeasible" %>
<% if unfeasible_or_unselected_filter %>
<ul class="no-bullet submenu">
<li class="inline-block">
<%= link_to current_path_with_query_params(order: "random", page: 1),
class: "is-active" do %>
<h2><%= t("budgets.investments.index.orders.random") %></h2>
<% end %>
</li>
</ul>
<% else %>
<%= render("shared/order_links", i18n_namespace: "budgets.investments.index") %>
<% end %>
<% if investments_default_view? %>

View File

@@ -715,6 +715,28 @@ feature 'Budget Investments' do
expect(order).not_to eq(new_order)
end
scenario "Order always is random for unfeasible and unselected investments" do
Budget::Phase::PHASE_KINDS.each do |phase|
budget.update(phase: phase)
visit budget_investments_path(budget, heading_id: heading.id, filter: "unfeasible")
within(".submenu") do
expect(page).to have_content "random"
expect(page).not_to have_content "by price"
expect(page).not_to have_content "highest rated"
end
visit budget_investments_path(budget, heading_id: heading.id, filter: "unselected")
within(".submenu") do
expect(page).to have_content "random"
expect(page).not_to have_content "price"
expect(page).not_to have_content "highest rated"
end
end
end
def investments_order
all(".budget-investment h3").collect {|i| i.text }
end