Fix valuation permissions for finished budgets
This commit is contained in:
@@ -64,6 +64,7 @@ module Abilities
|
|||||||
can [:read, :create, :update, :destroy], Budget::Heading
|
can [:read, :create, :update, :destroy], Budget::Heading
|
||||||
can [:hide, :admin_update, :toggle_selection], Budget::Investment
|
can [:hide, :admin_update, :toggle_selection], Budget::Investment
|
||||||
can [:valuate, :comment_valuation], Budget::Investment
|
can [:valuate, :comment_valuation], Budget::Investment
|
||||||
|
cannot [:comment_valuation], Budget::Investment, budget: { phase: "finished" }
|
||||||
can :create, Budget::ValuatorAssignment
|
can :create, Budget::ValuatorAssignment
|
||||||
can [:edit_dossier], Budget::Investment
|
can [:edit_dossier], Budget::Investment
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,9 @@ module Abilities
|
|||||||
def initialize(user)
|
def initialize(user)
|
||||||
valuator = user.valuator
|
valuator = user.valuator
|
||||||
assigned_investment_ids = valuator.assigned_investment_ids
|
assigned_investment_ids = valuator.assigned_investment_ids
|
||||||
finished = { phase: "finished" }
|
|
||||||
|
|
||||||
can [:read], Budget::Investment, id: assigned_investment_ids
|
can [:read], Budget::Investment, id: assigned_investment_ids
|
||||||
can [:valuate], Budget::Investment, { id: assigned_investment_ids, valuation_finished: false }
|
can [:valuate], Budget::Investment, { id: assigned_investment_ids, valuation_finished: false }
|
||||||
cannot [:valuate, :comment_valuation], Budget::Investment, budget: finished
|
|
||||||
|
|
||||||
if valuator.can_edit_dossier?
|
if valuator.can_edit_dossier?
|
||||||
can [:edit_dossier], Budget::Investment, id: assigned_investment_ids
|
can [:edit_dossier], Budget::Investment, id: assigned_investment_ids
|
||||||
@@ -18,6 +16,8 @@ module Abilities
|
|||||||
if valuator.can_comment?
|
if valuator.can_comment?
|
||||||
can [:comment_valuation], Budget::Investment, id: assigned_investment_ids
|
can [:comment_valuation], Budget::Investment, id: assigned_investment_ids
|
||||||
end
|
end
|
||||||
|
|
||||||
|
cannot [:valuate, :edit_dossier, :comment_valuation], Budget::Investment, budget: { phase: "finished" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
<h2><%= t("valuation.budget_investments.valuation_comments") %></h2>
|
<h2><%= t("valuation.budget_investments.valuation_comments") %></h2>
|
||||||
<% unless @comment_tree.nil? %>
|
<% unless @comment_tree.nil? %>
|
||||||
<% can_comment = (!@budget.finished? && can?(:comment_valuation, @investment)) %>
|
|
||||||
|
|
||||||
<%= render "/comments/comment_tree", comment_tree: @comment_tree,
|
<%= render "/comments/comment_tree", comment_tree: @comment_tree,
|
||||||
comment_flags: @comment_flags,
|
comment_flags: @comment_flags,
|
||||||
display_comments_count: false,
|
display_comments_count: false,
|
||||||
valuation: true,
|
valuation: true,
|
||||||
allow_comments: can_comment,
|
allow_comments: can?(:comment_valuation, @investment),
|
||||||
admin_layout: true %>
|
admin_layout: true %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ describe Abilities::Valuator do
|
|||||||
it { should be_able_to(:edit_dossier, assigned_investment) }
|
it { should be_able_to(:edit_dossier, assigned_investment) }
|
||||||
it { should be_able_to(:comment_valuation, assigned_investment) }
|
it { should be_able_to(:comment_valuation, assigned_investment) }
|
||||||
|
|
||||||
|
it { should_not be_able_to(:edit_dossier, finished_assigned_investment) }
|
||||||
|
it { should_not be_able_to(:comment_valuation, finished_assigned_investment) }
|
||||||
|
|
||||||
context "cannot edit dossier" do
|
context "cannot edit dossier" do
|
||||||
before { valuator.can_edit_dossier = false }
|
before { valuator.can_edit_dossier = false }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user