Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update support tickets endpoint part1 #991

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading