Skip to content

Commit

Permalink
Don't duplicate info in the Content Request ticket body
Browse files Browse the repository at this point in the history
The information is included in the custom fields so this removes duplicate
information as requested by a Content Designer.  It removes the
base_comment_snippets from ZendeskTicket. The specific Ticket classes can
define whether the information is passed in the body or custom fields.  It also
moves the [Reason for time constraint] at the end of the ticket body.
  • Loading branch information
AgaDufrat committed Aug 25, 2023
1 parent 7b6b4ff commit e223f1e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 51 deletions.
10 changes: 9 additions & 1 deletion app/models/zendesk/ticket/content_advice_request_ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def tags
protected

def comment_snippets
[
optional_comment_snippets + [
request_label(field: :details),
request_label(
field: :urls,
Expand All @@ -28,6 +28,14 @@ def comment_snippets
]
end

def optional_comment_snippets
snippets = []
snippets << Zendesk::LabelledSnippet.new(on: self, field: :needed_by_date) if needed_by_date
snippets << Zendesk::LabelledSnippet.new(on: self, field: :time_constraint_reason, label: "Reason for time constraint") if time_constraint_reason

snippets
end

def deadline_date
if needed_by_date.present?
Date.parse(needed_by_date).strftime("%-d %b")
Expand Down
21 changes: 10 additions & 11 deletions app/models/zendesk/ticket/content_change_request_ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,7 @@ def custom_fields
protected

def comment_snippets
[
Zendesk::LabelledSnippet.new(
on: @request,
field: :reason_for_change,
label: "Reason for change request",
),
Zendesk::LabelledSnippet.new(
on: @request,
field: :subject_area,
label: "Subject area",
),
snippets = [
Zendesk::LabelledSnippet.new(
on: @request,
field: :url,
Expand All @@ -51,6 +41,15 @@ def comment_snippets
label: "Details of what should be added, amended or removed",
),
]
if time_constraint_reason
snippets << Zendesk::LabelledSnippet.new(
on: self,
field: :time_constraint_reason,
label: "Reason for time constraint",
)
end

snippets
end
end
end
Expand Down
1 change: 1 addition & 0 deletions app/models/zendesk/ticket/remove_user_request_ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def tags

def comment_snippets
[
Zendesk::LabelledSnippet.new(on: self, field: :not_before_date),
Zendesk::LabelledSnippet.new(on: @request, field: :user_name),
Zendesk::LabelledSnippet.new(on: @request, field: :user_email),
Zendesk::LabelledSnippet.new(on: @request, field: :reason_for_removal),
Expand Down
24 changes: 8 additions & 16 deletions app/models/zendesk/zendesk_ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(request)
def_delegators :@requester, :email, :name, :collaborator_emails

def comment
Zendesk::SnippetCollection.new(base_comment_snippets + comment_snippets).to_s
Zendesk::SnippetCollection.new(comment_snippets).to_s
end

def not_before_date
Expand All @@ -41,6 +41,12 @@ def needed_by_time
end
end

def time_constraint_reason
if value?(:time_constraint) && value?(:time_constraint_reason, @request.time_constraint)
@request.time_constraint.time_constraint_reason
end
end

def tags
%w[govt_form]
end
Expand All @@ -50,27 +56,13 @@ def inside_government_tag_if_needed
end

def to_s
Zendesk::SnippetCollection.new(base_attribute_snippets + base_comment_snippets + comment_snippets).to_s
Zendesk::SnippetCollection.new(base_attribute_snippets + comment_snippets).to_s
end

def priority
"normal"
end

def base_comment_snippets
if value?(:time_constraint)
[
Zendesk::LabelledSnippet.new(on: self, field: :needed_by_date, label: "Needed by date"),
Zendesk::LabelledSnippet.new(on: self, field: :needed_by_time, label: "Needed by time"),
Zendesk::LabelledSnippet.new(on: self, field: :not_before_date, label: "Not before date"),
Zendesk::LabelledSnippet.new(on: self, field: :not_before_time, label: "Not before time"),
Zendesk::LabelledSnippet.new(on: @request.time_constraint, field: :time_constraint_reason, label: "Reason for time constraint"),
]
else
[]
end
end

def comment_snippets
[]
end
Expand Down
28 changes: 5 additions & 23 deletions spec/features/content_change_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,14 @@
"tags" => %w[govt_form content_amend],
"comment" => {
"body" =>
"[Needed by date]
31-12-#{next_year}
[Needed by time]
13:00
[Not before date]
01-12-#{next_year}
[Not before time]
18:00
[Reason for time constraint]
New law
[Reason for change request]
Factual inaccuracy
[Subject area]
Benefits
[URLs to be changed]
"[URLs to be changed]
http://gov.uk/X
[Details of what should be added, amended or removed]
Out of date XX YY",
Out of date XX YY
[Reason for time constraint]
New law",
},
"custom_fields" =>
[{ "id" => 7_948_652_819_356, "value" => "cr_inaccuracy" },
Expand Down

0 comments on commit e223f1e

Please sign in to comment.