diff --git a/app/views/admin/budget_investments/index.html.erb b/app/views/admin/budget_investments/index.html.erb index 09b6e875b..1a5c6686f 100644 --- a/app/views/admin/budget_investments/index.html.erb +++ b/app/views/admin/budget_investments/index.html.erb @@ -1,8 +1,10 @@ -
- <%= link_to t("admin.budget_investments.index.see_results"), - budget_results_path(current_budget, heading_id: current_budget.headings.first), - class: "button hollow medium", target: "_blank" %> -
+<% if @budget.has_winning_investments? %> +
+ <%= link_to t("admin.budget_investments.index.see_results"), + budget_results_path(@budget, heading_id: @budget.headings.first), + class: "button hollow medium", target: "_blank" %> +
+<% end %>

<%= @budget.name %> - <%= t("admin.budget_investments.index.title") %>

diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 8b20e26e7..053331043 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -540,6 +540,24 @@ feature 'Admin budget investments' do end + scenario "See results button appears when budget status is finished" do + + finished_budget = create(:budget, :finished) + + visit admin_budget_budget_investments_path(budget_id: finished_budget.id) + expect(page).to have_content "See results" + + end + + scenario "See results button does not appear for unfinished budgets" do + + not_finished_budget = create(:budget, :valuating) + + visit admin_budget_budget_investments_path(budget_id: not_finished_budget.id) + expect(page).not_to have_content "See results" + + end + end context 'Search' do