Skip to content

Commit

Permalink
Merge pull request #991 from alphagov/update-support-tickets-endpoint…
Browse files Browse the repository at this point in the history
…-part1

Update support tickets endpoint part1
  • Loading branch information
AgaDufrat authored Jul 22, 2024
2 parents f2d98ef + 029d633 commit 9be3c3c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 37 deletions.
17 changes: 4 additions & 13 deletions app/models/support_ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,20 @@ class SupportTicket
def initialize(attributes)
@subject = attributes.fetch(:subject, nil)
@tags = attributes.fetch(:tags, nil)
@user_agent = attributes.fetch(:user_agent, nil)
@description = attributes.fetch(:description, nil)
end

def attributes
{
"subject" => subject,
"tags" => tags,
"body" => ticket_body,
"comment" => {
"body" => description,
},
}
end

private

attr_reader :subject, :tags, :user_agent, :description

def ticket_body
<<-TICKET_BODY.strip_heredoc
[User agent]
#{user_agent}
[Details]
#{description}
TICKET_BODY
end
attr_reader :subject, :tags, :description
end
21 changes: 6 additions & 15 deletions spec/models/support_ticket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,15 @@
support_ticket = described_class.new(
subject: "Feedback for app",
tags: %w[app_name],
user_agent: "Safari",
description: "Ticket details go here.",
)

expect(support_ticket.attributes).to eq(
"subject" => "Feedback for app",
"tags" => %w[app_name],
"body" => <<-TICKET_BODY.strip_heredoc,
[User agent]
Safari
[Details]
Ticket details go here.
TICKET_BODY
"comment" => {
"body" => "Ticket details go here.",
},
)
end

Expand All @@ -48,13 +43,9 @@
expect(support_ticket.attributes).to eq(
"subject" => "Feedback for app",
"tags" => %w[app_name],
"body" => <<-TICKET_BODY.strip_heredoc,
[User agent]
[Details]
Ticket details go here.
TICKET_BODY
"comment" => {
"body" => "Ticket details go here.",
},
)
end
end
12 changes: 3 additions & 9 deletions spec/requests/support_tickets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
params: {
subject: "Feedback for app",
tags: %w[app_name],
user_agent: "Safari",
description: "Ticket details go here.",
}

Expand All @@ -20,20 +19,15 @@
zendesk_request = expect_zendesk_to_receive_ticket(
"subject" => "Feedback for app",
"tags" => %w[app_name],
"body" => <<-TICKET_BODY.strip_heredoc,
[User agent]
Safari
[Details]
Ticket details go here.
TICKET_BODY
"comment" => {
"body" => "Ticket details go here.",
},
)

post "/support-tickets",
params: {
subject: "Feedback for app",
tags: %w[app_name],
user_agent: "Safari",
description: "Ticket details go here.",
}

Expand Down

0 comments on commit 9be3c3c

Please sign in to comment.