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, SpendingProposal
can [:read, :update], SpendingProposal
end
end
end

View File

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

View File

@@ -4,7 +4,7 @@
<td>
<%= 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"),
spending_proposal,
method: :delete,

View File

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

View File

@@ -52,5 +52,7 @@ describe "Abilities::Administrator" do
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

View File

@@ -6,5 +6,7 @@ describe "Abilities::Valuator" do
let(:user) { valuator.user }
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