Compare commits

..

10 Commits

Author SHA1 Message Date
Senad Uka
71ad502cc1 Taskme update 2020-06-30 05:08:23 +02:00
Senad Uka
1cd125382f Task me sync 2020-06-26 04:57:23 +02:00
Senad Uka
749aad3467 Task me upstream sync 2020-06-25 08:47:10 +02:00
Senad Uka
c167889ea3 Upstream sync task me mvp 2020-06-24 04:49:28 +02:00
Senad Uka
3e917c29f0 task me sync 2020-06-19 12:32:50 +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
Senad Uka
88836e937e Task me sync 2020-06-03 07:24:01 +02:00
bilal
e3d4d22a34 Handle QrMatching response - mock 2020-06-02 22:23:19 +02:00
Senad Uka
3690268f83 Sync of the branch 2020-06-01 18:59:15 +02:00
54 changed files with 1455 additions and 26 deletions

View File

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

View File

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

View File

@@ -17,7 +17,7 @@ class AccountsController < ApplicationController
if sign_in(user)
TrackAnalyticsJob.perform_later(user, user.primary_account, :track_guest_sign_up, user_agent: request.user_agent, user_ip: request.remote_ip)
SubmitHubspotFormJob.perform_later(user.first_name, user.last_name, user.email, account.name, i_m_interested_in: user.interested_product_name)
SubmitHubspotFormJob.perform_later(user.email, account.name, i_m_interested_in: user.interested_product_name)
redirect_to signed_in_root_path
else
redirect_to new_session_path, alert: t(".notice")

View File

@@ -0,0 +1,36 @@
class Admin::TaskRequestsController < Admin::ApplicationController
before_action :set_task_request, only: [:edit, :update, :show]
def index
@task_requests = task_requests.order_by_recent.paginate(page: params[:page])
end
def edit
end
def show
@files = @task_request.files.paginate(page: params[:page])
end
def update
if @task_request.update(task_request_params)
redirect_to [:admin, :task_requests], notice: t(".notice")
else
render :edit
end
end
private
def task_request_params
params.require(:task_request).permit(:status, :deliverable_url)
end
def task_requests
policy_scope TaskRequest
end
def set_task_request
@task_request = authorize policy_scope(TaskRequest).find(params[:id])
end
end

View File

@@ -0,0 +1,76 @@
class TaskRequestsController < ApplicationController
layout "project"
before_action :set_project
before_action :build_task_request, only: [:new, :create]
before_action :set_task_request, only: [:show, :edit, :update, :cancel]
def index
@task_requests = task_requests.order_by_recent.paginate(page: params[:page])
end
def new
end
def create
@task_request.attributes = task_request_params_with_email
if @task_request.save
log_create_analytics
taskme_url = url_for([:admin, @task_request])
SubmitHubspotTaskRequestFormJob.perform_later(@task_request.user_email, taskme_url)
else
render :new
end
end
def show
@files = @task_request.files.paginate(page: params[:page])
end
def edit
end
def update
if @task_request.update(task_request_params)
redirect_to [@project, :task_requests], notice: t(".notice")
else
render :edit
end
end
def cancel
@task_request.cancelled!
redirect_to [@project, :task_requests], notice: t(".notice")
end
private
def task_request_params
params.require(:task_request).permit(:description, :deadline, :time_allowed, :additional_notes, files: [])
end
def task_request_params_with_email
task_request_params.merge(user_email: Current.user.email)
end
def set_project
@project = policy_scope(Project).find(params[:project_id])
end
def set_task_request
@task_request = authorize policy_scope(TaskRequest).find(params[:id])
end
def task_requests
authorize policy_scope(@project.task_requests)
end
def build_task_request
@task_request = authorize @project.task_requests.build
end
def log_create_analytics
TrackAnalyticsJob.perform_later(Current.user, Current.account, :track_create_task_request, user_agent: request.user_agent, user_ip: request.remote_ip)
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)
end
def description_list_pair_for(record, attribute, append: nil)
term = translation_for(record, attribute)
def description_list_pair_for(record, attribute, append: nil, custom_label: nil)
term = custom_label.nil? ? translation_for(record, attribute) : custom_label
definition = record.send(attribute)
description_list_pair(term, definition, append: append)

View File

@@ -11,6 +11,8 @@ module DropzoneHelper
t 'location_releases.form.photos.dropzone_label'
when "directory"
"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
"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

View File

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

View File

@@ -1,14 +1,12 @@
class SubmitHubspotFormJob < ApplicationJob
queue_as :default
def perform(first_name, last_name, email, company_name, additional_params = {})
def perform(email, company_name, additional_params = {})
hubspot_form_guid = ENV["HUBSPOT_FORM_GUID"]
return unless hubspot_form_guid.present?
submission_params = {
first_name: first_name,
last_name: last_name,
email: email,
email: email,
company: company_name
}.merge(additional_params)

View File

@@ -0,0 +1,18 @@
class SubmitHubspotTaskRequestFormJob < ApplicationJob
queue_as :default
def perform(user_email, taskme_url)
hubspot_task_request_form_guid = ENV["HUBSPOT_TASK_REQUEST_FORM_GUID"]
return unless hubspot_task_request_form_guid.present?
submission_params = {
email: user_email,
taskme_url: taskme_url
}
form = Hubspot::Form.new("guid" => hubspot_task_request_form_guid)
is_form_sumitted = form.submit(submission_params)
raise StandardError.new "Failed to submit the task request hubspot form data: #{is_form_sumitted}" unless is_form_sumitted
end
end

View File

@@ -54,6 +54,7 @@ class Account < ApplicationRecord
Download.where(project: projects),
User.joins(:project_memberships).where(project_memberships: { project: projects }),
Broadcast.where(project: projects),
TaskRequest.where(project: projects),
ZoomMeeting.where(project: projects),
MedicalRelease.where(project: projects),
MiscRelease.where(project: projects),
@@ -82,6 +83,10 @@ class Account < ApplicationRecord
plan_uid.to_s == "me_suite" || plan_uid.to_s == "releaseme"
end
def taskme_enabled?
plan_uid.to_s == "me_suite" || plan_uid.to_s == "taskme"
end
def plan_name
case plan_uid.to_s
when "deliverme"
@@ -90,6 +95,8 @@ class Account < ApplicationRecord
"DirectME"
when "releaseme"
"ReleaseME"
when "taskme"
"TaskME"
when "me_suite"
"ME Suite"
end

View File

@@ -24,6 +24,7 @@ class Project < ApplicationRecord
has_many :downloads, dependent: :destroy
has_many :broadcasts, dependent: :destroy
has_many :zoom_meetings, dependent: :destroy
has_many :task_requests, dependent: :destroy
accepts_nested_attributes_for :project_memberships

View File

@@ -0,0 +1,10 @@
class TaskRequest < ApplicationRecord
belongs_to :project
has_many_attached :files
enum status: [:pending, :completed, :cancelled]
scope :order_by_recent, -> { order(created_at: :desc) }
validates :time_allowed, numericality: { only_integer: true, greater_than_or_equal_to: 2 }
end

View File

@@ -36,4 +36,8 @@ class ProjectPolicy < ApplicationPolicy
def show_downloads?
show?
end
def show_task_results?
show?
end
end

View File

@@ -0,0 +1,29 @@
class TaskRequestPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
true
end
def destroy?
true
end
def update?
true
end
def cancel?
true
end
def open_deliverable?
true
end
end

View File

@@ -151,6 +151,24 @@ class Analytics
)
end
end
def track_create_task_request(user_agent:, user_ip:)
if analytics_enabled?
identify
track(
{
user_id: user.id,
event: "Task request created",
properties: {
account: account.try(:name),
account_id: account.try(:id),
user_agent: user_agent,
ip: user_ip,
},
}
)
end
end
private

View File

@@ -7,6 +7,9 @@
<li class="nav-item">
<%= link_to fa_icon("users fw", text: "Users"), [:admin, :users], class: class_string("nav-link", "active" => controller_name == "users") %>
</li>
<li class="nav-item">
<%= link_to fa_icon("tasks fw", text: "Task Requests"), [:admin, :task_requests], class: class_string("nav-link", "active" => controller_name == "task_requests") %>
</li>
<li class="nav-item">
<%= link_to fa_icon("bug fw", text: "Errors"), "https://sentry.io/bigmedia/", class: "nav-link", target: :_blank %>
</li>

View File

@@ -0,0 +1,13 @@
<%= errors_summary_for task_request %>
<%= 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 custom-select" %>
<%= form.text_field :deliverable_url %>
<div class="row align-items-center text-center mt-4">
<%= link_to t("shared.cancel"), [:admin, :task_requests], class: "col-3 text-reset" %>
<div class="col-9">
<%= form.submit class: class_string("btn btn-block", ["btn-success", "btn-primary"] => task_request.new_record?), data: { disable_with: t("shared.disable_with") } %>
</div>
</div>
<% end %>

View File

@@ -0,0 +1,32 @@
<tr id="<%= dom_id(task_request) %>">
<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>
<td>
<%= task_request.deadline.try(:strftime, '%D') %>
</td>
<td>
<%= task_request.time_allowed %>
</td>
<td>
<%= task_request.status.titleize %>
</td>
<td class="text-right">
<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>
</td>
</tr>

View File

@@ -0,0 +1,6 @@
<div class="card shadow-sm">
<%= card_header text: "Edit Task Request", close_action_path: [:admin, :task_requests] %>
<div class="card-body">
<%= render "form", model: [:admin, @task_request], task_request: @task_request %>
</div>
</div>

View File

@@ -0,0 +1,25 @@
<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>Task ID</th>
<th>Account Name</th>
<th>Project Name</th>
<th>Created On</th>
<th>Deadline</th>
<th>Time Allowed</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody id="users">
<% if @task_requests.any? %>
<%= render @task_requests %>
<% else %>
<tr>
<td colspan="20" class="py-4 text-center text-muted"><%= t(".empty") %></td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@@ -0,0 +1,49 @@
<div class="card shadow-sm">
<%= card_header text: "Task Details", close_action_path: [:admin, :task_requests] %>
<div class="card-body">
<div class="row">
<div class="col-md-6 col-sm-12">
<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, :created_at, append: ":" %>
<%= description_list_pair_for @task_request, :user_email, append: ":" %>
<%= description_list_pair_for @task_request, :status, append: ":" %>
</dl>
</div>
<div class="col-md-6 col-sm-12">
<dl>
<%= description_list_pair_for @task_request, :deadline, append: ":" %>
<%= description_list_pair_for @task_request, :time_allowed, append: ":" %>
<%= description_list_pair_for @task_request, :description, append: ":" %>
<%= description_list_pair_for @task_request, :additional_notes, append: ":" %>
</dl>
</div>
<div class="col-md-12">
<h2 class="h6 mt-3">Files:</h2>
<div class="pt-2 mx-n3">
<table class="table table-striped tr-px-4 align-all-middle">
<thead class="thead-light">
<tr>
<th>Filename</th>
<th></th>
</tr>
</thead>
<tbody id="task_requests">
<% if @files.any? %>
<%= render partial: "task_requests/file", collection: @files %>
<% else %>
<tr>
<td colspan="12" class="py-4 text-center text-muted"><%= t(".empty") %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="mt-4" id="task_requests_pagiantion">
<%= will_paginate @files %>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -11,6 +11,12 @@
<hr class="divider-light mx-n4">
<nav>
<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">
<%= 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 %>

View File

@@ -16,6 +16,11 @@
<%= link_to t("projects.show.downloads"), [@project, :downloads], class: "text-decoration-none text-reset stretched-link" %>
<% end %>
<% end %>
<% if policy(Project).show_task_results? %>
<%= render "folder_card" do %>
<%= link_to t("projects.show.tasks"), [@project, :tasks], class: "text-decoration-none text-reset stretched-link" %>
<% end %>
<% end %>
</div>
<hr/>

View File

@@ -0,0 +1,6 @@
<tr>
<td><%= file.filename %></td>
<td class="text-right">
<%= link_to fa_icon("download"), file, target: "_blank" %>
</td>
</tr>

View File

@@ -0,0 +1,39 @@
<%= errors_summary_for task_request %>
<%= bootstrap_form_with model: model, url: [@project, @task_request, show_chat: true], local: true do |form| %>
<div class="alert alert-info text-center text-md-left">
<%= fa_icon "info-circle" %>
<strong><%= t '.info_message' %></strong>
</div>
<%= form.text_area :description, label: t('.labels.description') %>
<%= form.text_field :deadline, class: "datepicker-control", label: t('.labels.deadline') %>
<%= form.number_field :time_allowed, label: t('.labels.time_allowed'), min: 2, step: 1, pattern: "\d+" %>
<%= 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">
<%= form.label :files %>
<%= form.file_field :files, disable: true, direct_upload: true, multiple: true, id: "task_request_files", hide_label: true %>
<% task_request.files.each do |file| %>
<% unless file.persisted? %>
<%= hidden_field_tag "#{task_request.model_name.param_key}[files][]", file.signed_id %>
<% end %>
<% end %>
</div>
<div class="dropzone field border-dashed"
data-accepted-files="audio/*,image/*,video/*,application/*"
data-behavior="dropzone"
data-file-input-id="task_request_files"
data-existing-files="<%= mock_photos_json(task_request.files) %>"
data-placeholder="<%= dropzone_placeholder_message_for(task_request) %>"
data-submit-button="#submit_folder"></div>
<% end %>
<div class="row align-items-center text-center mt-4">
<%= link_to t("shared.cancel"), [project, :task_requests], class: "col-3 text-reset" %>
<div class="col-9">
<%= form.submit class: class_string("btn btn-block", ["btn-success", "btn-primary"] => task_request.new_record?), data: { disable_with: t("shared.disable_with") } %>
</div>
</div>
<% end %>

View File

@@ -0,0 +1,45 @@
<tr>
<td>
<%= task_request.created_at.strftime('%D') %>
</td>
<td>
<%= task_request.deadline.try(:strftime, '%D') %>
</td>
<td>
<%= truncate(task_request.description) {
link_to t('.actions.read_more'),
'#',
class: 'alert-link',
data: {
toggle: "popover",
content: task_request.description,
trigger: "hover"
}
} %>
</td>
<td>
<%= task_request.time_allowed %>
</td>
<td>
<%= task_request.status.titleize %>
</td>
<td class="text-right">
<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 } %>
<div class="dropdown-menu dropdown-menu-right">
<% if policy(task_request).show? %>
<%= link_to fa_icon("tasks fw", text: "View"), [task_request.project, task_request], class: "dropdown-item", target: '_blank' %>
<% end %>
<% 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 %>
</div>
</div>
</td>
</tr>

View File

@@ -0,0 +1,15 @@
<% if params[:show_chat] %>
<%= javascript_include_tag "//js.hs-scripts.com/7344617.js", defer: "defer", async: true, id: "hs-script-loader" %>
<%= javascript_tag nonce: true do %>
function onConversationsAPIReady() {
window.HubSpotConversations.widget.load({ widgetOpen: true });
window.HubSpotConversations.widget.open();
}
if (window.HubSpotConversations) {
onConversationsAPIReady();
} else {
window.hsConversationsOnReady = [onConversationsAPIReady];
}
<% end %>
<% end %>
<p class="alert alert-success p-3 lead text-center"><%= t '.success_message' %></p>

View File

@@ -0,0 +1,6 @@
<div class="card shadow-sm">
<%= card_header text: t(".heading"), close_action_path: [@project, :task_requests] %>
<div class="card-body">
<%= render "form", model: [@project, @task_request], task_request: @task_request, project: @project %>
</div>
</div>

View File

@@ -0,0 +1,39 @@
<%= product_wordmark :task_me, class: "small mb-3" %>
<div class="row">
<div class="col-md-12">
<div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3">
<% if policy(TaskRequest).new? %>
<%= link_to fa_icon("plus", text: t(".actions.new")), [:new, @project, :task_request], class: "btn btn-primary mb-2" %>
<% end %>
</div>
</div>
</div>
<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_description") %></th>
<th><%= t(".table_headers.task_request_time_allowed") %></th>
<th><%= t(".table_headers.task_request_status") %></th>
<th></th>
</tr>
</thead>
<tbody id="task_requests">
<% if @task_requests.any? %>
<%= render @task_requests %>
<% else %>
<tr>
<td colspan="20" 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 @task_requests %>
</div>

View File

@@ -0,0 +1,6 @@
<div class="card shadow-sm">
<%= card_header text: t(".heading"), close_action_path: [@project, :task_requests] %>
<div class="card-body">
<%= render "form", model: [@project, @task_request], task_request: @task_request, project: @project %>
</div>
</div>

View File

@@ -0,0 +1,46 @@
<div class="card shadow-sm">
<%= card_header text: "Task Details", close_action_path: [@project, :task_requests] %>
<div class="card-body">
<div class="row">
<div class="col-md-6 col-sm-12">
<dl>
<%= description_list_pair_for @task_request, :description, append: ":" %>
<%= description_list_pair_for @task_request, :created_at, append: ":" %>
<%= description_list_pair_for @task_request, :status, append: ":" %>
</dl>
</div>
<div class="col-md-6 col-sm-12">
<dl>
<%= 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: ":" %>
</dl>
</div>
<div class="col-md-12">
<h2 class="h6 mt-3">Files:</h2>
<div class="pt-2 mx-n3">
<table class="table table-striped tr-px-4 align-all-middle">
<thead class="thead-light">
<tr>
<th>Filename</th>
<th></th>
</tr>
</thead>
<tbody id="task_requests">
<% if @files.any? %>
<%= render partial: "file", collection: @files %>
<% else %>
<tr>
<td colspan="12" class="py-4 text-center text-muted"><%= t(".empty") %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="mt-4" id="task_requests_pagiantion">
<%= will_paginate @files %>
</div>
</div>
</div>
</div>
</div>
</div>

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

@@ -97,6 +97,13 @@ en:
application:
header:
sign_out: Sign Out
task_requests:
index:
empty: Task requests will appear here
show:
empty: Attached files will appear here.
update:
notice: The task request has been updated successfully
users:
create:
notice: The user was created
@@ -317,6 +324,8 @@ en:
notice: The release has been updated
helpers:
help:
task_request:
time_allowed: Minimum of 2 hours, no partial hours allowed
contract_template:
fee: Leave at $0.00 for no-fee
guardian_clause: Leave blank if not required for this contract
@@ -867,6 +876,7 @@ en:
music_release: Music Releases (%{count})
report: Reports
talent_release: Talent Releases (%{count})
tasks: Tasks
public:
acquired_media_releases:
new:
@@ -1118,6 +1128,7 @@ en:
tag_multiple_releases: Add Tag
tag_multiple_releases_form:
submit: Add
task_me: Task
tags:
form:
submit: Add
@@ -1159,6 +1170,54 @@ en:
manage: Manage
update:
notice: The talent release has been updated
task_requests:
cancel:
notice: Task has been cancelled successfully.
create:
notice: Task request created succussfully.
success_message: Your task request was successfully submitted. Thank you. A chat window will pop up on the lower right in a few seconds.
edit:
heading:
Edit Task Request
form:
info_message: After submitting this task request, you'll be connected via chat with a ME Suite representative.
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 you like a TaskME representative to work on this task?
index:
actions:
new: Create Task Request
empty: Task requests will appear here.
table_headers:
task_request_created_on: Created On
task_request_deadline: Deadline
task_request_description: Description
task_request_results: Task Results
task_request_status: Status
task_request_time_allowed: Time Allowed
new:
heading: New Task Request
show:
empty: Attached files will appear here.
task_request:
actions:
manage: Manage
open_deliverable: Open Deliverable
read_more: read more
update:
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:
existing_account:
subject: You've been added as a ME Suite Account Manager

View File

@@ -350,3 +350,16 @@ es:
heading: Second Guardian Photo (ES)
guardian_photo:
heading: Guardian Photo (ES)
task_requests:
create:
success_message: Your task request was successfully submitted. Thank you. A chat window will pop up on the lower right in a few seconds. (ES)
form:
info_message: After submitting this task request, you'll be connected via chat with a ME Suite representative. (ES)
index:
table_headers:
task_request_description: Description (ES)
task_request:
actions:
manage: Manage (ES)
open_deliverable: Open Deliverable (ES)
read_more: read more (ES)

View File

@@ -31,6 +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]
root to: "accounts#index", as: :signed_in_root
end
@@ -99,6 +100,12 @@ Rails.application.routes.draw do
delete :destroy_file
end
end
resources :task_requests, except: :destroy do
member do
post :cancel
end
end
resources :tasks, only: :index
end
resource :profile, only: [:show, :update]
resources :videos, only: [] do

View File

@@ -0,0 +1,14 @@
class CreateTaskRequests < ActiveRecord::Migration[6.0]
def change
create_table :task_requests do |t|
t.references :project
t.text :description
t.datetime :deadline
t.string :time_allowed
t.text :additional_notes
t.integer :status, default: 0
t.timestamps
end
end
end

View File

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

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

@@ -9,6 +9,20 @@ SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
--
-- Name: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: -
--
@@ -317,8 +331,8 @@ CREATE TABLE public.appearance_releases (
person_last_name character varying,
guardian_first_name character varying,
guardian_last_name character varying,
identifier character varying,
guardian_email character varying,
identifier character varying,
person_address_street2 character varying,
person_address_city character varying,
person_address_state character varying,
@@ -652,6 +666,15 @@ CREATE SEQUENCE public.contract_templates_id_seq
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: -
--
@@ -1378,7 +1401,6 @@ CREATE TABLE public.settings (
--
CREATE SEQUENCE public.settings_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1414,7 +1436,6 @@ CREATE TABLE public.taggings (
--
CREATE SEQUENCE public.taggings_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1445,7 +1466,6 @@ CREATE TABLE public.tags (
--
CREATE SEQUENCE public.tags_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1536,6 +1556,44 @@ CREATE SEQUENCE public.talent_releases_id_seq
ALTER SEQUENCE public.talent_releases_id_seq OWNED BY public.talent_releases.id;
--
-- Name: task_requests; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.task_requests (
id bigint NOT NULL,
project_id bigint,
description text,
deadline timestamp without time zone,
time_allowed character varying,
additional_notes text,
status integer DEFAULT 0,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
deliverable_url character varying,
user_email character varying
);
--
-- Name: task_requests_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.task_requests_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: task_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.task_requests_id_seq OWNED BY public.task_requests.id;
--
-- Name: terms; Type: TABLE; Schema: public; Owner: -
--
@@ -1768,9 +1826,9 @@ CREATE TABLE public.zoom_meetings (
api_meeting_id character varying,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
status integer DEFAULT 0,
zoom_user_id bigint,
project_id bigint,
status integer DEFAULT 0
project_id bigint
);
@@ -2064,6 +2122,13 @@ ALTER TABLE ONLY public.tags ALTER COLUMN id SET DEFAULT nextval('public.tags_id
ALTER TABLE ONLY public.talent_releases ALTER COLUMN id SET DEFAULT nextval('public.talent_releases_id_seq'::regclass);
--
-- Name: task_requests id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.task_requests ALTER COLUMN id SET DEFAULT nextval('public.task_requests_id_seq'::regclass);
--
-- Name: terms id; Type: DEFAULT; Schema: public; Owner: -
--
@@ -2240,6 +2305,14 @@ ALTER TABLE ONLY public.contract_templates
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: -
--
@@ -2408,6 +2481,14 @@ ALTER TABLE ONLY public.talent_releases
ADD CONSTRAINT talent_releases_pkey PRIMARY KEY (id);
--
-- Name: task_requests task_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.task_requests
ADD CONSTRAINT task_requests_pkey PRIMARY KEY (id);
--
-- Name: terms terms_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@@ -3046,6 +3127,13 @@ CREATE INDEX index_talent_releases_on_term_id ON public.talent_releases USING bt
CREATE INDEX index_talent_releases_on_territory_id ON public.talent_releases USING btree (territory_id);
--
-- Name: index_task_requests_on_project_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_task_requests_on_project_id ON public.task_requests USING btree (project_id);
--
-- Name: index_unreleased_appearances_on_video_id; Type: INDEX; Schema: public; Owner: -
--
@@ -3810,11 +3898,14 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200430190412'),
('20200507110804'),
('20200512161738'),
('20200518200245'),
('20200519191908'),
('20200526113516'),
('20200603090419'),
('20200606044747'),
('20200610085411'),
('20200610140459'),
('20200610143327'),
('20200612121539'),
('20200615131722'),
('20200615133602'),

View File

@@ -57,8 +57,6 @@ RSpec.describe AccountsController, type: :controller do
expect {
post :create, params: params
}.to have_enqueued_job(SubmitHubspotFormJob).with(
"John",
"Doe",
"test_user+1@test.com",
"Test Dev account",
i_m_interested_in: "DirectME"

View File

@@ -0,0 +1,68 @@
require "rails_helper"
RSpec.describe Admin::TaskRequestsController, type: :controller do
render_views
let!(:current_user) { create(:user, :admin) }
before do
sign_in(current_user)
end
describe "#index" do
it "returns a successful response" do
get :index
expect(response).to be_successful
end
end
describe "#edit" do
let(:task_request) { create(:task_request) }
it "returns a successful response" do
get :edit, params: { id: task_request }
expect(response).to be_successful
end
it "assigns task request" do
get :edit, params: { id: task_request }
expect(assigns(:task_request)).to eq task_request
end
end
describe "#update" do
let(:task_request) { create(:task_request) }
it "redirects to task requests page" do
patch :update, params: { id: task_request, task_request: update_params }
expect(response).to be_redirect
expect(response).to redirect_to admin_task_requests_path
end
it "sets a flash notice" do
patch :update, params: { id: task_request, task_request: update_params }
expect(flash.notice).to eq "The task request has been updated successfully"
end
it "updates task request" do
patch :update, params: { id: task_request, task_request: update_params }
expect(task_request.reload.status).to eq("completed")
expect(task_request.reload.deliverable_url).to eq("example.com/deliverables")
end
end
private
def update_params
{
status: "completed",
deliverable_url: "example.com/deliverables"
}
end
end

View File

@@ -0,0 +1,129 @@
require 'rails_helper'
RSpec.describe TaskRequestsController, 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, project: project, description: "Another Request")
get :index, params: { project_id: project }
expect(response.body).to have_link "Create Task Request"
expect(response.body).to have_content "Pending"
end
context "when there are many records" do
it "paginates the table" do
create_list(:task_request, 20, project: project)
get :index, params: { project_id: project }
expect(response.body).to have_link("2", href: project_task_requests_path(project, page: 2))
end
end
end
describe "#new" do
it "responds successfully" do
get :new, params: { project_id: project }
expect(response).to be_successful
expect(assigns(:task_request)).to be_a_new(TaskRequest)
expect(response).to render_template(:new)
end
end
describe "#create" do
it "does create a new record" do
expect {
post :create, params: { project_id: project.id, task_request: task_request_params }
}.to change(TaskRequest, :count)
end
it "logs an event" do
expect {
post :create, params: { project_id: project.id, task_request: task_request_params }
}.to have_enqueued_job(TrackAnalyticsJob).with(user, account, :track_create_task_request, user_agent: "Rails Testing", user_ip: "0.0.0.0")
end
it "submits data to hubspot form" do
expect {
post :create, params: { project_id: project.id, task_request: task_request_params }
}.to have_enqueued_job(SubmitHubspotTaskRequestFormJob)
end
end
describe "#update" do
let!(:task_request) { create(:task_request, project: project, description: "My description" ) }
it "updates task request" do
patch :update, params: { project_id: project.id, id: task_request.id, task_request: update_params }
expect(task_request.reload.description).to eq("This is updated description")
end
end
describe "#show" do
let!(:task_request) { create(:task_request, project: project, description: "Task Request") }
it "responds successfully" do
get :show, params: { project_id: project.id, id: task_request.id }
expect(response).to be_successful
expect(assigns(:task_request)).to eq(task_request)
end
it "renders content" do
get :show, params: { project_id: project.id, id: task_request.id }
expect(response.body).to have_content "Task Request"
expect(response.body).to have_content "pending"
end
end
describe "#cancel" do
let!(:task_request) { create(:task_request, project: project, description: "Task to be cancelled") }
it "responds with redirect" do
post :cancel, params: { project_id: project.id, id: task_request.id }
expect(response).to be_redirect
expect(response).to redirect_to(project_task_requests_path(project))
expect(flash.notice).not_to be_nil
end
it "updates the status to 'cancelled'" do
expect {
post :cancel, params: { project_id: project.id, id: task_request.id }
}.to change { task_request.reload.status }.from("pending").to("cancelled")
end
end
private
def task_request_params
attributes = attributes_for(:task_request).except(:status, :user_email)
files = 2.times.map { Rack::Test::UploadedFile.new(file_fixture("location_photo.png"), "image/png") }
attributes.merge({ files: files })
end
def update_params
{ description: "This is updated description" }
end
end

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

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

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_content 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 'Attached files will appear here.'
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,92 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.feature 'User creates task request', type: :feature do
let(:current_user) { create(:user, :manager) }
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
before do
sign_in(current_user)
end
scenario 'creating a new task request' do
visit new_project_task_request_path(project)
fill_in description_field, with: 'Description of the task'
fill_in deadline_field, with: '2020-06-24'
fill_in time_allowed_field, with: '30'
fill_in additional_notes_field, with: 'Additional note about the task'
click_on 'Create Task request'
expect(page).to have_content task_created_message
end
scenario 'user can view task request details' do
create(:task_request, project: project, description: 'Description of the task', deadline: '2020-07-23', time_allowed: '10', additional_notes: 'Additional note about the task')
visit project_task_request_path(project, TaskRequest.first)
expect(page).to have_content('Description of the task')
expect(page).to have_content('2020-07-23')
expect(page).to have_content('10')
expect(page).to have_content('Additional note about the task')
end
scenario 'user can update existing task request' do
create(:task_request, project: project, description: 'Description of the task', deadline: '2020-08-23', time_allowed: '10', additional_notes: 'Additional note about the task')
visit edit_project_task_request_path(project, TaskRequest.first)
fill_in deadline_field, with: '2020-07-01'
fill_in time_allowed_field, with: '13'
click_on 'Update Task request'
expect(page).to have_content('13')
expect(page).to have_content('07/01/20')
end
scenario 'user can cancel a task request' do
create(:task_request, project: project, description: 'Description of the task', deadline: '2020-08-23', time_allowed: '10', additional_notes: 'Additional note about the task')
visit project_task_requests_path(project)
click_on 'Manage'
click_link 'Cancel'
expect(page).to have_content('Cancelled')
end
scenario 'user can view completed tasks' do
create_list(:task_request, 5, project: project, status: 'completed')
create_list(:task_request, 5, project: project, status: 'pending')
visit project_tasks_path(project)
expect(page).to have_content('Completed')
expect(page).not_to have_content('Pending')
end
private
def description_field
t "task_requests.form.labels.description"
end
def deadline_field
t "task_requests.form.labels.deadline"
end
def time_allowed_field
t "task_requests.form.labels.time_allowed"
end
def additional_notes_field
t "task_requests.form.labels.additional_notes"
end
def task_created_message
t 'task_requests.create.success_message'
end
end

View File

@@ -0,0 +1,116 @@
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 description_column
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 "full description is shown if description text is not truncated" do
visit project_task_requests_path(project)
task_request = create(:task_request, project: project, description: 'Short Desc')
visit project_task_requests_path(project)
expect(page).to have_content task_request.description
end
scenario "truncated description is shown if description text is too long" do
visit project_task_requests_path(project)
task_request = create(:task_request,
project: project,
description: long_description_text)
visit project_task_requests_path(project)
expect(page).not_to have_content task_request.description
truncated_text = "#{task_request.description[0..26]}...read more"
expect(page).to have_content truncated_text
end
scenario "full description is shown when user hovers over read more link in description colum", js: true do
visit project_task_requests_path(project)
task_request = create(:task_request,
project: project,
description: long_description_text)
visit project_task_requests_path(project)
page.execute_script '$("a[data-toggle=popover]").trigger("mouseover")'
expect(page).to have_content task_request.description
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
def description_column
t 'task_requests.index.table_headers.task_request_description'
end
def long_description_text
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
end
end

View File

@@ -11,12 +11,10 @@ RSpec.describe SubmitHubspotFormJob, type: :job do
allow(Hubspot::Form).to receive(:new).and_return(form)
allow(form).to receive(:submit).and_return(true)
SubmitHubspotFormJob.perform_now("John", "Doe", "email@test.com", "My Account")
SubmitHubspotFormJob.perform_now("email@test.com", "My Account")
expect(Hubspot::Form).to have_received(:new).with("guid" => "hubspot_form_guid")
expect(form).to have_received(:submit).with(
first_name: "John",
last_name: "Doe",
email: "email@test.com",
company: "My Account"
)
@@ -27,11 +25,9 @@ RSpec.describe SubmitHubspotFormJob, type: :job do
allow(Hubspot::Form).to receive(:new).and_return(form)
allow(form).to receive(:submit).and_return(true)
SubmitHubspotFormJob.perform_now("John", "Doe", "email@test.com", "My Account", additional_param_one: "Foo", additional_param_two: "Bar")
SubmitHubspotFormJob.perform_now("email@test.com", "My Account", additional_param_one: "Foo", additional_param_two: "Bar")
expect(form).to have_received(:submit).with(
first_name: "John",
last_name: "Doe",
email: "email@test.com",
company: "My Account",
additional_param_one: "Foo",
@@ -46,7 +42,7 @@ RSpec.describe SubmitHubspotFormJob, type: :job do
allow(Hubspot::Form).to receive(:new).and_return(form)
allow(form).to receive(:submit)
SubmitHubspotFormJob.perform_now("John", "Doe", "email@test.com", "My Account")
SubmitHubspotFormJob.perform_now("email@test.com", "My Account")
expect(form).not_to have_received(:submit)
end

View File

@@ -0,0 +1,36 @@
require 'rails_helper'
RSpec.describe SubmitHubspotTaskRequestFormJob, type: :job do
describe '#perform_now' do
before do
ENV["HUBSPOT_TASK_REQUEST_FORM_GUID"] = "hubspot_task_request_form_guid"
end
it 'submits to the Hubspot API with the right params' do
form = double(:form)
allow(Hubspot::Form).to receive(:new).and_return(form)
allow(form).to receive(:submit).and_return(true)
SubmitHubspotTaskRequestFormJob.perform_now("email@test.com", "https://example.com/admin/task_requests/1")
expect(Hubspot::Form).to have_received(:new).with("guid" => "hubspot_task_request_form_guid")
expect(form).to have_received(:submit).with(
email: "email@test.com",
taskme_url: "https://example.com/admin/task_requests/1"
)
end
context 'when HUBSPOT_TASK_REQUEST_FORM_GUID is not available' do
it 'does not submit to the API' do
ENV["HUBSPOT_TASK_REQUEST_FORM_GUID"] = nil
form = double(:form)
allow(Hubspot::Form).to receive(:new).and_return(form)
allow(form).to receive(:submit)
SubmitHubspotTaskRequestFormJob.perform_now("email@test.com", "https://example.com/admin/task_requests/1")
expect(form).not_to have_received(:submit)
end
end
end
end

View File

@@ -129,6 +129,7 @@ RSpec.describe Account do
Download,
User,
Broadcast,
TaskRequest,
Account,
ZoomMeeting,
MedicalRelease,

View File

@@ -0,0 +1,20 @@
require 'rails_helper'
RSpec.describe TaskRequest, type: :model do
describe "associations" do
it { is_expected.to belong_to(:project) }
end
describe "enums" do
it { is_expected.to define_enum_for(:status).with_values([:pending, :completed, :cancelled]) }
end
describe "#order_by_recent" do
subject { described_class }
it { is_expected.to respond_to(:order_by_recent) }
end
describe "#validations" do
it { should validate_numericality_of(:time_allowed).only_integer.is_greater_than_or_equal_to(2) }
end
end