File tree Expand file tree Collapse file tree 5 files changed +75
-0
lines changed Expand file tree Collapse file tree 5 files changed +75
-0
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,27 @@ import (
11
11
"time"
12
12
13
13
"code.gitea.io/gitea/models"
14
+ "code.gitea.io/gitea/modules/setting"
14
15
api "code.gitea.io/gitea/modules/structs"
15
16
16
17
"github.com/stretchr/testify/assert"
17
18
)
18
19
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
+
19
35
func TestAPIIssuesReactions (t * testing.T ) {
20
36
defer prepareTestEnv (t )()
21
37
Original file line number Diff line number Diff line change @@ -512,6 +512,9 @@ func RegisterRoutes(m *macaron.Macaron) {
512
512
m .Get ("/signing-key.gpg" , misc .SigningKey )
513
513
m .Post ("/markdown" , bind (api.MarkdownOption {}), misc .Markdown )
514
514
m .Post ("/markdown/raw" , misc .MarkdownRaw )
515
+ m .Group ("/settings" , func () {
516
+ m .Get ("/allowed_reactions" , misc .SettingGetsAllowedReactions )
517
+ })
515
518
516
519
// Notifications
517
520
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 {
14
14
// in:body
15
15
Body api.ServerVersion `json:"body"`
16
16
}
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 8343
8343
}
8344
8344
}
8345
8345
},
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
+ },
8346
8363
"/signing-key.gpg": {
8347
8364
"get": {
8348
8365
"produces": [
15042
15059
}
15043
15060
}
15044
15061
},
15062
+ "StringSlice": {
15063
+ "description": "StringSlice",
15064
+ "schema": {
15065
+ "type": "array",
15066
+ "items": {
15067
+ "type": "string"
15068
+ }
15069
+ }
15070
+ },
15045
15071
"Tag": {
15046
15072
"description": "Tag",
15047
15073
"schema": {
You can’t perform that action at this time.
0 commit comments