diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index b4717fbdf..179d83ba8 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -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 diff --git a/app/views/budgets/investments/index.html.erb b/app/views/budgets/investments/index.html.erb index e23efac73..cbf44c357 100644 --- a/app/views/budgets/investments/index.html.erb +++ b/app/views/budgets/investments/index.html.erb @@ -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 %> +
+ <% else %> + <%= render("shared/order_links", i18n_namespace: "budgets.investments.index") %> + <% end %> <% if investments_default_view? %> diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index b8f2a9dfa..533b8d543 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -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