Implements #150
Adds an entry inside moderation section that allows moderators to check pending tasks and mark them as solved.
This commit is contained in:
@@ -1081,4 +1081,20 @@ LOREM_IPSUM
|
||||
comments { Faker::Lorem.sentence(10) }
|
||||
end
|
||||
end
|
||||
|
||||
factory :administrator_task do
|
||||
source { |s| s.association(:proposal_executed_dashboard_action, :with_comments) }
|
||||
user
|
||||
executed_at { Time.now }
|
||||
|
||||
trait :pending do
|
||||
user { nil }
|
||||
executed_at { nil }
|
||||
end
|
||||
|
||||
trait :done do
|
||||
user
|
||||
executed_at { Time.now }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
74
spec/features/moderation/administrator_tasks_spec.rb
Normal file
74
spec/features/moderation/administrator_tasks_spec.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Administrator tasks moderation' do
|
||||
let(:moderator) { create(:moderator) }
|
||||
|
||||
before do
|
||||
login_as moderator.user
|
||||
end
|
||||
|
||||
context 'when accessing the pending task list' do
|
||||
context 'and no pending task' do
|
||||
before do
|
||||
visit moderation_administrator_tasks_path
|
||||
end
|
||||
|
||||
it 'informs that there are no pending tasks' do
|
||||
expect(page).to have_content('There are no pending tasks')
|
||||
end
|
||||
end
|
||||
|
||||
context 'and there are pending tasks' do
|
||||
let!(:task) { create :administrator_task, :pending }
|
||||
|
||||
before do
|
||||
visit moderation_administrator_tasks_path
|
||||
end
|
||||
|
||||
it 'shows the related proposal title' do
|
||||
expect(page).to have_content(task.source.proposal.title)
|
||||
end
|
||||
|
||||
it 'shows the requested action title' do
|
||||
expect(page).to have_content(task.source.proposal_dashboard_action.title)
|
||||
end
|
||||
|
||||
it 'has a link that allows solving the request' do
|
||||
expect(page).to have_link('Solve')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when solving a pending task' do
|
||||
let!(:task) { create :administrator_task, :pending }
|
||||
|
||||
before do
|
||||
visit moderation_administrator_tasks_path
|
||||
click_link 'Solve'
|
||||
end
|
||||
|
||||
it 'contains a link to the proposal' do
|
||||
expect(page).to have_link('Check the proposal details')
|
||||
end
|
||||
|
||||
it 'contains a button that solves the request' do
|
||||
expect(page).to have_button('Mark as solved')
|
||||
end
|
||||
|
||||
it 'shows the comments added by the user during the request' do
|
||||
expect(page).to have_content(task.source.comments)
|
||||
end
|
||||
|
||||
context 'and the Mark as solved button is pressed' do
|
||||
before do
|
||||
click_button 'Mark as solved'
|
||||
end
|
||||
|
||||
it 'The proposal dissapears from the list' do
|
||||
expect(page).not_to have_content(task.source.proposal.title)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -21,6 +21,7 @@ describe Abilities::Moderator do
|
||||
let(:hidden_debate) { create(:debate, :hidden) }
|
||||
let(:hidden_comment) { create(:comment, :hidden) }
|
||||
let(:hidden_proposal) { create(:proposal, :hidden) }
|
||||
let(:administrator_task) { create(:administrator_task) }
|
||||
|
||||
it { should be_able_to(:index, Debate) }
|
||||
it { should be_able_to(:show, debate) }
|
||||
@@ -31,6 +32,9 @@ describe Abilities::Moderator do
|
||||
|
||||
it { should be_able_to(:read, Organization) }
|
||||
|
||||
it { is_expected.to be_able_to :manage, AdministratorTask }
|
||||
it { is_expected.to be_able_to :manage, administrator_task }
|
||||
|
||||
describe "organizations" do
|
||||
let(:pending_organization) { create(:organization) }
|
||||
let(:rejected_organization) { create(:organization, :rejected) }
|
||||
|
||||
@@ -6,12 +6,17 @@ describe ProposalExecutedDashboardAction do
|
||||
build :proposal_executed_dashboard_action,
|
||||
proposal: proposal,
|
||||
proposal_dashboard_action: proposal_dashboard_action,
|
||||
executed_at: executed_at
|
||||
executed_at: executed_at,
|
||||
comments: comments
|
||||
end
|
||||
|
||||
let(:proposal) { create :proposal }
|
||||
let(:proposal_dashboard_action) { create :proposal_dashboard_action }
|
||||
let(:proposal_dashboard_action) do
|
||||
create :proposal_dashboard_action, request_to_administrators: request_to_administrators, link: Faker::Internet.url
|
||||
end
|
||||
let(:request_to_administrators) { false }
|
||||
let(:executed_at) { Time.now }
|
||||
let(:comments) { '' }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
|
||||
@@ -33,6 +38,22 @@ describe ProposalExecutedDashboardAction do
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
|
||||
context 'when the action sends a request to the administrators' do
|
||||
let(:request_to_administrators) { true }
|
||||
|
||||
context 'and comments are blank' do
|
||||
let(:comments) { '' }
|
||||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
|
||||
context 'and comments have value' do
|
||||
let(:comments) { Faker::Lorem.sentence }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when it has been already executed' do
|
||||
let!(:executed) { create(:proposal_executed_dashboard_action, proposal: proposal, proposal_dashboard_action: proposal_dashboard_action) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user