Skip to content

Commit

Permalink
Revert "Add zendesk ticket url to ticket comment instead of appending…
Browse files Browse the repository at this point in the history
… docs"

This reverts commit b847043.

This will come back, but reverting for now so we can deploy a hotfix to
production.
  • Loading branch information
tdooner committed Jun 2, 2020
1 parent 63772cc commit 682042f
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 53 deletions.
1 change: 0 additions & 1 deletion app/helpers/eitc_zendesk_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class EitcZendeskInstance
COMMUNICATION_PREFERENCES = "360037409074"
DOCUMENT_REQUEST_LINK = "360038257473"
INTAKE_SOURCE = "360040933734"
LINK_TO_CLIENT_DOCUMENTS = "360042211294"

# Digital Intake Status value tags
INTAKE_STATUS_UNSTARTED = ""
Expand Down
29 changes: 13 additions & 16 deletions app/services/zendesk_follow_up_docs_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ class ZendeskFollowUpDocsService
include ZendeskServiceHelper
include AttachmentsHelper
include ConsolidatedTraceHelper
include Rails.application.routes.url_helpers

def initialize(intake)
@intake = intake
Expand All @@ -22,21 +21,19 @@ def send_requested_docs
.where(document_type: "Requested")
.or(@intake.documents.where(document_type: "Requested Later"))
.where(zendesk_ticket_id: nil)
ticket_url = zendesk_ticket_url(@intake.intake_ticket_id)
output = append_comment_to_ticket(
ticket_id: @intake.intake_ticket_id,
fields: { EitcZendeskInstance::LINK_TO_CLIENT_DOCUMENTS => ticket_url },
comment: <<~DOCS
The client added requested follow-up documents:
#{new_requested_docs.map {|d| "* #{d.upload.filename}\n"}.join }
View all client documents here:
#{ticket_url}
DOCS
)
raise CouldNotSendFollowUpDocError unless output
new_requested_docs.each {|doc| doc.update(zendesk_ticket_id: @intake.intake_ticket_id)}
DatadogApi.increment("zendesk.ticket.docs.requested.sent")
output
download_attachments_to_tmp(new_requested_docs.map(&:upload)) do |file_list|

output = append_multiple_files_to_ticket(
ticket_id: @intake.intake_ticket_id,
file_list: file_list,
comment: "The client added requested follow-up documents:\n" + new_requested_docs.map {|d| "* #{d.upload.filename}\n"}.join,
)

raise CouldNotSendFollowUpDocError unless output
new_requested_docs.each {|doc| doc.update(zendesk_ticket_id: @intake.intake_ticket_id)}
DatadogApi.increment("zendesk.ticket.docs.requested.sent")
output
end
end

class CouldNotSendFollowUpDocError < ZendeskServiceError; end
Expand Down
28 changes: 13 additions & 15 deletions app/services/zendesk_intake_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,20 @@ def send_bank_details_png
end

def send_all_docs
ticket_url = zendesk_ticket_url(@intake.intake_ticket_id)
output = append_comment_to_ticket(
ticket_id: @intake.intake_ticket_id,
fields: { EitcZendeskInstance::LINK_TO_CLIENT_DOCUMENTS => ticket_url },
comment: <<~DOCS
Documents:
#{@intake.documents.map {|d| "* #{d.upload.filename} (#{d.document_type})\n"}.join}
View all client documents here:
#{ticket_url}
DOCS
)
download_attachments_to_tmp(@intake.documents.map(&:upload)) do |file_list|

output = append_multiple_files_to_ticket(
ticket_id: @intake.intake_ticket_id,
file_list: file_list,
comment: "Documents:\n" + @intake.documents.map {|d| "* #{d.upload.filename} (#{d.document_type})\n"}.join,
)

raise CouldNotSendDocumentError unless output
@intake.documents.each { |d| d.update(zendesk_ticket_id: @intake.intake_ticket_id) }
DatadogApi.increment("zendesk.ticket.docs.all.sent")
output
end

raise CouldNotSendDocumentError unless output
@intake.documents.each { |d| d.update(zendesk_ticket_id: @intake.intake_ticket_id) }
DatadogApi.increment("zendesk.ticket.docs.all.sent")
output
end

def contact_preferences
Expand Down
22 changes: 11 additions & 11 deletions spec/services/zendesk_follow_up_docs_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@

before do
DatadogApi.instance_variable_set("@dogapi_client", nil)
allow(service).to receive(:append_comment_to_ticket).and_return(output)
allow(service).to receive(:append_multiple_files_to_ticket).and_return(output)
end

it "lists each requested doc in the comment and adds portal link to the ticket" do
it "appends each requested doc to the ticket" do
result = service.send_requested_docs

expect(result).to eq true

expect(service).to have_received(:append_comment_to_ticket).with(
expect(service).to have_received(:append_multiple_files_to_ticket).with(
ticket_id: 34,
fields: {
EitcZendeskInstance::LINK_TO_CLIENT_DOCUMENTS => zendesk_ticket_url(34)
},
file_list: [
{ filename: "picture_id.jpg", file: instance_of(Tempfile) },
{ filename: "picture_id.jpg", file: instance_of(Tempfile) },
{ filename: "picture_id.jpg", file: instance_of(Tempfile) },
],
comment: <<~DOCS
The client added requested follow-up documents:
* #{requested_docs[0].upload.filename}
* #{requested_docs[1].upload.filename}
* #{requested_docs[2].upload.filename}
View all client documents here:
#{zendesk_ticket_url(34)}
DOCS
)
end
Expand Down Expand Up @@ -78,9 +78,9 @@
end

it "does not update zendesk" do
service.send_requested_docs
result = service.send_requested_docs

expect(service).not_to have_received(:append_comment_to_ticket)
expect(service).not_to have_received(:append_multiple_files_to_ticket)
end

it "does not send a datadog metric" do
Expand Down
20 changes: 10 additions & 10 deletions spec/services/zendesk_intake_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -523,24 +523,24 @@

before do
intake.intake_ticket_id = 34
allow(service).to receive(:append_comment_to_ticket).and_return(output)
allow(service).to receive(:append_multiple_files_to_ticket).and_return(output)
end

it "lists each document in the comment, adds portal link and marks each document with the ticket id" do
it "appends each document to the ticket and marks each document with the ticket id" do
result = service.send_all_docs

expect(result).to eq true

expect(service.send_all_docs).to eq(true)
expect(service).to have_received(:append_comment_to_ticket).with(
expect(service).to have_received(:append_multiple_files_to_ticket).with(
ticket_id: 34,
fields: {
EitcZendeskInstance::LINK_TO_CLIENT_DOCUMENTS => zendesk_ticket_url(34)
},
file_list: [
{ filename: documents[0].upload.filename, file: instance_of(Tempfile) },
{ filename: documents[1].upload.filename, file: instance_of(Tempfile) },
],
comment: <<~DOCS
Documents:
* #{documents[0].upload.filename} (#{documents[0].document_type})
* #{documents[1].upload.filename} (#{documents[1].document_type})
View all client documents here:
#{zendesk_ticket_url(34)}
DOCS
)

Expand Down

0 comments on commit 682042f

Please sign in to comment.