@@ -23,13 +23,14 @@ defmodule GroupherServer.Test.Mutation.CMS.ArticleArticleTags.CURD do
23
23
24
24
describe "[mutation cms tag]" do
25
25
@ create_tag_query """
26
- mutation($thread: Thread!, $title: String!, $color: RainbowColor!, $group: String, $communityId: ID!) {
27
- createArticleTag(thread: $thread, title: $title, color: $color, group: $group, communityId: $communityId) {
26
+ mutation($thread: Thread!, $title: String!, $color: RainbowColor!, $group: String, $communityId: ID!, $extra: [String] ) {
27
+ createArticleTag(thread: $thread, title: $title, color: $color, group: $group, communityId: $communityId, extra: $extra ) {
28
28
id
29
29
title
30
30
color
31
31
thread
32
32
group
33
+ extra
33
34
community {
34
35
id
35
36
logo
@@ -38,7 +39,6 @@ defmodule GroupherServer.Test.Mutation.CMS.ArticleArticleTags.CURD do
38
39
}
39
40
}
40
41
"""
41
-
42
42
test "create tag with valid attrs, has default POST thread and default posts" ,
43
43
~m( community) a do
44
44
variables = % {
@@ -64,6 +64,24 @@ defmodule GroupherServer.Test.Mutation.CMS.ArticleArticleTags.CURD do
64
64
assert belong_community [ "id" ] == to_string ( community . id )
65
65
end
66
66
67
+ test "create tag with extra" , ~m( community) a do
68
+ variables = % {
69
+ title: "tag title" ,
70
+ communityId: community . id ,
71
+ thread: "POST" ,
72
+ color: "GREEN" ,
73
+ group: "awesome" ,
74
+ extra: [ "menuID" , "menuID2" ]
75
+ }
76
+
77
+ passport_rules = % { community . title => % { "post.article_tag.create" => true } }
78
+ rule_conn = simu_conn ( :user , cms: passport_rules )
79
+
80
+ created = rule_conn |> mutation_result ( @ create_tag_query , variables , "createArticleTag" )
81
+
82
+ assert created [ "extra" ] == [ "menuID" , "menuID2" ]
83
+ end
84
+
67
85
test "unauth user create tag fails" , ~m( community user_conn guest_conn) a do
68
86
variables = % {
69
87
title: "tag title" ,
@@ -83,23 +101,25 @@ defmodule GroupherServer.Test.Mutation.CMS.ArticleArticleTags.CURD do
83
101
end
84
102
85
103
@ update_tag_query """
86
- mutation($id: ID!, $color: RainbowColor, $title: String, $communityId: ID!) {
87
- updateArticleTag(id: $id, color: $color, title: $title, communityId: $communityId) {
104
+ mutation($id: ID!, $color: RainbowColor, $title: String, $communityId: ID!, $extra: [String] ) {
105
+ updateArticleTag(id: $id, color: $color, title: $title, communityId: $communityId, extra: $extra ) {
88
106
id
89
107
title
90
108
color
109
+ extra
91
110
}
92
111
}
93
112
"""
94
-
113
+ @ tag :wip
95
114
test "auth user can update a tag" , ~m( article_tag_attrs community user) a do
96
115
{ :ok , article_tag } = CMS . create_article_tag ( community , :post , article_tag_attrs , user )
97
116
98
117
variables = % {
99
118
id: article_tag . id ,
100
119
color: "YELLOW" ,
101
120
title: "new title" ,
102
- communityId: community . id
121
+ communityId: community . id ,
122
+ extra: [ "newMenuID" ]
103
123
}
104
124
105
125
passport_rules = % { community . title => % { "post.article_tag.update" => true } }
@@ -109,6 +129,7 @@ defmodule GroupherServer.Test.Mutation.CMS.ArticleArticleTags.CURD do
109
129
110
130
assert updated [ "color" ] == "YELLOW"
111
131
assert updated [ "title" ] == "new title"
132
+ assert updated [ "extra" ] == [ "newMenuID" ]
112
133
end
113
134
114
135
@ delete_tag_query """