Compare commits
1 Commits
big-admin-
...
allow-user
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c21286de7 |
@@ -1,5 +1,5 @@
|
|||||||
class Admin::TaskRequestsController < Admin::ApplicationController
|
class Admin::TaskRequestsController < Admin::ApplicationController
|
||||||
before_action :set_task_request, only: [:edit, :update, :show]
|
before_action :set_task_request, only: [:edit, :update]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@task_requests = task_requests.order_by_recent.paginate(page: params[:page])
|
@task_requests = task_requests.order_by_recent.paginate(page: params[:page])
|
||||||
|
|||||||
@@ -22,4 +22,8 @@ class TaskRequestPolicy < ApplicationPolicy
|
|||||||
def cancel?
|
def cancel?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def open_deliverable?
|
||||||
|
true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<%= button_tag "Manage", class: "btn btn-light btn-sm dropdown-toggle border", data: { toggle: "dropdown", boundary: "window" }, aria: { haspopup: true, expanded: false } %>
|
<%= button_tag "Manage", class: "btn btn-light btn-sm dropdown-toggle border", data: { toggle: "dropdown", boundary: "window" }, aria: { haspopup: true, expanded: false } %>
|
||||||
<div class="dropdown-menu dropdown-menu-right">
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
<%= link_to fa_icon("tasks", text: "View"), [:admin, task_request], class: "dropdown-item", target: '_blank' %>
|
|
||||||
<%= link_to fa_icon("pencil", text: "Edit"), [:edit, :admin, task_request], class: "dropdown-item" %>
|
<%= link_to fa_icon("pencil", text: "Edit"), [:edit, :admin, task_request], class: "dropdown-item" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
<dl>
|
|
||||||
<%= description_list_pair_for @task_request, :description, append: ":" %>
|
|
||||||
<%= description_list_pair_for @task_request, :created_at, append: ":" %>
|
|
||||||
<%= description_list_pair_for @task_request, :deadline, append: ":" %>
|
|
||||||
<%= description_list_pair_for @task_request, :time_allowed, append: ":" %>
|
|
||||||
<%= description_list_pair_for @task_request, :additional_notes, append: ":" %>
|
|
||||||
<%= description_list_pair_for @task_request, :status, append: ":" %>
|
|
||||||
<dt>Files:</dt>
|
|
||||||
<dd>
|
|
||||||
<% if @task_request.files.present? %>
|
|
||||||
<% @task_request.files.each do |file| %>
|
|
||||||
<%= link_to file.filename, rails_blob_path(file, disposition: 'attachment'), class: "btn btn-link" %><br/>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
No files attached
|
|
||||||
<% end %>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
@@ -26,6 +26,9 @@
|
|||||||
<% if policy(task_request).edit? %>
|
<% if policy(task_request).edit? %>
|
||||||
<%= link_to fa_icon("pencil fw", text: "Edit"), [:edit, task_request.project, task_request], class: "dropdown-item" %>
|
<%= link_to fa_icon("pencil fw", text: "Edit"), [:edit, task_request.project, task_request], class: "dropdown-item" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if policy(task_request).open_deliverable? && task_request.status == "completed" %>
|
||||||
|
<%= link_to fa_icon("external-link fw", text: t(".actions.open_deliverable")), task_request.deliverable_url, class: "dropdown-item", target: '_blank' %>
|
||||||
|
<% end %>
|
||||||
<% if policy(task_request).cancel? && !task_request.cancelled? %>
|
<% if policy(task_request).cancel? && !task_request.cancelled? %>
|
||||||
<%= link_to fa_icon("ban fw", text: "Cancel"), [:cancel, task_request.project, task_request], class: "dropdown-item", method: :post %>
|
<%= link_to fa_icon("ban fw", text: "Cancel"), [:cancel, task_request.project, task_request], class: "dropdown-item", method: :post %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -959,6 +959,7 @@ en:
|
|||||||
task_request:
|
task_request:
|
||||||
actions:
|
actions:
|
||||||
manage: Manage
|
manage: Manage
|
||||||
|
open_deliverable: Open Deliverable
|
||||||
update:
|
update:
|
||||||
notice: Task request updated successfully.
|
notice: Task request updated successfully.
|
||||||
user_mailer:
|
user_mailer:
|
||||||
|
|||||||
@@ -182,3 +182,8 @@ es:
|
|||||||
photos:
|
photos:
|
||||||
guardian_photo:
|
guardian_photo:
|
||||||
heading: Guardian Photo (ES)
|
heading: Guardian Photo (ES)
|
||||||
|
task_requests:
|
||||||
|
task_request:
|
||||||
|
actions:
|
||||||
|
manage: Manage (ES)
|
||||||
|
open_deliverable: Open Deliverable (ES)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ Rails.application.routes.draw do
|
|||||||
resources :users, only: [:index, :new, :create, :edit, :update, :destroy] do
|
resources :users, only: [:index, :new, :create, :edit, :update, :destroy] do
|
||||||
resource :masquerade, only: :create
|
resource :masquerade, only: :create
|
||||||
end
|
end
|
||||||
resources :task_requests, only: [:index, :edit, :update, :show]
|
resources :task_requests, only: [:index, :edit, :update]
|
||||||
|
|
||||||
root to: "accounts#index", as: :signed_in_root
|
root to: "accounts#index", as: :signed_in_root
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
require "rails_helper"
|
|
||||||
|
|
||||||
feature "Admin managing task requests" do
|
|
||||||
let(:current_user) { create(:user, admin: true, email: "user@test.com") }
|
|
||||||
let(:project) { create(:project, account: current_user.primary_account, name: "Test Project") }
|
|
||||||
|
|
||||||
before do
|
|
||||||
sign_in current_user
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "admin should see View action for task request in Manage dropdown", js: true do
|
|
||||||
create(:task_request)
|
|
||||||
visit admin_task_requests_path
|
|
||||||
|
|
||||||
click_on 'Manage'
|
|
||||||
expect(page).to have_content 'View'
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "admin can open detail view of task request", js: true do
|
|
||||||
task_request = create(:task_request, :with_files)
|
|
||||||
visit admin_task_requests_path
|
|
||||||
|
|
||||||
click_on 'Manage'
|
|
||||||
click_link 'View'
|
|
||||||
switch_to_window(windows.last)
|
|
||||||
|
|
||||||
expect(page).to have_content 'Description'
|
|
||||||
expect(page).to have_content task_request.description
|
|
||||||
|
|
||||||
expect(page).to have_content 'Created At'
|
|
||||||
expect(page).to have_content task_request.created_at
|
|
||||||
|
|
||||||
expect(page).to have_content 'Deadline'
|
|
||||||
expect(page).to have_content task_request.deadline
|
|
||||||
|
|
||||||
expect(page).to have_content 'Time Allowed'
|
|
||||||
expect(page).to have_content task_request.time_allowed
|
|
||||||
|
|
||||||
expect(page).to have_content 'Additional Notes'
|
|
||||||
expect(page).to have_content task_request.additional_notes
|
|
||||||
|
|
||||||
expect(page).to have_content 'Status'
|
|
||||||
expect(page).to have_content task_request.status
|
|
||||||
|
|
||||||
expect(page).to have_content 'Files'
|
|
||||||
task_request.files.each do |file|
|
|
||||||
expect(page).to have_link file.blob.filename
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "no files attached label is shown if there are no files attached to the task request", js:true do
|
|
||||||
create(:task_request)
|
|
||||||
visit admin_task_requests_path
|
|
||||||
|
|
||||||
click_on 'Manage'
|
|
||||||
click_link 'View'
|
|
||||||
switch_to_window(windows.last)
|
|
||||||
|
|
||||||
expect(page).to have_content 'No files attached'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
73
spec/features/user_managing_task_requests_spec.rb
Normal file
73
spec/features/user_managing_task_requests_spec.rb
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
require "rails_helper"
|
||||||
|
|
||||||
|
feature "User managing task requests" do
|
||||||
|
let(:current_user) { create(:user) }
|
||||||
|
let(:project) { create(:project, account: current_user.primary_account) }
|
||||||
|
|
||||||
|
before :each do
|
||||||
|
sign_in current_user
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "task requests table is visible" do
|
||||||
|
visit project_task_requests_path(project)
|
||||||
|
|
||||||
|
expect(page).to have_content "Created On"
|
||||||
|
expect(page).to have_content "Deadline"
|
||||||
|
expect(page).to have_content "Time Allowed"
|
||||||
|
expect(page).to have_content "Status"
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "sees list of task requests" do
|
||||||
|
visit project_task_requests_path(project)
|
||||||
|
|
||||||
|
expect(page).to have_content no_task_requests_label
|
||||||
|
|
||||||
|
task_request = create(:task_request, project: project)
|
||||||
|
|
||||||
|
visit project_task_requests_path(project)
|
||||||
|
|
||||||
|
expect(page).not_to have_content no_task_requests_label
|
||||||
|
|
||||||
|
expect(page).to have_content task_request.created_at.try(:strftime, '%D')
|
||||||
|
expect(page).to have_content task_request.deadline.try(:strftime, '%D')
|
||||||
|
expect(page).to have_content task_request.time_allowed
|
||||||
|
expect(page).to have_content task_request.status.capitalize
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "user does not see open deliverable action in manage dropdown if task status is not completed" do
|
||||||
|
task_request = create(:task_request, project: project)
|
||||||
|
visit project_task_requests_path(project)
|
||||||
|
|
||||||
|
click_on manage_button
|
||||||
|
expect(page).not_to have_content open_deliverable_action_label
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "user can click deliverable action in manage dropdown if task status is completed", js: true do
|
||||||
|
create(:task_request, project: project, status: "completed", deliverable_url: "/")
|
||||||
|
visit project_task_requests_path(project)
|
||||||
|
|
||||||
|
click_on manage_button
|
||||||
|
expect(page).to have_content open_deliverable_action_label
|
||||||
|
click_link open_deliverable_action_label
|
||||||
|
switch_to_window(windows.last)
|
||||||
|
expect(page).to have_content add_new_project_label
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def no_task_requests_label
|
||||||
|
"Task requests will appear here"
|
||||||
|
end
|
||||||
|
|
||||||
|
def manage_button
|
||||||
|
t "task_requests.task_request.actions.manage"
|
||||||
|
end
|
||||||
|
|
||||||
|
def open_deliverable_action_label
|
||||||
|
t "task_requests.task_request.actions.open_deliverable"
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_new_project_label
|
||||||
|
t "projects.index.actions.new"
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user