Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 560c4fd

Browse files
committed
chore: wip
1 parent 78f27bf commit 560c4fd

File tree

4 files changed

+41
-14
lines changed

4 files changed

+41
-14
lines changed

lib/groupher_server_web/schema/cms/mutations/blog.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Blog do
1111
arg(:title, non_null(:string))
1212
arg(:body, non_null(:string))
1313
arg(:digest, non_null(:string))
14-
arg(:length, non_null(:integer))
14+
arg(:length, :integer)
1515
arg(:community_id, non_null(:id))
16-
1716
arg(:link_addr, :string)
18-
1917
arg(:thread, :thread, default_value: :blog)
2018
arg(:article_tags, list_of(:ids))
2119

test/groupher_server_web/mutation/cms/articles/blog_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule GroupherServer.Test.Mutation.Articles.Blog do
2323
$title: String!,
2424
$body: String,
2525
$digest: String!,
26-
$length: Int!,
26+
$length: Int,
2727
$communityId: ID!,
2828
$articleTags: [Ids]
2929
) {

test/groupher_server_web/mutation/statistics/statistics_test.exs

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,36 @@ defmodule GroupherServer.Test.Mutation.Statistics do
100100
assert contributes.count == 1
101101
end
102102

103+
@create_blog_query """
104+
mutation (
105+
$title: String!,
106+
$body: String!,
107+
$digest: String!,
108+
$communityId: ID!,
109+
$articleTags: [Ids]
110+
) {
111+
createBlog(
112+
title: $title,
113+
body: $body,
114+
digest: $digest,
115+
communityId: $communityId,
116+
articleTags: $articleTags
117+
) {
118+
id
119+
title
120+
body
121+
}
122+
}
123+
"""
124+
test "user should have contribute list after create a blog", ~m(user_conn user community)a do
125+
variables = blog_attr |> Map.merge(%{communityId: community.id}) |> camelize_map_key
126+
127+
user_conn |> mutation_result(@create_blog_query, variables, "createBlog")
128+
129+
{:ok, contributes} = ORM.find_by(UserContribute, user_id: user.id)
130+
assert contributes.count == 1
131+
end
132+
103133
@create_repo_query """
104134
mutation(
105135
$title: String!,
@@ -157,19 +187,18 @@ defmodule GroupherServer.Test.Mutation.Statistics do
157187
assert contributes.count == 1
158188
end
159189

160-
@create_comment_query """
161-
mutation($community: String!, $thread: Thread, $id: ID!, $body: String!) {
162-
createComment(community: $community, thread: $thread, id: $id, body: $body) {
190+
@write_comment_query """
191+
mutation($thread: Thread!, $id: ID!, $content: String!) {
192+
createArticleComment(thread: $thread, id: $id, content: $content) {
163193
id
164-
body
194+
bodyHtml
165195
}
166196
}
167197
"""
168-
test "user should have contribute list after create a comment",
169-
~m(user_conn user community)a do
198+
test "user should have contribute list after create a comment", ~m(user_conn user)a do
170199
{:ok, post} = db_insert(:post)
171-
variables = %{community: community.raw, thread: "POST", id: post.id, body: "this a comment"}
172-
user_conn |> mutation_result(@create_comment_query, variables, "createComment")
200+
variables = %{thread: "POST", id: post.id, content: "comment"}
201+
user_conn |> mutation_result(@write_comment_query, variables, "createArticleComment")
173202

174203
{:ok, contributes} = ORM.find_by(UserContribute, user_id: user.id)
175204
assert contributes.count == 1

test/helper/orm_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ defmodule GroupherServer.Test.Helper.ORM do
4040
end
4141

4242
test "find/3 with preload can preload muilt fields", %{post: post} do
43-
{:ok, found} = ORM.find(Post, post.id, preload: [:author, :comments, :communities])
43+
{:ok, found} = ORM.find(Post, post.id, preload: [:author, :article_tags, :communities])
4444
# IO.inspect found
4545
assert %Author{} = found.author
46-
assert %Ecto.Association.NotLoaded{} != found.comments
46+
assert %Ecto.Association.NotLoaded{} != found.article_tags
4747
assert %Ecto.Association.NotLoaded{} != found.communities
4848
end
4949

0 commit comments

Comments
 (0)