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

Commit 88573ca

Browse files
committed
chore: wip
1 parent 21dfd98 commit 88573ca

File tree

11 files changed

+32
-47
lines changed

11 files changed

+32
-47
lines changed

lib/groupher_server/cms/delegates/article_curd.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
292292
CMS.PinedPost
293293
|> join(:inner, [p], c in assoc(p, :community))
294294
|> join(:inner, [p], content in assoc(p, :post))
295-
|> where([p, c, t, content], c.raw == ^community)
296-
|> select([p, c, t, content], content)
295+
|> where([p, c, content], c.raw == ^community)
296+
|> select([p, c, content], content)
297297
# 10 pined contents per community/thread, at most
298298
|> ORM.paginater(%{page: 1, size: 10})
299299
|> done()

lib/groupher_server_web/resolvers/cms_resolver.ex

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,27 +99,29 @@ defmodule GroupherServerWeb.Resolvers.CMS do
9999
# #######################
100100
# content flag ..
101101
# #######################
102+
def pin_content(_root, ~m(id community_id thread)a, _info) do
103+
do_pin_content(id, community_id, thread)
104+
end
105+
102106
def pin_content(_root, ~m(id community_id)a, _info) do
103107
CMS.pin_content(%CMS.Post{id: id}, %Community{id: community_id})
104108
end
105109

106-
def pin_content(_root, ~m(id community_id thread)a, _info) do
107-
do_pin_content(id, community_id, thread)
110+
def undo_pin_content(_root, ~m(id community_id thread)a, _info) do
111+
do_undo_pin_content(id, community_id, thread)
108112
end
109113

110114
def undo_pin_content(_root, ~m(id community_id)a, _info) do
111115
CMS.undo_pin_content(%CMS.Post{id: id}, %Community{id: community_id})
112116
end
113117

114-
def undo_pin_content(_root, ~m(id community_id thread)a, _info) do
115-
do_undo_pin_content(id, community_id, thread)
118+
def do_pin_content(id, community_id, :job) do
119+
CMS.pin_content(%CMS.Job{id: id}, %Community{id: community_id})
116120
end
117121

118-
def do_pin_content(id, community_id, :job),
119-
do: CMS.pin_content(%CMS.Job{id: id}, %Community{id: community_id})
120-
121-
def do_pin_content(id, community_id, :repo),
122-
do: CMS.pin_content(%CMS.Repo{id: id}, %Community{id: community_id})
122+
def do_pin_content(id, community_id, :repo) do
123+
CMS.pin_content(%CMS.Repo{id: id}, %Community{id: community_id})
124+
end
123125

124126
def do_undo_pin_content(id, community_id, :job) do
125127
CMS.undo_pin_content(%CMS.Job{id: id}, %Community{id: community_id})
@@ -129,11 +131,13 @@ defmodule GroupherServerWeb.Resolvers.CMS do
129131
CMS.undo_pin_content(%CMS.Repo{id: id}, %Community{id: community_id})
130132
end
131133

132-
def trash_content(_root, ~m(id thread community_id)a, _info),
133-
do: set_community_flags(community_id, thread, id, %{trash: true})
134+
def trash_content(_root, ~m(id thread community_id)a, _info) do
135+
set_community_flags(community_id, thread, id, %{trash: true})
136+
end
134137

135-
def undo_trash_content(_root, ~m(id thread community_id)a, _info),
136-
do: set_community_flags(community_id, thread, id, %{trash: false})
138+
def undo_trash_content(_root, ~m(id thread community_id)a, _info) do
139+
set_community_flags(community_id, thread, id, %{trash: false})
140+
end
137141

138142
# TODO: report contents
139143
# def report_content(_root, ~m(id thread community_id)a, _info),

test/groupher_server/cms/article_comment_replies_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ defmodule GroupherServer.Test.CMS.ArticleCommentReplies do
100100
{:ok, replyed_comment_2} = CMS.reply_article_comment(replyed_comment_1.id, "reply 2", user2)
101101
{:ok, replyed_comment_3} = CMS.reply_article_comment(replyed_comment_2.id, "reply 3", user)
102102

103-
{:ok, parent_comment} = ORM.find(ArticleComment, parent_comment.id)
103+
{:ok, _parent_comment} = ORM.find(ArticleComment, parent_comment.id)
104104

105105
{:ok, replyed_comment_1} = ORM.find(ArticleComment, replyed_comment_1.id)
106106
{:ok, replyed_comment_2} = ORM.find(ArticleComment, replyed_comment_2.id)

test/groupher_server/cms/article_comment_test.exs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ defmodule GroupherServer.Test.CMS.ArticleComment do
321321
@tag :wip
322322
test "can load paged comments participators of a article", ~m(user post)a do
323323
total_count = 30
324-
page_number = 1
325324
page_size = 10
326325
thread = :post
327326

@@ -332,8 +331,8 @@ defmodule GroupherServer.Test.CMS.ArticleComment do
332331
acc ++ [comment]
333332
end)
334333

335-
{:ok, comment} = CMS.create_article_comment(:post, post.id, "commment", user)
336-
{:ok, comment} = CMS.create_article_comment(:post, post.id, "commment", user)
334+
{:ok, _comment} = CMS.create_article_comment(:post, post.id, "commment", user)
335+
{:ok, _comment} = CMS.create_article_comment(:post, post.id, "commment", user)
337336

338337
{:ok, results} =
339338
CMS.list_article_comments_participators(thread, post.id, %{page: 1, size: page_size})

test/groupher_server/cms/content_pin_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ defmodule GroupherServer.Test.CMS.ContentsPin do
2424

2525
describe "[cms post pin]" do
2626
test "can pin a post", ~m(community post)a do
27-
{:ok, pined_post} = CMS.pin_content(post, community, "posts")
27+
{:ok, pined_post} = CMS.pin_content(post, community)
2828

2929
assert pined_post.id == post.id
3030
end
3131

3232
test "can undo pin to a post", ~m(community post)a do
33-
{:ok, pined_post} = CMS.pin_content(post, community, "posts")
33+
{:ok, pined_post} = CMS.pin_content(post, community)
3434
assert pined_post.id == post.id
3535

36-
assert {:ok, unpined} = CMS.undo_pin_content(post, community, "posts")
36+
assert {:ok, unpined} = CMS.undo_pin_content(post, community)
3737
assert unpined.id == post.id
3838
end
3939
end

test/groupher_server_web/mutation/cms/cms_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ defmodule GroupherServer.Test.Mutation.CMS.Basic do
216216
assert belong_community["id"] == to_string(community.id)
217217
end
218218

219+
@tag :wip3
219220
test "auth user create duplicate tag fails", ~m(community)a do
220221
variables = mock_attrs(:tag, %{communityId: community.id})
221222

test/groupher_server_web/mutation/cms/post_flag_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ defmodule GroupherServer.Test.Mutation.PostFlag do
118118
passport_rules = %{community.raw => %{"post.undo_pin" => true}}
119119
rule_conn = simu_conn(:user, cms: passport_rules)
120120

121-
CMS.pin_content(post, community, "posts")
121+
CMS.pin_content(post, community)
122122
updated = rule_conn |> mutation_result(@query, variables, "undoPinPost")
123123

124124
assert updated["id"] == to_string(post.id)

test/groupher_server_web/mutation/cms/repo_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ defmodule GroupherServer.Test.Mutation.Repo do
141141
created = user_conn |> mutation_result(@create_repo_query, variables, "createRepo")
142142
{:ok, repo} = ORM.find(CMS.Repo, created["id"])
143143

144-
updated =
144+
_updated =
145145
user_conn
146146
|> mutation_result(
147147
@update_repo_query,

test/groupher_server_web/query/cms/article_comment_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ defmodule GroupherServer.Test.Query.ArticleComment do
288288
assert results["totalCount"] == total_count + 2
289289
end
290290

291-
@tag :wip2
291+
@tag :wip
292292
test "guest user can get paged comment with floor it", ~m(guest_conn post user)a do
293293
total_count = 5
294294
thread = :post

test/groupher_server_web/query/cms/paged_posts_test.exs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -186,26 +186,7 @@ defmodule GroupherServer.Test.Query.PagedPosts do
186186
assert results["totalCount"] == 1
187187
end
188188

189-
# test "read state false filter should work", ~m(user)a do
190-
# user_conn = simu_conn(:user, user)
191-
# {:ok, community} = db_insert(:community)
192-
193-
# {:ok, post} = CMS.create_content(community, :post, mock_attrs(:post), user)
194-
# {:ok, _post2} = CMS.create_content(community, :post, mock_attrs(:post), user)
195-
# {:ok, _post3} = CMS.create_content(community, :post, mock_attrs(:post), user)
196-
197-
# variables = %{filter: %{community: community.raw}}
198-
# results = user_conn |> query_result(@query, variables, "pagedPosts")
199-
# assert results["totalCount"] == 3
200-
201-
# {:ok, _} = CMS.read_content(:post, post.id, user)
202-
203-
# variables = %{filter: %{community: community.raw, read: "FALSE"}}
204-
# results = user_conn |> query_result(@query, variables, "pagedPosts")
205-
206-
# assert results["totalCount"] == 2
207-
# end
208-
189+
@tag :wip2
209190
test "read state all filter should work", ~m(user)a do
210191
user_conn = simu_conn(:user, user)
211192
{:ok, community} = db_insert(:community)

0 commit comments

Comments
 (0)