Compare commits
2 Commits
big-admin-
...
big-admin-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
295eccac77 | ||
|
|
727f71d6e3 |
@@ -1,5 +1,5 @@
|
||||
class Admin::TaskRequestsController < Admin::ApplicationController
|
||||
before_action :set_task_request, only: [:edit, :update, :show]
|
||||
before_action :set_task_request, only: [:edit, :update]
|
||||
|
||||
def index
|
||||
@task_requests = task_requests.order_by_recent.paginate(page: params[:page])
|
||||
|
||||
@@ -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>
|
||||
@@ -18,7 +24,6 @@
|
||||
<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 } %>
|
||||
<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" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
@@ -31,7 +31,7 @@ Rails.application.routes.draw do
|
||||
resources :users, only: [:index, :new, :create, :edit, :update, :destroy] do
|
||||
resource :masquerade, only: :create
|
||||
end
|
||||
resources :task_requests, only: [:index, :edit, :update, :show]
|
||||
resources :task_requests, only: [:index, :edit, :update]
|
||||
|
||||
root to: "accounts#index", as: :signed_in_root
|
||||
end
|
||||
|
||||
@@ -8,54 +8,41 @@ feature "Admin managing task requests" do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
scenario "admin should see View action for task request in Manage dropdown", js: true do
|
||||
create(:task_request)
|
||||
scenario "task requests table is visible" do
|
||||
visit admin_task_requests_path
|
||||
|
||||
click_on 'Manage'
|
||||
expect(page).to have_content 'View'
|
||||
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 "admin can open detail view of task request", js: true do
|
||||
task_request = create(:task_request, :with_files)
|
||||
scenario "sees list of task requests" do
|
||||
visit admin_task_requests_path
|
||||
|
||||
click_on 'Manage'
|
||||
click_link 'View'
|
||||
switch_to_window(windows.last)
|
||||
expect(page).to have_content no_task_requests_label
|
||||
|
||||
expect(page).to have_content 'Description'
|
||||
expect(page).to have_content task_request.description
|
||||
task_request = create(:task_request)
|
||||
|
||||
expect(page).to have_content 'Created At'
|
||||
expect(page).to have_content task_request.created_at
|
||||
visit admin_task_requests_path
|
||||
|
||||
expect(page).to have_content 'Deadline'
|
||||
expect(page).to have_content task_request.deadline
|
||||
expect(page).not_to have_content no_task_requests_label
|
||||
|
||||
expect(page).to have_content 'Time Allowed'
|
||||
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 '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
|
||||
expect(page).to have_content task_request.status.capitalize
|
||||
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
|
||||
private
|
||||
|
||||
click_on 'Manage'
|
||||
click_link 'View'
|
||||
switch_to_window(windows.last)
|
||||
|
||||
expect(page).to have_content 'No files attached'
|
||||
def no_task_requests_label
|
||||
"Task requests will appear here"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user