diff --git a/core/handlers/ticket_opened_test.go b/core/handlers/ticket_opened_test.go index 831ceaee3..d048c0a60 100644 --- a/core/handlers/ticket_opened_test.go +++ b/core/handlers/ticket_opened_test.go @@ -56,8 +56,8 @@ func TestTicketOpened(t *testing.T) { actions.NewOpenTicket( handlers.NewActionUUID(), assets.NewTicketerReference(testdata.Mailgun.UUID, "Mailgun (IT Support)"), - nil, - "Need help", + assets.NewTopicReference(testdata.SupportTopic.UUID, "Support"), + "", "Where are my cookies?", assets.NewUserReference(testdata.Admin.Email, "Admin"), "Email Ticket", diff --git a/core/models/assets.go b/core/models/assets.go index 82f881743..5b22f8656 100644 --- a/core/models/assets.go +++ b/core/models/assets.go @@ -332,6 +332,7 @@ func NewOrgAssets(ctx context.Context, db *sqlx.DB, orgID OrgID, prev *OrgAssets oa.topicsByID = make(map[TopicID]*Topic, len(oa.topics)) oa.topicsByUUID = make(map[assets.TopicUUID]*Topic, len(oa.topics)) for _, t := range oa.topics { + oa.topicsByID[t.(*Topic).ID()] = t.(*Topic) oa.topicsByUUID[t.UUID()] = t.(*Topic) } } else { diff --git a/core/models/tickets_test.go b/core/models/tickets_test.go index 0e65b4ccd..b0e4a8956 100644 --- a/core/models/tickets_test.go +++ b/core/models/tickets_test.go @@ -82,7 +82,7 @@ func TestTickets(t *testing.T) { testdata.Bob.ID, testdata.Zendesk.ID, "EX7869", - testdata.DefaultTopic.ID, + testdata.SalesTopic.ID, "New Zen Ticket", "Where are my trousers?", models.NilUserID, diff --git a/core/models/topics_test.go b/core/models/topics_test.go index a7cd86a2a..f96d7b169 100644 --- a/core/models/topics_test.go +++ b/core/models/topics_test.go @@ -20,7 +20,14 @@ func TestTopics(t *testing.T) { topics, err := oa.Topics() require.NoError(t, err) - assert.Equal(t, 1, len(topics)) + assert.Equal(t, 3, len(topics)) assert.Equal(t, testdata.DefaultTopic.UUID, topics[0].UUID()) assert.Equal(t, "General", topics[0].Name()) + assert.Equal(t, testdata.SalesTopic.UUID, topics[1].UUID()) + assert.Equal(t, "Sales", topics[1].Name()) + assert.Equal(t, testdata.SupportTopic.UUID, topics[2].UUID()) + assert.Equal(t, "Support", topics[2].Name()) + + assert.Equal(t, topics[1], oa.TopicByID(testdata.SalesTopic.ID)) + assert.Equal(t, topics[2], oa.TopicByUUID(testdata.SupportTopic.UUID)) } diff --git a/mailroom_test.dump b/mailroom_test.dump index fecbfd780..eab87ce7f 100644 Binary files a/mailroom_test.dump and b/mailroom_test.dump differ diff --git a/testsuite/testdata/constants.go b/testsuite/testdata/constants.go index c658efd78..1813dee87 100644 --- a/testsuite/testdata/constants.go +++ b/testsuite/testdata/constants.go @@ -72,6 +72,8 @@ var ReportingLabel = &Label{10000, "ebc4dedc-91c4-4ed4-9dd6-daa05ea82698"} var TestingLabel = &Label{10001, "a6338cdc-7938-4437-8b05-2d5d785e3a08"} var DefaultTopic = &Topic{1, "ffc903f7-8cbb-443f-9627-87106842d1aa"} +var SalesTopic = &Topic{2, "9ef2ff21-064a-41f1-8560-ccc990b4f937"} +var SupportTopic = &Topic{3, "0a8f2e00-fef6-402c-bd79-d789446ec0e0"} var Internal = &Ticketer{1, "8bd48029-6ca1-46a8-aa14-68f7213b82b3"} var Mailgun = &Ticketer{2, "f9c9447f-a291-4f3c-8c79-c089bbd4e713"}