Skip to content

Commit

Permalink
Send Content change request tickets to "Content Request" form
Browse files Browse the repository at this point in the history
Normally the Zendesk tickets default to the "Default Ticket Form. We want to
render "Content Request" form because some information in the Content change
request tickets is included only in the custom fields (not in the body). The
Zendesk user might not see this information if they don’t know to switch to the
correct form template. Therefore we want to render the correct form for this
ticket.

Name: ticket_form_id
Type: integer
Read-only: false
Mandatory: false
Description: Enterprise only. The id of the ticket form to render for the ticket

From the API reference: https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#json-format
  • Loading branch information
AgaDufrat committed Aug 25, 2023
1 parent e223f1e commit 3338386
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/zendesk/ticket/content_change_request_ticket.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Zendesk
module Ticket
class ContentChangeRequestTicket < Zendesk::ZendeskTicket
TICKET_FORM_ID = 7_949_329_694_108

def subject
if @request.title.present?
"#{@request.title} - Content change request"
Expand Down
1 change: 1 addition & 0 deletions app/models/zendesk/zendesk_tickets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def raise_ticket(ticket_to_raise)
comment: { "body" => ticket_to_raise.comment },
}
ticket_options.merge!(custom_fields: ticket_to_raise.custom_fields) if ticket_to_raise.respond_to?(:custom_fields)
ticket_options.merge!(ticket_form_id: ticket_to_raise.class::TICKET_FORM_ID) if ticket_to_raise.class.const_defined?(:TICKET_FORM_ID)

ZendeskTicketWorker.perform_async(ticket_options.stringify_keys)
end
Expand Down
1 change: 1 addition & 0 deletions spec/features/content_change_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
{ "id" => 7_949_152_975_772, "value" => "2024-12-01" },
{ "id" => 8_250_061_570_844, "value" => "13:00" },
{ "id" => 8_250_075_489_052, "value" => "18:00" }],
"ticket_form_id" => 7_949_329_694_108,
)

user_makes_a_content_change_request(
Expand Down
17 changes: 17 additions & 0 deletions spec/models/zendesk/zendesk_tickets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,22 @@
),
)
end

it "calls ZendeskTicketWorker with ticket_form_id if the constant is defined in the child class" do
ticket_with_form_id = instance_double(
Zendesk::Ticket::ContentChangeRequestTicket,
base_ticket_attr,
)
allow(ticket_with_form_id).to receive(:class).and_return(Zendesk::Ticket::ContentChangeRequestTicket)
stub_const("Zendesk::Ticket::ContentChangeRequestTicket::TICKET_FORM_ID", 123)

described_class.new.raise_ticket(ticket_with_form_id)

expect(ZendeskTicketWorker).to have_received(:perform_async).with(
hash_including(
"ticket_form_id" => 123,
),
)
end
end
end

0 comments on commit 3338386

Please sign in to comment.