Compare commits
5 Commits
add-notice
...
add-descri
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8a311fdea | ||
|
|
ba826508d8 | ||
|
|
a5213feccc | ||
|
|
c167889ea3 | ||
|
|
3e917c29f0 |
@@ -8,6 +8,10 @@ class Admin::TaskRequestsController < Admin::ApplicationController
|
||||
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")
|
||||
|
||||
@@ -17,13 +17,15 @@ class TaskRequestsController < ApplicationController
|
||||
|
||||
if @task_request.save
|
||||
log_create_analytics
|
||||
redirect_to [@project, :task_requests], notice: t(".notice")
|
||||
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
|
||||
|
||||
18
app/jobs/submit_hubspot_task_request_form_job.rb
Normal file
18
app/jobs/submit_hubspot_task_request_form_job.rb
Normal 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
|
||||
@@ -1,21 +1,49 @@
|
||||
<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>
|
||||
<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>
|
||||
|
||||
6
app/views/task_requests/_file.html.erb
Normal file
6
app/views/task_requests/_file.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<tr>
|
||||
<td><%= file.filename %></td>
|
||||
<td class="text-right">
|
||||
<%= link_to fa_icon("download"), file, target: "_blank" %>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -1,6 +1,11 @@
|
||||
<%= errors_summary_for task_request %>
|
||||
|
||||
<%= bootstrap_form_with model: model, local: true do |form| %>
|
||||
<%= bootstrap_form_with model: model, url: [@project, @task_request, show_chat: true], local: true do |form| %>
|
||||
<div class="alert alert-notice text-center pl-0 text-md-left mt-4">
|
||||
<%= 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.text_field :time_allowed, label: t('.labels.time_allowed') %>
|
||||
@@ -24,11 +29,6 @@
|
||||
data-placeholder="<%= dropzone_placeholder_message_for(task_request) %>"
|
||||
data-submit-button="#submit_folder"></div>
|
||||
<% end %>
|
||||
|
||||
<div class="alert alert-info text-center text-md-left mt-4">
|
||||
<%= fa_icon "info-circle" %>
|
||||
<strong>After you submit this information you will immediately be connected with a BIG representative who will be able to collect any additional information needed, answer your questions, etc.</strong>
|
||||
</div>
|
||||
|
||||
<div class="row align-items-center text-center mt-4">
|
||||
<%= link_to t("shared.cancel"), [project, :task_requests], class: "col-3 text-reset" %>
|
||||
|
||||
@@ -5,6 +5,18 @@
|
||||
<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>
|
||||
|
||||
9
app/views/task_requests/create.html.erb
Normal file
9
app/views/task_requests/create.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<% if params[:show_chat] %>
|
||||
<%= javascript_include_tag "https://js.hs-scripts.com/7344617.js", defer: "defer", async: true, id: "hs-script-loader" %>
|
||||
<%= javascript_tag nonce: true do %>
|
||||
$(document).ready(function(){
|
||||
window.HubSpotConversations.widget.open();
|
||||
});
|
||||
<% end %>
|
||||
<% end %>
|
||||
<p class="alert alert-success p-3 lead text-center"><%= t '.success_message' %></p>
|
||||
@@ -16,6 +16,7 @@
|
||||
<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>
|
||||
@@ -26,7 +27,7 @@
|
||||
<%= render @task_requests %>
|
||||
<% else %>
|
||||
<tr>
|
||||
<td colspan="5" 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 +1,46 @@
|
||||
<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| %>
|
||||
<%= file.filename %><br>
|
||||
<% end %>
|
||||
<% else %>
|
||||
"No files attached."
|
||||
<% end %>
|
||||
</dd>
|
||||
</dl>
|
||||
<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>
|
||||
|
||||
@@ -96,6 +96,8 @@ en:
|
||||
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:
|
||||
@@ -941,10 +943,12 @@ en:
|
||||
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?
|
||||
@@ -958,15 +962,19 @@ en:
|
||||
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:
|
||||
|
||||
@@ -183,7 +183,15 @@ 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)
|
||||
|
||||
@@ -43,14 +43,14 @@ COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching
|
||||
|
||||
CREATE FUNCTION public.pg_search_dmetaphone(text) RETURNS text
|
||||
LANGUAGE sql IMMUTABLE STRICT
|
||||
AS $_$
|
||||
SELECT array_to_string(ARRAY(SELECT dmetaphone(unnest(regexp_split_to_array($1, E'\\s+')))), ' ')
|
||||
AS $_$
|
||||
SELECT array_to_string(ARRAY(SELECT dmetaphone(unnest(regexp_split_to_array($1, E'\\s+')))), ' ')
|
||||
$_$;
|
||||
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
SET default_table_access_method = heap;
|
||||
SET default_with_oids = false;
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
|
||||
--
|
||||
-- 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: -
|
||||
--
|
||||
@@ -1181,6 +1172,7 @@ CREATE TABLE public.settings (
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.settings_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
@@ -1216,6 +1208,7 @@ CREATE TABLE public.taggings (
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.taggings_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
@@ -1246,6 +1239,7 @@ CREATE TABLE public.tags (
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.tags_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
@@ -1597,9 +1591,9 @@ CREATE TABLE public.zoom_meetings (
|
||||
created_at timestamp(6) without time zone NOT NULL,
|
||||
updated_at timestamp(6) without time zone NOT NULL,
|
||||
broadcast_id bigint,
|
||||
status integer DEFAULT 0,
|
||||
zoom_user_id bigint,
|
||||
project_id bigint
|
||||
project_id bigint,
|
||||
status integer DEFAULT 0
|
||||
);
|
||||
|
||||
|
||||
@@ -2053,14 +2047,6 @@ 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: -
|
||||
--
|
||||
|
||||
@@ -49,13 +49,6 @@ RSpec.describe TaskRequestsController, type: :controller do
|
||||
end
|
||||
|
||||
describe "#create" do
|
||||
it "responds with a redirect" do
|
||||
post :create, params: { project_id: project.id, task_request: task_request_params }
|
||||
|
||||
expect(response).to be_redirect
|
||||
expect(flash.notice).not_to be_nil
|
||||
end
|
||||
|
||||
it "does create a new record" do
|
||||
expect {
|
||||
post :create, params: { project_id: project.id, task_request: task_request_params }
|
||||
@@ -67,6 +60,12 @@ RSpec.describe TaskRequestsController, type: :controller do
|
||||
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
|
||||
|
||||
@@ -53,7 +53,7 @@ feature "Admin managing task requests" do
|
||||
|
||||
expect(page).to have_content 'Files'
|
||||
task_request.files.each do |file|
|
||||
expect(page).to have_link file.blob.filename
|
||||
expect(page).to have_content file.blob.filename
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@ feature "Admin managing task requests" do
|
||||
click_link 'View'
|
||||
switch_to_window(windows.last)
|
||||
|
||||
expect(page).to have_content 'No files attached'
|
||||
expect(page).to have_content 'Attached files will appear here.'
|
||||
end
|
||||
|
||||
scenario "task requests table is visible" do
|
||||
|
||||
92
spec/features/user_creates_task_request_spec.rb
Normal file
92
spec/features/user_creates_task_request_spec.rb
Normal 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
|
||||
@@ -13,6 +13,7 @@ feature "User managing task requests" do
|
||||
|
||||
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
|
||||
@@ -34,6 +35,40 @@ feature "User managing task requests" do
|
||||
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)
|
||||
@@ -70,4 +105,12 @@ feature "User managing task requests" do
|
||||
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
|
||||
|
||||
36
spec/jobs/submit_hubspot_task_request_form_job_spec.rb
Normal file
36
spec/jobs/submit_hubspot_task_request_form_job_spec.rb
Normal 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
|
||||
Reference in New Issue
Block a user