Compare commits

..

2 Commits

Author SHA1 Message Date
bilal
295eccac77 fix MR comment 2020-06-06 01:32:03 +02:00
bilal
727f71d6e3 add account and project name columns to the task requests table 2020-06-04 10:02:14 +02:00
8 changed files with 57 additions and 87 deletions

View File

@@ -22,8 +22,4 @@ class TaskRequestPolicy < ApplicationPolicy
def cancel?
true
end
def open_deliverable?
true
end
end

View File

@@ -2,6 +2,12 @@
<td>
<%= task_request.id %>
</td>
<td>
<%= task_request.project.account.name %>
</td>
<td>
<%= task_request.project.name %>
</td>
<td>
<%= task_request.created_at.strftime("%D") %>
</td>

View File

@@ -3,6 +3,8 @@
<thead class="thead-light">
<tr>
<th>Task ID</th>
<th>Account Name</th>
<th>Project Name</th>
<th>Created On</th>
<th>Deadline</th>
<th>Time Allowed</th>
@@ -15,7 +17,7 @@
<%= render @task_requests %>
<% else %>
<tr>
<td colspan="6" class="py-4 text-center text-muted"><%= t(".empty") %></td>
<td colspan="20" class="py-4 text-center text-muted"><%= t(".empty") %></td>
</tr>
<% end %>
</tbody>

View File

@@ -26,9 +26,6 @@
<% if policy(task_request).edit? %>
<%= link_to fa_icon("pencil fw", text: "Edit"), [:edit, task_request.project, task_request], class: "dropdown-item" %>
<% 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? %>
<%= link_to fa_icon("ban fw", text: "Cancel"), [:cancel, task_request.project, task_request], class: "dropdown-item", method: :post %>
<% end %>

View File

@@ -959,7 +959,6 @@ en:
task_request:
actions:
manage: Manage
open_deliverable: Open Deliverable
update:
notice: Task request updated successfully.
user_mailer:

View File

@@ -182,8 +182,3 @@ es:
photos:
guardian_photo:
heading: Guardian Photo (ES)
task_requests:
task_request:
actions:
manage: Manage (ES)
open_deliverable: Open Deliverable (ES)

View File

@@ -0,0 +1,48 @@
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 "task requests table is visible" do
visit admin_task_requests_path
expect(page).to have_content "Task ID"
expect(page).to have_content "Account Name"
expect(page).to have_content "Project Name"
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 admin_task_requests_path
expect(page).to have_content no_task_requests_label
task_request = create(:task_request)
visit admin_task_requests_path
expect(page).not_to have_content no_task_requests_label
expect(page).to have_content task_request.id
expect(page).to have_content task_request.project.account.name
expect(page).to have_content task_request.project.name
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
private
def no_task_requests_label
"Task requests will appear here"
end
end

View File

@@ -1,73 +0,0 @@
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