Merge pull request #993 from consul/permissions-change

Permissions change
This commit is contained in:
Enrique García
2016-03-14 15:00:04 +01:00
6 changed files with 10 additions and 6 deletions

View File

@@ -37,7 +37,7 @@ module Abilities
can :manage, Annotation can :manage, Annotation
can :manage, SpendingProposal can [:read, :update], SpendingProposal
end end
end end
end end

View File

@@ -3,7 +3,7 @@ module Abilities
include CanCan::Ability include CanCan::Ability
def initialize(user) def initialize(user)
can :manage, SpendingProposal can [:read, :update, :valuate], SpendingProposal
end end
end end
end end

View File

@@ -4,7 +4,7 @@
<td> <td>
<%= link_to spending_proposal.title, spending_proposal %> <%= link_to spending_proposal.title, spending_proposal %>
<% if current_user && current_user.id == spending_proposal.author_id %> <% if can?(:destroy, spending_proposal) %>
<%= link_to t("users.show.delete_spending_proposal"), <%= link_to t("users.show.delete_spending_proposal"),
spending_proposal, spending_proposal,
method: :delete, method: :delete,

View File

@@ -202,7 +202,7 @@ feature 'Users' do
feature 'Spending proposals' do feature 'Spending proposals' do
background do background do
@author = create(:user) @author = create(:user, :level_two)
@spending_proposal = create(:spending_proposal, author: @author, title: 'Build a school') @spending_proposal = create(:spending_proposal, author: @author, title: 'Build a school')
end end

View File

@@ -52,5 +52,7 @@ describe "Abilities::Administrator" do
it { should be_able_to(:manage, Annotation) } it { should be_able_to(:manage, Annotation) }
it { should be_able_to(:manage, SpendingProposal) } it { should be_able_to(:read, SpendingProposal) }
it { should be_able_to(:update, SpendingProposal) }
it { should be_able_to(:valuate, SpendingProposal) }
end end

View File

@@ -6,5 +6,7 @@ describe "Abilities::Valuator" do
let(:user) { valuator.user } let(:user) { valuator.user }
let(:valuator) { create(:valuator) } let(:valuator) { create(:valuator) }
it { should be_able_to(:manage, SpendingProposal) } it { should be_able_to(:read, SpendingProposal) }
it { should be_able_to(:update, SpendingProposal) }
it { should be_able_to(:valuate, SpendingProposal) }
end end