Skip to content

Commit

Permalink
Merge pull request #1200 from alphagov/temp-changes-to-content-request
Browse files Browse the repository at this point in the history
Update Content change request ticket subject and temporarily add fields into body
  • Loading branch information
AgaDufrat authored Oct 13, 2023
2 parents 62a4dbd + bcd9984 commit 24b16b7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
20 changes: 15 additions & 5 deletions app/models/zendesk/ticket/content_change_request_ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ class ContentChangeRequestTicket < Zendesk::ZendeskTicket
TICKET_FORM_ID = 7_949_329_694_108

def subject
if @request.title.present?
"#{@request.title} - Content change request"
else
"Content change request"
end
@request.title.presence || "Content change request"
end

def tags
Expand All @@ -32,6 +28,20 @@ def custom_fields

def comment_snippets
snippets = [
Zendesk::LabelledSnippet.new(
on: @request,
field: :reason_for_change,
label: "Reason for request",
),
Zendesk::LabelledSnippet.new(
on: @request,
field: :subject_area,
label: "Subject area",
),
Zendesk::LabelledSnippet.new(on: self, field: :needed_by_date, label: "Deadline date"),
Zendesk::LabelledSnippet.new(on: self, field: :needed_by_time, label: "Deadline time"),
Zendesk::LabelledSnippet.new(on: self, field: :not_before_date, label: "Do not publish before date"),
Zendesk::LabelledSnippet.new(on: self, field: :not_before_time, label: "Do not publish before time"),
Zendesk::LabelledSnippet.new(
on: @request,
field: :url,
Expand Down
22 changes: 20 additions & 2 deletions spec/features/content_change_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,30 @@

scenario "successful mainstream content change request " do
request = expect_zendesk_to_receive_ticket(
"subject" => "Update X - Content change request",
"subject" => "Update X",
"requester" => hash_including("name" => "John Smith", "email" => "[email protected]"),
"tags" => %w[govt_form content_amend],
"comment" => {
"body" =>
"[URLs to be changed]
"[Reason for request]
Factual inaccuracy
[Subject area]
Benefits
[Deadline date]
31-12-#{next_year}
[Deadline time]
13:00
[Do not publish before date]
01-12-#{next_year}
[Do not publish before time]
18:00
[URLs to be changed]
http://gov.uk/X
[Details of what should be added, amended or removed]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def with_time_constraint(attributes)
{ time_constraint: OpenStruct.new(attributes) }
end

it "contains the title in the subject, if one is provided" do
expect(ticket(title: "Abc").subject).to eq("Abc - Content change request")
it "has the title in the subject, if one is provided" do
expect(ticket(title: "Abc").subject).to eq("Abc")
end

it "has a default subject" do
Expand Down

0 comments on commit 24b16b7

Please sign in to comment.