Don't show links to budget results if disabled
This commit is contained in:
@@ -111,7 +111,7 @@ module BudgetsHelper
|
||||
results: t("budgets.results.link"),
|
||||
stats: t("stats.budgets.link"),
|
||||
executions: t("budgets.executions.link")
|
||||
}.map do |section, text|
|
||||
}.select { |section, _| can?(:"read_#{section}", budget) }.map do |section, text|
|
||||
{
|
||||
text: text,
|
||||
url: send("budget_#{section}_path", budget),
|
||||
|
||||
@@ -15,9 +15,12 @@
|
||||
|
||||
<div class="small-12 medium-6 column table" data-equalizer-watch>
|
||||
<div id="budget_<%= budget.id %>_results" class="table-cell align-middle">
|
||||
<%= link_to t("budgets.index.see_results"),
|
||||
budget_results_path(budget),
|
||||
class: "button" %>
|
||||
<% if can?(:read_results, budget) %>
|
||||
<%= link_to t("budgets.index.see_results"),
|
||||
budget_results_path(budget),
|
||||
class: "button" %>
|
||||
<% end %>
|
||||
|
||||
<%= link_to t("budgets.index.milestones"),
|
||||
budget_executions_path(budget),
|
||||
class: "button" %>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if current_budget.finished? %>
|
||||
<% if can?(:read_results, current_budget) %>
|
||||
<%= link_to t("budgets.show.see_results"),
|
||||
budget_results_path(current_budget, heading_id: current_budget.headings.first),
|
||||
class: "button margin-top expanded" %>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @budget.finished? %>
|
||||
<% if can?(:read_results, @budget) %>
|
||||
<%= link_to t("budgets.show.see_results"),
|
||||
budget_results_path(@budget),
|
||||
class: "button margin-top expanded" %>
|
||||
|
||||
@@ -15,6 +15,22 @@ describe "Results" do
|
||||
Budget::Result.new(budget, heading).calculate_winners
|
||||
end
|
||||
|
||||
scenario "No links to budget results with results disabled" do
|
||||
budget.update(results_enabled: false)
|
||||
|
||||
visit budgets_path
|
||||
|
||||
expect(page).not_to have_link "See results"
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
expect(page).not_to have_link "See results"
|
||||
|
||||
visit budget_executions_path(budget)
|
||||
|
||||
expect(page).not_to have_link "See results"
|
||||
end
|
||||
|
||||
scenario "Diplays winner investments" do
|
||||
create(:budget_heading, group: group)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user