only level 2 users can create spending proposals

This commit is contained in:
Juanjo Bazán
2016-01-13 13:35:21 +01:00
parent e4dc496b89
commit 1ab0b31d4b
7 changed files with 28 additions and 7 deletions

View File

@@ -22,7 +22,6 @@ module Abilities
can :create, Comment
can :create, Debate
can :create, Proposal
can :create, SpendingProposal
can [:flag, :unflag], Comment
cannot [:flag, :unflag], Comment, user_id: user.id
@@ -41,6 +40,7 @@ module Abilities
if user.level_two_or_three_verified?
can :vote, Proposal
can :vote_featured, Proposal
can :create, SpendingProposal
end
can :create, Annotation

View File

@@ -6,8 +6,11 @@
<p><%= t('spending_proposals.index.text') %></p>
<% if can? :create, SpendingProposal %>
<%= link_to t('spending_proposals.index.create_link'), new_spending_proposal_path, class: 'button radius' %>
<% else %>
<p><%= t('spending_proposals.index.verified_only', verify_account: link_to(t('spending_proposals.index.verify_account'), verification_path)).html_safe %></p>
<% end %>
</div>
</div>
</div>

View File

@@ -251,6 +251,8 @@ en:
title: "Participatory budgeting"
text: "Here you can send spending proposals to be considered in the frame of the annual participatory budgeting."
create_link: "Create spending proposal"
verified_only: "Only verified users can create spending proposals, %{verify_account}."
verify_account: "verify your account"
new:
back_link: Back
start_new: "Create spending proposal"

View File

@@ -251,6 +251,8 @@ es:
title: "Presupuestos participativos"
text: "Desde esta sección podrás sugerir propuestas de gasto que irán asociadas a las partidas de presupuestos ciudadanos. El requisito principal es que sean propuestas presupuestables."
create_link: "Enviar propuesta de gasto"
verified_only: "Sólo los usuarios verificados pueden crear propuestas de gasto, %{verify_account}."
verify_account: "verifica tu cuenta"
new:
back_link: Volver
start_new: "Crear una propuesta de gasto"

View File

@@ -2,14 +2,23 @@ require 'rails_helper'
feature 'Spending proposals' do
let(:author) { create(:user, :level_two) }
scenario 'Index' do
visit spending_proposals_path
expect(page).to_not have_link('Create spending proposal', href: new_spending_proposal_path)
expect(page).to have_link('verify your account')
login_as(author)
visit spending_proposals_path
expect(page).to have_link('Create spending proposal', href: new_spending_proposal_path)
expect(page).to_not have_link('verify your account')
end
scenario 'Create' do
author = create(:user)
login_as(author)
visit new_spending_proposal_path
@@ -26,7 +35,7 @@ feature 'Spending proposals' do
end
scenario 'Captcha is required for proposal creation' do
login_as(create(:user))
login_as(author)
visit new_spending_proposal_path
fill_in 'spending_proposal_title', with: 'Build a skyscraper'
@@ -47,7 +56,6 @@ feature 'Spending proposals' do
end
scenario 'Errors on create' do
author = create(:user)
login_as(author)
visit new_spending_proposal_path

View File

@@ -51,4 +51,6 @@ describe "Abilities::Administrator" do
it { should_not be_able_to(:comment_as_moderator, proposal) }
it { should be_able_to(:manage, Annotation) }
it { should be_able_to(:manage, SpendingProposal) }
end

View File

@@ -29,7 +29,7 @@ describe "Abilities::Common" do
it { should_not be_able_to(:vote_featured, Proposal) }
it { should be_able_to(:index, SpendingProposal) }
it { should be_able_to(:create, SpendingProposal) }
it { should_not be_able_to(:create, SpendingProposal) }
it { should_not be_able_to(:comment_as_administrator, debate) }
it { should_not be_able_to(:comment_as_moderator, debate) }
@@ -87,6 +87,8 @@ describe "Abilities::Common" do
it { should be_able_to(:vote, Proposal) }
it { should be_able_to(:vote_featured, Proposal) }
it { should be_able_to(:create, SpendingProposal) }
end
describe "when level 3 verified" do
@@ -94,5 +96,7 @@ describe "Abilities::Common" do
it { should be_able_to(:vote, Proposal) }
it { should be_able_to(:vote_featured, Proposal) }
it { should be_able_to(:create, SpendingProposal) }
end
end