only level 2 users can create spending proposals
This commit is contained in:
@@ -22,7 +22,6 @@ module Abilities
|
|||||||
can :create, Comment
|
can :create, Comment
|
||||||
can :create, Debate
|
can :create, Debate
|
||||||
can :create, Proposal
|
can :create, Proposal
|
||||||
can :create, SpendingProposal
|
|
||||||
|
|
||||||
can [:flag, :unflag], Comment
|
can [:flag, :unflag], Comment
|
||||||
cannot [:flag, :unflag], Comment, user_id: user.id
|
cannot [:flag, :unflag], Comment, user_id: user.id
|
||||||
@@ -41,6 +40,7 @@ module Abilities
|
|||||||
if user.level_two_or_three_verified?
|
if user.level_two_or_three_verified?
|
||||||
can :vote, Proposal
|
can :vote, Proposal
|
||||||
can :vote_featured, Proposal
|
can :vote_featured, Proposal
|
||||||
|
can :create, SpendingProposal
|
||||||
end
|
end
|
||||||
|
|
||||||
can :create, Annotation
|
can :create, Annotation
|
||||||
|
|||||||
@@ -6,8 +6,11 @@
|
|||||||
|
|
||||||
<p><%= t('spending_proposals.index.text') %></p>
|
<p><%= t('spending_proposals.index.text') %></p>
|
||||||
|
|
||||||
<%= link_to t('spending_proposals.index.create_link'), new_spending_proposal_path, class: 'button radius' %>
|
<% 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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -251,6 +251,8 @@ en:
|
|||||||
title: "Participatory budgeting"
|
title: "Participatory budgeting"
|
||||||
text: "Here you can send spending proposals to be considered in the frame of the annual 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"
|
create_link: "Create spending proposal"
|
||||||
|
verified_only: "Only verified users can create spending proposals, %{verify_account}."
|
||||||
|
verify_account: "verify your account"
|
||||||
new:
|
new:
|
||||||
back_link: Back
|
back_link: Back
|
||||||
start_new: "Create spending proposal"
|
start_new: "Create spending proposal"
|
||||||
|
|||||||
@@ -251,6 +251,8 @@ es:
|
|||||||
title: "Presupuestos participativos"
|
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."
|
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"
|
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:
|
new:
|
||||||
back_link: Volver
|
back_link: Volver
|
||||||
start_new: "Crear una propuesta de gasto"
|
start_new: "Crear una propuesta de gasto"
|
||||||
|
|||||||
@@ -2,14 +2,23 @@ require 'rails_helper'
|
|||||||
|
|
||||||
feature 'Spending proposals' do
|
feature 'Spending proposals' do
|
||||||
|
|
||||||
|
let(:author) { create(:user, :level_two) }
|
||||||
|
|
||||||
scenario 'Index' do
|
scenario 'Index' do
|
||||||
visit spending_proposals_path
|
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 have_link('Create spending proposal', href: new_spending_proposal_path)
|
||||||
|
expect(page).to_not have_link('verify your account')
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Create' do
|
scenario 'Create' do
|
||||||
author = create(:user)
|
|
||||||
login_as(author)
|
login_as(author)
|
||||||
|
|
||||||
visit new_spending_proposal_path
|
visit new_spending_proposal_path
|
||||||
@@ -26,7 +35,7 @@ feature 'Spending proposals' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Captcha is required for proposal creation' do
|
scenario 'Captcha is required for proposal creation' do
|
||||||
login_as(create(:user))
|
login_as(author)
|
||||||
|
|
||||||
visit new_spending_proposal_path
|
visit new_spending_proposal_path
|
||||||
fill_in 'spending_proposal_title', with: 'Build a skyscraper'
|
fill_in 'spending_proposal_title', with: 'Build a skyscraper'
|
||||||
@@ -47,7 +56,6 @@ feature 'Spending proposals' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Errors on create' do
|
scenario 'Errors on create' do
|
||||||
author = create(:user)
|
|
||||||
login_as(author)
|
login_as(author)
|
||||||
|
|
||||||
visit new_spending_proposal_path
|
visit new_spending_proposal_path
|
||||||
|
|||||||
@@ -51,4 +51,6 @@ describe "Abilities::Administrator" do
|
|||||||
it { should_not be_able_to(:comment_as_moderator, proposal) }
|
it { should_not be_able_to(:comment_as_moderator, proposal) }
|
||||||
|
|
||||||
it { should be_able_to(:manage, Annotation) }
|
it { should be_able_to(:manage, Annotation) }
|
||||||
|
|
||||||
|
it { should be_able_to(:manage, SpendingProposal) }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ describe "Abilities::Common" do
|
|||||||
it { should_not be_able_to(:vote_featured, Proposal) }
|
it { should_not be_able_to(:vote_featured, Proposal) }
|
||||||
|
|
||||||
it { should be_able_to(:index, SpendingProposal) }
|
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_administrator, debate) }
|
||||||
it { should_not be_able_to(:comment_as_moderator, 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, Proposal) }
|
||||||
it { should be_able_to(:vote_featured, Proposal) }
|
it { should be_able_to(:vote_featured, Proposal) }
|
||||||
|
|
||||||
|
it { should be_able_to(:create, SpendingProposal) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when level 3 verified" do
|
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, Proposal) }
|
||||||
it { should be_able_to(:vote_featured, Proposal) }
|
it { should be_able_to(:vote_featured, Proposal) }
|
||||||
|
|
||||||
|
it { should be_able_to(:create, SpendingProposal) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user