Compare commits

...

5 Commits

Author SHA1 Message Date
bilal
7b319d4247 update structure.sql 2020-06-19 10:30:10 +02:00
bilal
f1e662879d change text 2020-06-19 10:27:49 +02:00
bilal
0cc305302a move notice to the top; change style 2020-06-15 13:03:14 +02:00
Senad Uka
8ad89371b8 Task mvp upstream sync 2020-06-15 11:02:00 +02:00
Senad Uka
9d7e2c044a Upstream sync task me 2020-06-09 06:34:58 +02:00
31 changed files with 430 additions and 75 deletions

View File

@@ -14,6 +14,7 @@ $red: #F9002B;
$green: #51B61B; $green: #51B61B;
$teal: #32C498; $teal: #32C498;
$purple: #5139EE; $purple: #5139EE;
$yellow: #F9BE1B;
$dark: $gray-900; $dark: $gray-900;
$success: $teal; $success: $teal;
$link-color: $body-color; $link-color: $body-color;

View File

@@ -32,14 +32,14 @@
&.release-me { &.release-me {
span:last-child { span:last-child {
background-color: $teal; background-color: $teal;
color: $body-color; color: $white;
} }
} }
&.direct-me { &.direct-me {
span:last-child { span:last-child {
background-color: $green; background-color: $green;
color: $body-color; color: $white;
} }
} }
@@ -53,7 +53,14 @@
&.deliver-me { &.deliver-me {
span:last-child { span:last-child {
background-color: $purple; background-color: $purple;
color: white; color: $white;
}
}
&.task-me {
span:last-child {
background-color: $yellow;
color: $white;
} }
} }

View File

@@ -1,5 +1,5 @@
class Admin::TaskRequestsController < Admin::ApplicationController class Admin::TaskRequestsController < Admin::ApplicationController
before_action :set_task_request, only: [:edit, :update] before_action :set_task_request, only: [:edit, :update, :show]
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])

View File

@@ -6,18 +6,14 @@ class TaskRequestsController < ApplicationController
before_action :set_task_request, only: [:show, :edit, :update, :cancel] before_action :set_task_request, only: [:show, :edit, :update, :cancel]
def index def index
if params[:completed_only] @task_requests = task_requests.order_by_recent.paginate(page: params[:page])
@task_requests = task_requests.completed.order_by_recent.paginate(page: params[:page])
else
@task_requests = task_requests.order_by_recent.paginate(page: params[:page])
end
end end
def new def new
end end
def create def create
@task_request.attributes = task_request_params @task_request.attributes = task_request_params_with_email
if @task_request.save if @task_request.save
log_create_analytics log_create_analytics
@@ -52,6 +48,10 @@ class TaskRequestsController < ApplicationController
params.require(:task_request).permit(:description, :deadline, :time_allowed, :additional_notes, files: []) params.require(:task_request).permit(:description, :deadline, :time_allowed, :additional_notes, files: [])
end end
def task_request_params_with_email
task_request_params.merge(user_email: Current.user.email)
end
def set_project def set_project
@project = policy_scope(Project).find(params[:project_id]) @project = policy_scope(Project).find(params[:project_id])
end end

View File

@@ -0,0 +1,19 @@
class TasksController < ApplicationController
before_action :set_project
include ProjectLayout
def index
@tasks = task_requests.completed.order_by_recent.paginate(page: params[:page])
end
private
def set_project
@project = policy_scope(Project).find(params[:project_id])
end
def task_requests
authorize policy_scope(@project.task_requests)
end
end

View File

@@ -7,8 +7,8 @@ module DescriptionListHelper
safe_join(tags) safe_join(tags)
end end
def description_list_pair_for(record, attribute, append: nil) def description_list_pair_for(record, attribute, append: nil, custom_label: nil)
term = translation_for(record, attribute) term = custom_label.nil? ? translation_for(record, attribute) : custom_label
definition = record.send(attribute) definition = record.send(attribute)
description_list_pair(term, definition, append: append) description_list_pair(term, definition, append: append)

View File

@@ -7,6 +7,8 @@ module DropzoneHelper
"To Add Audio Files to the release:<br>Drag & Drop Files<br>or<br>Click or Tap here to browse files" "To Add Audio Files to the release:<br>Drag & Drop Files<br>or<br>Click or Tap here to browse files"
when "directory" when "directory"
"To Add Files to the Folder:<br>Drag & Drop Files<br>or<br>Click or Tap here to browse files" "To Add Files to the Folder:<br>Drag & Drop Files<br>or<br>Click or Tap here to browse files"
when "task_request"
"To Add Files for the Task:<br>Drag & Drop Files<br>or<br>Click or Tap here to browse files"
else else
"To Add Photos to the release:<br>Drag & Drop Files<br>or<br>Click or Tap here to browse photos and connect to Camera" "To Add Photos to the release:<br>Drag & Drop Files<br>or<br>Click or Tap here to browse photos and connect to Camera"
end end

View File

@@ -1,5 +1,6 @@
$(document).on("turbolinks:load", () => { $(document).on("turbolinks:load", () => {
$('.datepicker-control').datepicker({ $('.datepicker-control').datepicker({
format: "yyyy-mm-dd" format: "yyyy-mm-dd",
todayHighlight: true
}); });
}); });

View File

@@ -79,8 +79,8 @@ class Account < ApplicationRecord
plan_uid.to_s == "me_suite" || plan_uid.to_s == "releaseme" plan_uid.to_s == "me_suite" || plan_uid.to_s == "releaseme"
end end
def assistme_enabled? def taskme_enabled?
plan_uid.to_s == "me_suite" || plan_uid.to_s == "assistme" plan_uid.to_s == "me_suite" || plan_uid.to_s == "taskme"
end end
def plan_name def plan_name
@@ -91,8 +91,8 @@ class Account < ApplicationRecord
"DirectME" "DirectME"
when "releaseme" when "releaseme"
"ReleaseME" "ReleaseME"
when "assistme" when "taskme"
"AssistME" "TaskME"
when "me_suite" when "me_suite"
"ME Suite" "ME Suite"
end end

View File

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

View File

@@ -1,7 +1,7 @@
<%= errors_summary_for task_request %> <%= errors_summary_for task_request %>
<%= bootstrap_form_with model: model, local: true do |form| %> <%= bootstrap_form_with model: model, local: true do |form| %>
<%= form.select :status, options_for_select(TaskRequest.statuses.except(:cancelled).keys, task_request.status), { class: "form-control" } %> <%= form.select :status, options_for_select(TaskRequest.statuses.except(:cancelled).keys, task_request.status), {}, class: "form-control custom-select" %>
<%= form.text_field :deliverable_url %> <%= form.text_field :deliverable_url %>
<div class="row align-items-center text-center mt-4"> <div class="row align-items-center text-center mt-4">

View File

@@ -2,6 +2,12 @@
<td> <td>
<%= task_request.id %> <%= task_request.id %>
</td> </td>
<td>
<%= task_request.project.account.name %>
</td>
<td>
<%= task_request.project.name %>
</td>
<td> <td>
<%= task_request.created_at.strftime("%D") %> <%= task_request.created_at.strftime("%D") %>
</td> </td>
@@ -18,6 +24,7 @@
<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>

View File

@@ -3,6 +3,8 @@
<thead class="thead-light"> <thead class="thead-light">
<tr> <tr>
<th>Task ID</th> <th>Task ID</th>
<th>Account Name</th>
<th>Project Name</th>
<th>Created On</th> <th>Created On</th>
<th>Deadline</th> <th>Deadline</th>
<th>Time Allowed</th> <th>Time Allowed</th>
@@ -15,7 +17,7 @@
<%= render @task_requests %> <%= render @task_requests %>
<% else %> <% else %>
<tr> <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> </tr>
<% end %> <% end %>
</tbody> </tbody>

View File

@@ -0,0 +1,21 @@
<dl>
<%= description_list_pair_for @task_request.project.account, :name, custom_label: "Account Name", append: ":" %>
<%= description_list_pair_for @task_request.project, :name, custom_label: "Project Name", append: ":" %>
<%= description_list_pair_for @task_request, :description, append: ":" %>
<%= description_list_pair_for @task_request, :created_at, append: ":" %>
<%= description_list_pair_for @task_request, :user_email, 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>

View File

@@ -11,6 +11,12 @@
<hr class="divider-light mx-n4"> <hr class="divider-light mx-n4">
<nav> <nav>
<ul class="nav nav-pills nav-pills-dark flex-column"> <ul class="nav nav-pills nav-pills-dark flex-column">
<li class="nav-item">
<%= link_to [project, :task_requests], class: class_string("nav-link", "active" => controller_name == "task_requests") do %>
<%= lock_icon_for(Current.account, :taskme) %>
<%= product_wordmark :task_me, class: class_string("d-inline-block", "disabled" => !Current.account.taskme_enabled?) %>
<% end %>
</li>
<li class="nav-item"> <li class="nav-item">
<%= link_to [project, :contract_templates], class: class_string("nav-link", "active" => %w(contract_templates release_template_imports).include?(controller_name)) do %> <%= link_to [project, :contract_templates], class: class_string("nav-link", "active" => %w(contract_templates release_template_imports).include?(controller_name)) do %>
<%= lock_icon_for Current.account, :releaseme %> <%= lock_icon_for Current.account, :releaseme %>
@@ -35,12 +41,6 @@
<%= product_wordmark :deliver_me, class: class_string("d-inline-block", "disabled" => !Current.account.deliverme_enabled?) %> <%= product_wordmark :deliver_me, class: class_string("d-inline-block", "disabled" => !Current.account.deliverme_enabled?) %>
<% end %> <% end %>
</li> </li>
<li class="nav-item">
<%= link_to [project, :task_requests], class: class_string("nav-link", "active" => controller_name == "task_requests") do %>
<%= lock_icon_for(Current.account, :assistme) %>
<%= product_wordmark :assist_me, class: class_string("d-inline-block", "disabled" => !Current.account.assistme_enabled?) %>
<% end %>
</li>
</ul> </ul>
</nav> </nav>
<hr class="divider-light mx-n4"> <hr class="divider-light mx-n4">

View File

@@ -18,7 +18,7 @@
<% end %> <% end %>
<% if policy(Project).show_task_results? %> <% if policy(Project).show_task_results? %>
<%= render "folder_card" do %> <%= render "folder_card" do %>
<%= link_to t("projects.show.task_requests"), [@project, :task_requests, completed_only: true], class: "text-decoration-none text-reset stretched-link" %> <%= link_to t("projects.show.tasks"), [@project, :tasks], class: "text-decoration-none text-reset stretched-link" %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>

View File

@@ -1,11 +1,16 @@
<%= errors_summary_for task_request %> <%= errors_summary_for task_request %>
<%= bootstrap_form_with model: model, local: true do |form| %> <%= bootstrap_form_with model: model, local: true do |form| %>
<%= form.text_area :description %> <div class="alert alert-notice text-center pl-0 text-md-left mt-4">
<%= form.text_field :deadline, class: "datepicker-control" %> <%= fa_icon "info-circle" %>
<%= form.text_field :time_allowed %> <strong><%= t '.info_message' %></strong>
<%= form.text_area :additional_notes %> </div>
<%= field_set_tag content_tag(:span, "Files", class: "h6 text-muted text-uppercase") do %>
<%= form.text_area :description, label: t('.labels.description') %>
<%= form.text_field :deadline, class: "datepicker-control", label: t('.labels.deadline') %>
<%= form.text_field :time_allowed, label: t('.labels.time_allowed') %>
<%= form.text_area :additional_notes, label: t('.labels.additional_notes') %>
<%= field_set_tag content_tag(:span, t('.labels.files'), class: "h6 text-muted text-uppercase") do %>
<div class="field d-none"> <div class="field d-none">
<%= form.label :files %> <%= form.label :files %>
<%= form.file_field :files, disable: true, direct_upload: true, multiple: true, id: "task_request_files", hide_label: true %> <%= form.file_field :files, disable: true, direct_upload: true, multiple: true, id: "task_request_files", hide_label: true %>

View File

@@ -11,11 +11,6 @@
<td> <td>
<%= task_request.status.titleize %> <%= task_request.status.titleize %>
</td> </td>
<% if params[:completed_only] %>
<td>
<%= task_request.deliverable_url %>
</td>
<% end %>
<td class="text-right"> <td class="text-right">
<div class="btn-group"> <div class="btn-group">
<%= button_tag t(".actions.manage"), class: "btn btn-light btn-sm dropdown-toggle border", data: { toggle: "dropdown", boundary: "window" }, aria: { haspopup: true, expanded: false } %> <%= button_tag t(".actions.manage"), class: "btn btn-light btn-sm dropdown-toggle border", data: { toggle: "dropdown", boundary: "window" }, aria: { haspopup: true, expanded: false } %>
@@ -26,6 +21,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 %>

View File

@@ -1,4 +1,4 @@
<%= product_wordmark :assist_me, class: "small mb-3" %> <%= product_wordmark :task_me, class: "small mb-3" %>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@@ -18,9 +18,6 @@
<th><%= t(".table_headers.task_request_deadline") %></th> <th><%= t(".table_headers.task_request_deadline") %></th>
<th><%= t(".table_headers.task_request_time_allowed") %></th> <th><%= t(".table_headers.task_request_time_allowed") %></th>
<th><%= t(".table_headers.task_request_status") %></th> <th><%= t(".table_headers.task_request_status") %></th>
<% if params[:completed_only] %>
<th><%= t(".table_headers.task_request_results") %></th>
<% end %>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>

View File

@@ -0,0 +1,17 @@
<tr>
<td>
<%= task.created_at.strftime('%D') %>
</td>
<td>
<%= task.deadline.try(:strftime, '%D') %>
</td>
<td>
<%= task.time_allowed %>
</td>
<td>
<%= task.status.titleize %>
</td>
<td>
<%= link_to "View Deliverable", task.deliverable_url, target: "_blank" %>
</td>
</tr>

View File

@@ -0,0 +1,26 @@
<div class="border bg-white rounded shadow-sm pb-3 table-responsive">
<table class="table table-striped tr-px-4 align-all-middle">
<thead class="thead-light">
<tr>
<th><%= t(".table_headers.task_request_created_on") %></th>
<th><%= t(".table_headers.task_request_deadline") %></th>
<th><%= t(".table_headers.task_request_time_allowed") %></th>
<th><%= t(".table_headers.task_request_status") %></th>
<th><%= t(".table_headers.task_request_results") %></th>
</tr>
</thead>
<tbody id="task_requests">
<% if @tasks.any? %>
<%= render partial: "task", collection: @tasks %>
<% else %>
<tr>
<td colspan="5" class="py-4 text-center text-muted"><%= t(".empty") %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div id="task_requests_pagination" class="mt-3">
<%= will_paginate @tasks %>
</div>

View File

@@ -734,7 +734,7 @@ en:
music_release: Music Releases (%{count}) music_release: Music Releases (%{count})
report: Reports report: Reports
talent_release: Talent Releases (%{count}) talent_release: Talent Releases (%{count})
task_requests: Tasks tasks: Tasks
public: public:
acquired_media_releases: acquired_media_releases:
new: new:
@@ -875,7 +875,6 @@ en:
title: Sign In title: Sign In
shared: shared:
ago: ago ago: ago
assist_me: Assist
back: Back back: Back
cancel: Cancel cancel: Cancel
clear: Clear clear: Clear
@@ -901,6 +900,7 @@ en:
tag_multiple_releases: Add Tag tag_multiple_releases: Add Tag
tag_multiple_releases_form: tag_multiple_releases_form:
submit: Add submit: Add
task_me: Task
tags: tags:
form: form:
submit: Add submit: Add
@@ -944,6 +944,14 @@ en:
edit: edit:
heading: heading:
Edit Task Request Edit Task Request
form:
labels:
additional_notes: Please add any additional notes we should be aware of regarding this task.
deadline: What is the deadline for this task?
description: Please describe the task.
files: Please attach any files related to this task
time_allowed: How many hours would like spend on this task?
info_message: After submitting this task request, you'll be connected via chat with a ME Suite representative.
index: index:
actions: actions:
new: Create Task Request new: Create Task Request
@@ -959,8 +967,18 @@ 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.
tasks:
index:
empty: Tasks will appear here.
table_headers:
task_request_created_on: Created On
task_request_deadline: Deadline
task_request_results: Task Results
task_request_status: Status
task_request_time_allowed: Time Allowed
user_mailer: user_mailer:
existing_account: existing_account:
subject: You've been added as a ME Suite Account Manager subject: You've been added as a ME Suite Account Manager

View File

@@ -182,3 +182,10 @@ 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)
form:
info_message: After submitting this task request, you'll be connected via chat with a ME Suite representative. (ES)

View File

@@ -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] resources :task_requests, only: [:index, :edit, :update, :show]
root to: "accounts#index", as: :signed_in_root root to: "accounts#index", as: :signed_in_root
end end
@@ -103,6 +103,7 @@ Rails.application.routes.draw do
post :cancel post :cancel
end end
end end
resources :tasks, only: :index
end end
resource :profile, only: [:show, :update] resource :profile, only: [:show, :update]
resources :videos, only: [] do resources :videos, only: [] do

View File

@@ -0,0 +1,5 @@
class AddUserEmailToTaskRequests < ActiveRecord::Migration[6.0]
def change
add_column :task_requests, :user_email, :string
end
end

View File

@@ -37,20 +37,20 @@ CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams'; COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';
-- --
-- Name: pg_search_dmetaphone(text); Type: FUNCTION; Schema: public; Owner: - -- Name: pg_search_dmetaphone(text); Type: FUNCTION; Schema: public; Owner: -
-- --
CREATE FUNCTION public.pg_search_dmetaphone(text) RETURNS text CREATE FUNCTION public.pg_search_dmetaphone(text) RETURNS text
LANGUAGE sql IMMUTABLE STRICT LANGUAGE sql IMMUTABLE STRICT
AS $_$ AS $_$
SELECT array_to_string(ARRAY(SELECT dmetaphone(unnest(regexp_split_to_array($1, E'\\s+')))), ' ') SELECT array_to_string(ARRAY(SELECT dmetaphone(unnest(regexp_split_to_array($1, E'\\s+')))), ' ')
$_$; $_$;
SET default_tablespace = ''; SET default_tablespace = '';
SET default_table_access_method = heap; SET default_with_oids = false;
-- --
-- Name: account_auths; Type: TABLE; Schema: public; Owner: - -- Name: account_auths; Type: TABLE; Schema: public; Owner: -
@@ -615,15 +615,6 @@ CREATE SEQUENCE public.contract_templates_id_seq
ALTER SEQUENCE public.contract_templates_id_seq OWNED BY public.contract_templates.id; ALTER SEQUENCE public.contract_templates_id_seq OWNED BY public.contract_templates.id;
--
-- Name: data_migrations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.data_migrations (
version character varying NOT NULL
);
-- --
-- Name: directories; Type: TABLE; Schema: public; Owner: - -- Name: directories; Type: TABLE; Schema: public; Owner: -
-- --
@@ -1181,6 +1172,7 @@ CREATE TABLE public.settings (
-- --
CREATE SEQUENCE public.settings_id_seq CREATE SEQUENCE public.settings_id_seq
AS integer
START WITH 1 START WITH 1
INCREMENT BY 1 INCREMENT BY 1
NO MINVALUE NO MINVALUE
@@ -1216,6 +1208,7 @@ CREATE TABLE public.taggings (
-- --
CREATE SEQUENCE public.taggings_id_seq CREATE SEQUENCE public.taggings_id_seq
AS integer
START WITH 1 START WITH 1
INCREMENT BY 1 INCREMENT BY 1
NO MINVALUE NO MINVALUE
@@ -1246,6 +1239,7 @@ CREATE TABLE public.tags (
-- --
CREATE SEQUENCE public.tags_id_seq CREATE SEQUENCE public.tags_id_seq
AS integer
START WITH 1 START WITH 1
INCREMENT BY 1 INCREMENT BY 1
NO MINVALUE NO MINVALUE
@@ -1340,7 +1334,8 @@ CREATE TABLE public.task_requests (
status integer DEFAULT 0, status integer DEFAULT 0,
created_at timestamp(6) without time zone NOT NULL, created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL,
deliverable_url character varying deliverable_url character varying,
user_email character varying
); );
@@ -1596,9 +1591,9 @@ CREATE TABLE public.zoom_meetings (
created_at timestamp(6) without time zone NOT NULL, created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL,
broadcast_id bigint, broadcast_id bigint,
status integer DEFAULT 0,
zoom_user_id bigint, zoom_user_id bigint,
project_id bigint project_id bigint,
status integer DEFAULT 0
); );
@@ -2052,14 +2047,6 @@ ALTER TABLE ONLY public.contract_templates
ADD CONSTRAINT contract_templates_pkey PRIMARY KEY (id); ADD CONSTRAINT contract_templates_pkey PRIMARY KEY (id);
--
-- Name: data_migrations data_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.data_migrations
ADD CONSTRAINT data_migrations_pkey PRIMARY KEY (version);
-- --
-- Name: directories directories_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- Name: directories directories_pkey; Type: CONSTRAINT; Schema: public; Owner: -
-- --
@@ -3560,4 +3547,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200507110804'), ('20200507110804'),
('20200512161738'), ('20200512161738'),
('20200518200245'), ('20200518200245'),
('20200519191908'); ('20200519191908'),
('20200610143327');

View File

@@ -118,7 +118,7 @@ RSpec.describe TaskRequestsController, type: :controller do
private private
def task_request_params def task_request_params
attributes = attributes_for(:task_request).except(:status) attributes = attributes_for(:task_request).except(:status, :user_email)
files = 2.times.map { Rack::Test::UploadedFile.new(file_fixture("location_photo.png"), "image/png") } files = 2.times.map { Rack::Test::UploadedFile.new(file_fixture("location_photo.png"), "image/png") }
attributes.merge({ files: files }) attributes.merge({ files: files })

View File

@@ -0,0 +1,40 @@
require 'rails_helper'
RSpec.describe TasksController, type: :controller do
render_views
let(:user) { create(:user) }
let(:account) { user.primary_account }
let(:project) { create(:project, account: user.primary_account) }
before do
sign_in user
end
describe "#index" do
it "responds successfully" do
get :index, params: { project_id: project }
expect(response).to be_successful
end
it "renders content" do
create(:task_request, :completed, project: project, description: "Another Request")
get :index, params: { project_id: project }
expect(response.body).to have_content "Completed"
expect(response.body).to have_link "View Deliverable"
end
context "when there are many records" do
it "paginates the table" do
create_list(:task_request, 20, :completed, project: project)
get :index, params: { project_id: project }
expect(response.body).to have_link("2", href: project_tasks_path(project, page: 2))
end
end
end
end

View File

@@ -1,11 +1,17 @@
FactoryBot.define do FactoryBot.define do
factory :task_request do factory :task_request do
association :project association :project
user_email 'test@email.com'
deadline { 10.days.from_now } deadline { 10.days.from_now }
time_allowed "10 days" time_allowed "10 days"
description "Task request" description "Task request"
additional_notes "Additional notes" additional_notes "Additional notes"
status 0 status 0
trait :completed do
deliverable_url "example.com/deliverables"
status 1
end
trait :with_files do trait :with_files do
files { [Rack::Test::UploadedFile.new('spec/fixtures/files/contract.pdf', 'application/pdf')] } files { [Rack::Test::UploadedFile.new('spec/fixtures/files/contract.pdf', 'application/pdf')] }

View File

@@ -0,0 +1,108 @@
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 'Account Name'
expect(page).to have_content task_request.project.account.name
expect(page).to have_content 'Project Name'
expect(page).to have_content task_request.project.name
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 'User Email'
expect(page).to have_content task_request.user_email
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
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

@@ -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