From 0eb666db4d0094e424bba9f3c9f5da3ef6d5b8cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 6 Sep 2021 23:10:51 +0200 Subject: [PATCH] Allow commenting on polls as moderator/admin So it works the same way as everywhere else. --- app/models/abilities/administrator.rb | 2 +- app/models/abilities/moderator.rb | 2 +- spec/models/abilities/administrator_spec.rb | 4 ++++ spec/models/abilities/moderator_spec.rb | 3 +++ spec/system/comments/polls_spec.rb | 12 ------------ 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 7d3c698b1..0f492cd0b 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -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 diff --git a/app/models/abilities/moderator.rb b/app/models/abilities/moderator.rb index eac434f22..9058c70a0 100644 --- a/app/models/abilities/moderator.rb +++ b/app/models/abilities/moderator.rb @@ -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 diff --git a/spec/models/abilities/administrator_spec.rb b/spec/models/abilities/administrator_spec.rb index 7a82b4482..424638a1b 100644 --- a/spec/models/abilities/administrator_spec.rb +++ b/spec/models/abilities/administrator_spec.rb @@ -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) } diff --git a/spec/models/abilities/moderator_spec.rb b/spec/models/abilities/moderator_spec.rb index 9f3cb14dc..b9df69067 100644 --- a/spec/models/abilities/moderator_spec.rb +++ b/spec/models/abilities/moderator_spec.rb @@ -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) } diff --git a/spec/system/comments/polls_spec.rb b/spec/system/comments/polls_spec.rb index 6528f37b3..8179fd476 100644 --- a/spec/system/comments/polls_spec.rb +++ b/spec/system/comments/polls_spec.rb @@ -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"