Allow commenting on polls as moderator/admin

So it works the same way as everywhere else.
This commit is contained in:
Javi Martín
2021-09-06 23:10:51 +02:00
parent c77759469d
commit 0eb666db4d
5 changed files with 9 additions and 14 deletions

View File

@@ -49,7 +49,7 @@ module Abilities
can :mark_featured, Debate
can :unmark_featured, Debate
can :comment_as_administrator, [Debate, Comment, Proposal, Poll::Question, Budget::Investment,
can :comment_as_administrator, [Debate, Comment, Proposal, Poll, Poll::Question, Budget::Investment,
Legislation::Question, Legislation::Proposal, Legislation::Annotation, Topic]
can [:search, :create, :index, :destroy, :update], ::Administrator

View File

@@ -5,7 +5,7 @@ module Abilities
def initialize(user)
merge Abilities::Moderation.new(user)
can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll::Question,
can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll, Poll::Question,
Legislation::Question, Legislation::Annotation, Legislation::Proposal, Topic]
end
end

View File

@@ -16,6 +16,7 @@ describe Abilities::Administrator do
let(:budget_investment) { create(:budget_investment) }
let(:finished_investment) { create(:budget_investment, budget: create(:budget, :finished)) }
let(:legislation_question) { create(:legislation_question) }
let(:poll) { create(:poll) }
let(:poll_question) { create(:poll_question) }
let(:past_process) { create(:legislation_process, :past) }
@@ -71,6 +72,9 @@ describe Abilities::Administrator do
it { should be_able_to(:comment_as_administrator, legislation_question) }
it { should_not be_able_to(:comment_as_moderator, legislation_question) }
it { should be_able_to(:comment_as_administrator, poll) }
it { should_not be_able_to(:comment_as_moderator, poll) }
it { should be_able_to(:summary, past_process) }
it { should_not be_able_to(:summary, past_draft_process) }
it { should_not be_able_to(:summary, open_process) }

View File

@@ -13,6 +13,7 @@ describe Abilities::Moderator do
let(:comment) { create(:comment) }
let(:proposal) { create(:proposal) }
let(:legislation_question) { create(:legislation_question) }
let(:poll) { create(:poll) }
let(:own_debate) { create(:debate, author: user) }
let(:own_comment) { create(:comment, author: user) }
@@ -101,9 +102,11 @@ describe Abilities::Moderator do
it { should be_able_to(:comment_as_moderator, debate) }
it { should be_able_to(:comment_as_moderator, proposal) }
it { should be_able_to(:comment_as_moderator, legislation_question) }
it { should be_able_to(:comment_as_moderator, poll) }
it { should_not be_able_to(:comment_as_administrator, debate) }
it { should_not be_able_to(:comment_as_administrator, proposal) }
it { should_not be_able_to(:comment_as_administrator, legislation_question) }
it { should_not be_able_to(:comment_as_administrator, poll) }
end
it { should_not be_able_to(:read, SDG::Target) }

View File

@@ -315,8 +315,6 @@ describe "Commenting polls" do
describe "Moderators" do
scenario "can create comment as a moderator" do
skip "Feature not implemented yet, review soon"
moderator = create(:moderator)
login_as(moderator.user)
@@ -335,8 +333,6 @@ describe "Commenting polls" do
end
scenario "can create reply as a moderator" do
skip "Feature not implemented yet, review soon"
citizen = create(:user, username: "Ana")
manuela = create(:user, username: "Manuela")
moderator = create(:moderator, user: manuela)
@@ -364,8 +360,6 @@ describe "Commenting polls" do
end
scenario "can not comment as an administrator" do
skip "Feature not implemented yet, review soon"
moderator = create(:moderator)
login_as(moderator.user)
@@ -377,8 +371,6 @@ describe "Commenting polls" do
describe "Administrators" do
scenario "can create comment as an administrator" do
skip "Feature not implemented yet, review soon"
admin = create(:administrator)
login_as(admin.user)
@@ -397,8 +389,6 @@ describe "Commenting polls" do
end
scenario "can create reply as an administrator" do
skip "Feature not implemented yet, review soon"
citizen = create(:user, username: "Ana")
manuela = create(:user, username: "Manuela")
admin = create(:administrator, user: manuela)
@@ -426,8 +416,6 @@ describe "Commenting polls" do
end
scenario "can not comment as a moderator", :admin do
skip "Feature not implemented yet, review soon"
visit poll_path(poll)
expect(page).not_to have_content "Comment as moderator"