Skip to content

Commit

Permalink
Rename ticket endpoint action note to add_note
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Aug 26, 2021
1 parent 3abacf2 commit 1acf150
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions web/ticket/note.go → web/ticket/add_note.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import (
)

func init() {
web.RegisterJSONRoute(http.MethodPost, "/mr/ticket/note", web.RequireAuthToken(web.WithHTTPLogs(handleNote)))
web.RegisterJSONRoute(http.MethodPost, "/mr/ticket/add_note", web.RequireAuthToken(web.WithHTTPLogs(handleAddNote)))
}

type noteRequest struct {
type addNoteRequest struct {
bulkTicketRequest

Note string `json:"note"`
}

// Assigns the tickets with the given ids to the given user
// Adds the given text note to the tickets with the given ids
//
// {
// "org_id": 123,
Expand All @@ -30,8 +30,8 @@ type noteRequest struct {
// "note": "spam"
// }
//
func handleNote(ctx context.Context, rt *runtime.Runtime, r *http.Request, l *models.HTTPLogger) (interface{}, int, error) {
request := &noteRequest{}
func handleAddNote(ctx context.Context, rt *runtime.Runtime, r *http.Request, l *models.HTTPLogger) (interface{}, int, error) {
request := &addNoteRequest{}
if err := utils.UnmarshalAndValidateWithLimit(r.Body, request, web.MaxRequestBytes); err != nil {
return errors.Wrapf(err, "request failed validation"), http.StatusBadRequest, nil
}
Expand Down
4 changes: 2 additions & 2 deletions web/ticket/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ func TestTicketAssign(t *testing.T) {
web.RunWebTests(t, "testdata/assign.json", nil)
}

func TestTicketNote(t *testing.T) {
func TestTicketAddNote(t *testing.T) {
_, _, db, _ := testsuite.Reset()

// create 2 open tickets and 1 closed one for Cathy across two different ticketers
testdata.InsertOpenTicket(db, testdata.Org1, testdata.Cathy, testdata.Mailgun, "Need help", "Have you seen my cookies?", "17", testdata.Admin)
testdata.InsertOpenTicket(db, testdata.Org1, testdata.Cathy, testdata.Zendesk, "More help", "Have you seen my cookies?", "21", testdata.Agent)
testdata.InsertClosedTicket(db, testdata.Org1, testdata.Cathy, testdata.Zendesk, "Old question", "Have you seen my cookies?", "34", nil)

web.RunWebTests(t, "testdata/note.json", nil)
web.RunWebTests(t, "testdata/add_note.json", nil)
}

func TestTicketClose(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"label": "adds a note to the given tickets",
"method": "POST",
"path": "/mr/ticket/note",
"path": "/mr/ticket/add_note",
"body": {
"org_id": 1,
"user_id": 3,
Expand Down

0 comments on commit 1acf150

Please sign in to comment.