Addressed comments from sprint meeting 22/06/2018
New group created in administration menu including dashboard resources/ proposed tasks and pending tasks for the administrator. Some unused files have been removed.
This commit is contained in:
25
app/controllers/admin/administrator_tasks_controller.rb
Normal file
25
app/controllers/admin/administrator_tasks_controller.rb
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
class Admin::AdministratorTasksController < Admin::BaseController
|
||||||
|
helper_method :administrator_task
|
||||||
|
|
||||||
|
def index
|
||||||
|
authorize! :index, AdministratorTask
|
||||||
|
@administrator_tasks = AdministratorTask.pending
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
authorize! :edit, administrator_task
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
authorize! :update, administrator_task
|
||||||
|
|
||||||
|
administrator_task.update(user: current_user, executed_at: Time.now)
|
||||||
|
redirect_to admin_administrator_tasks_path, { flash: { notice: t('.success') } }
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def administrator_task
|
||||||
|
@administrator_task ||= AdministratorTask.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
||||||
15
app/views/admin/administrator_tasks/_form.html.erb
Normal file
15
app/views/admin/administrator_tasks/_form.html.erb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<%= form_for [:admin, administrator_task] do |f| %>
|
||||||
|
|
||||||
|
<div class="callout">
|
||||||
|
<h5><%=t '.proposal', title: administrator_task.source.proposal.title %></h5>
|
||||||
|
<p><%=t '.request', title: administrator_task.source.proposal_dashboard_action.title %></p>
|
||||||
|
<%== administrator_task.source.comments unless administrator_task.source.comments.blank? %>
|
||||||
|
<%= link_to t('.check_details'), proposal_path(administrator_task.source.proposal), target: '_blank' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="actions small-12 large-3 medium-3 column">
|
||||||
|
<%= f.submit(class: 'button expanded', value: t('.solve')) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
9
app/views/admin/administrator_tasks/edit.html.erb
Normal file
9
app/views/admin/administrator_tasks/edit.html.erb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="small-12 column">
|
||||||
|
<%= back_link_to admin_administrator_tasks_path, t('.back') %>
|
||||||
|
|
||||||
|
<h1><%= t('.solving') %></h1>
|
||||||
|
|
||||||
|
<%= render 'form' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
34
app/views/admin/administrator_tasks/index.html.erb
Normal file
34
app/views/admin/administrator_tasks/index.html.erb
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<h2 class="inline-block">
|
||||||
|
<%= AdministratorTask.model_name.human(count: 2) %>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><%= AdministratorTask.human_attribute_name(:source) %></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% if @administrator_tasks.empty? %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="100%"><%= t '.no_records' %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% @administrator_tasks.each do |task| %>
|
||||||
|
<tr id="<%= dom_id(task) %>">
|
||||||
|
<td>
|
||||||
|
<%= task.source.proposal.title %>:
|
||||||
|
<%= task.source.proposal_dashboard_action.title %>
|
||||||
|
</td>
|
||||||
|
<td style="text-align: right">
|
||||||
|
<%= link_to t('.solve'),
|
||||||
|
edit_admin_administrator_task_path(task),
|
||||||
|
class: 'edit-banner button hollow' %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
74
spec/features/admin/administrator_tasks_spec.rb
Normal file
74
spec/features/admin/administrator_tasks_spec.rb
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe 'Administrator tasks' do
|
||||||
|
let(:administrator) { create(:administrator) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
login_as administrator.user
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when accessing the pending task list' do
|
||||||
|
context 'and no pending task' do
|
||||||
|
before do
|
||||||
|
visit admin_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 admin_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 admin_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
|
||||||
Reference in New Issue
Block a user