File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,11 +11,27 @@ import (
1111 "time"
1212
1313 "code.gitea.io/gitea/models"
14+ "code.gitea.io/gitea/modules/setting"
1415 api "code.gitea.io/gitea/modules/structs"
1516
1617 "github.com/stretchr/testify/assert"
1718)
1819
20+ func TestAPIAllowedReactions (t * testing.T ) {
21+ defer prepareTestEnv (t )()
22+
23+ type allowed []string
24+
25+ a := new (allowed )
26+
27+ req := NewRequest (t , "GET" , "/api/v1/settings/allowed_reactions" )
28+ resp := MakeRequest (t , req , http .StatusOK )
29+
30+ DecodeJSON (t , resp , & a )
31+ assert .Len (t , * a , len (setting .UI .Reactions ))
32+ assert .ElementsMatch (t , setting .UI .Reactions , * a )
33+ }
34+
1935func TestAPIIssuesReactions (t * testing.T ) {
2036 defer prepareTestEnv (t )()
2137
Original file line number Diff line number Diff line change @@ -512,6 +512,9 @@ func RegisterRoutes(m *macaron.Macaron) {
512512 m .Get ("/signing-key.gpg" , misc .SigningKey )
513513 m .Post ("/markdown" , bind (api.MarkdownOption {}), misc .Markdown )
514514 m .Post ("/markdown/raw" , misc .MarkdownRaw )
515+ m .Group ("/settings" , func () {
516+ m .Get ("/allowed_reactions" , misc .SettingGetsAllowedReactions )
517+ })
515518
516519 // Notifications
517520 m .Group ("/notifications" , func () {
Original file line number Diff line number Diff line change 1+ // Copyright 2020 The Gitea Authors. All rights reserved.
2+ // Use of this source code is governed by a MIT-style
3+ // license that can be found in the LICENSE file.
4+
5+ package misc
6+
7+ import (
8+ "code.gitea.io/gitea/modules/context"
9+ "code.gitea.io/gitea/modules/setting"
10+ )
11+
12+ // SettingGetsAllowedReactions return allowed reactions
13+ func SettingGetsAllowedReactions (ctx * context.APIContext ) {
14+ // swagger:operation GET /settings/allowed_reactions miscellaneous getAllowedReactions
15+ // ---
16+ // summary: Returns string array of allowed reactions
17+ // produces:
18+ // - application/json
19+ // responses:
20+ // "200":
21+ // "$ref": "#/responses/StringSlice"
22+ ctx .JSON (200 , setting .UI .Reactions )
23+ }
Original file line number Diff line number Diff line change @@ -14,3 +14,10 @@ type swaggerResponseServerVersion struct {
1414 // in:body
1515 Body api.ServerVersion `json:"body"`
1616}
17+
18+ // StringSlice
19+ // swagger:response StringSlice
20+ type swaggerResponseStringSlice struct {
21+ // in:body
22+ Body []string `json:"body"`
23+ }
Original file line number Diff line number Diff line change 83438343 }
83448344 }
83458345 },
8346+ " /settings/allowed_reactions" : {
8347+ " get" : {
8348+ " produces" : [
8349+ " application/json"
8350+ ],
8351+ " tags" : [
8352+ " miscellaneous"
8353+ ],
8354+ " summary" : " Returns string array of allowed reactions" ,
8355+ " operationId" : " getAllowedReactions" ,
8356+ " responses" : {
8357+ " 200" : {
8358+ " $ref" : " #/responses/StringSlice"
8359+ }
8360+ }
8361+ }
8362+ },
83468363 " /signing-key.gpg" : {
83478364 " get" : {
83488365 " produces" : [
1504215059 }
1504315060 }
1504415061 },
15062+ " StringSlice" : {
15063+ " description" : " StringSlice" ,
15064+ " schema" : {
15065+ " type" : " array" ,
15066+ " items" : {
15067+ " type" : " string"
15068+ }
15069+ }
15070+ },
1504515071 " Tag" : {
1504615072 " description" : " Tag" ,
1504715073 " schema" : {
You can’t perform that action at this time.
0 commit comments