Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commitea2598f

Browse files
committed
refactor(article-comments): fix broken tests
1 parenta0ac4be commitea2598f

File tree

7 files changed

+5
-119
lines changed

7 files changed

+5
-119
lines changed

‎lib/groupher_server/cms/cms.ex‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,6 @@ defmodule GroupherServer.CMS do
146146
# >> like / undo like
147147
defdelegatelike_comment(thread,comment,user),to:CommentReaction
148148
defdelegateundo_like_comment(thread,comment,user),to:CommentReaction
149-
# >> dislike / undo dislike
150-
defdelegatedislike_comment(thread,comment,user),to:CommentReaction
151-
defdelegateundo_dislike_comment(thread,comment,user),to:CommentReaction
152149

153150
# Passport CURD
154151
defdelegatestamp_passport(rules,user),to:PassportCURD

‎lib/groupher_server/cms/delegates/comment_reaction.ex‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ defmodule GroupherServer.CMS.Delegate.CommentReaction do
1212
undo_feel_comment(thread,comment_id,user_id,:like)
1313
end
1414

15-
defdislike_comment(thread,comment_id,%Accounts.User{id:user_id})do
16-
feel_comment(thread,comment_id,user_id,:dislike)
17-
end
18-
19-
defundo_dislike_comment(thread,comment_id,%Accounts.User{id:user_id})do
20-
undo_feel_comment(thread,comment_id,user_id,:dislike)
21-
end
22-
2315
defpmerge_thread_comment_id(:post_comment,comment_id),do:%{post_comment_id:comment_id}
2416
defpmerge_thread_comment_id(:job_comment,comment_id),do:%{job_comment_id:comment_id}
2517
defpmerge_thread_comment_id(:repo_comment,comment_id),do:%{repo_comment_id:comment_id}

‎lib/groupher_server/cms/embeds/article_comment_meta.ex‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ defmodule GroupherServer.CMS.Embeds.ArticleCommentMeta do
77
aliasCMS.Embeds
88

99
@default_meta%{
10+
is_article_author_upvoted:false,
11+
is_solution:false,
1012
report_count:0,
1113
report_users:[]
1214
}
@@ -15,6 +17,9 @@ defmodule GroupherServer.CMS.Embeds.ArticleCommentMeta do
1517
defdefault_meta(),do:@default_meta
1618

1719
embedded_schemado
20+
field(:is_article_author_upvoted,:boolean,default:false)
21+
field(:is_solution,:boolean,default:false)
22+
1823
field(:report_count,:integer,default:0)
1924
embeds_many(:report_users,Embeds.User,on_replace::delete)
2025
end

‎lib/groupher_server_web/resolvers/cms_resolver.ex‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,6 @@ defmodule GroupherServerWeb.Resolvers.CMS do
386386
CMS.undo_like_comment(thread,id,user)
387387
end
388388

389-
defdislike_comment(_root,~m(thread id)a,%{context:%{cur_user:user}})do
390-
CMS.dislike_comment(thread,id,user)
391-
end
392-
393-
defundo_dislike_comment(_root,~m(thread id)a,%{context:%{cur_user:user}})do
394-
CMS.undo_dislike_comment(thread,id,user)
395-
end
396-
397389
defstamp_passport(_root,~m(user_id rules)a,%{context:%{cur_user:_user}})do
398390
CMS.stamp_passport(rules,%User{id:user_id})
399391
end

‎lib/groupher_server_web/schema/cms/mutations/comment.ex‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,5 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Comment do
9494
middleware(M.Authorize,:login)
9595
resolve(&R.CMS.undo_like_comment/3)
9696
end
97-
98-
field:dislike_comment,:commentdo
99-
arg(:thread,non_null(:cms_comment),default_value::post_comment)
100-
arg(:id,non_null(:id))
101-
102-
middleware(M.Authorize,:login)
103-
resolve(&R.CMS.dislike_comment/3)
104-
end
105-
106-
field:undo_dislike_comment,:commentdo
107-
arg(:thread,non_null(:cms_comment),default_value::post_comment)
108-
arg(:id,non_null(:id))
109-
110-
middleware(M.Authorize,:login)
111-
resolve(&R.CMS.undo_dislike_comment/3)
112-
end
11397
end
11498
end

‎test/groupher_server/cms/post_comment_test.exs‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -211,23 +211,6 @@ defmodule GroupherServer.Test.PostComment do
211211
assertfalse==comment_preload.likes|>Enum.any?(&(&1.id==like.id))
212212
end
213213

214-
test"user can dislike a comment",~m(comment user)ado
215-
# {:ok, like} = CMS.reaction(:post_comment, :like, comment.id, user.id)
216-
{:ok,disliked_comment}=CMS.dislike_comment(:post_comment,comment.id,user)
217-
218-
{:ok,comment_preload}=ORM.find(PostComment,disliked_comment.id,preload::dislikes)
219-
220-
assertcomment_preload.dislikes|>Enum.any?(&(&1.post_comment_id==comment.id))
221-
end
222-
223-
test"user can undo a dislike action",~m(comment user)ado
224-
{:ok,dislike}=CMS.dislike_comment(:post_comment,comment.id,user)
225-
{:ok,_}=CMS.undo_dislike_comment(:post_comment,comment.id,user)
226-
227-
{:ok,comment_preload}=ORM.find(PostComment,comment.id,preload::dislikes)
228-
assertfalse==comment_preload.dislikes|>Enum.any?(&(&1.id==dislike.id))
229-
end
230-
231214
test"user can get paged likes of a post comment",~m(comment)ado
232215
{:ok,user1}=db_insert(:user)
233216
{:ok,user2}=db_insert(:user)

‎test/groupher_server_web/mutation/cms/post_comment_test.exs‎

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -267,72 +267,5 @@ defmodule GroupherServer.Test.Mutation.PostComment do
267267

268268
assertfound.likes|>Enum.any?(&(&1.post_comment_id==comment.id))
269269
end
270-
271-
@undo_like_comment_query"""
272-
mutation($thread: CmsComment!, $id: ID!) {
273-
undoLikeComment(thread: $thread, id: $id) {
274-
id
275-
}
276-
}
277-
"""
278-
test"login user can undo a like action to comment",~m(user comment)ado
279-
variables=%{thread:"POST_COMMENT",id:comment.id}
280-
user_conn=simu_conn(:user,user)
281-
user_conn|>mutation_result(@like_comment_query,variables,"likeComment")
282-
283-
{:ok,found}=CMS.PostComment|>ORM.find(comment.id,preload::likes)
284-
assertfound.likes|>Enum.any?(&(&1.post_comment_id==comment.id))
285-
286-
user_conn|>mutation_result(@undo_like_comment_query,variables,"undoLikeComment")
287-
288-
{:ok,found}=CMS.PostComment|>ORM.find(comment.id,preload::likes)
289-
assertfalse==found.likes|>Enum.any?(&(&1.post_comment_id==comment.id))
290-
end
291-
292-
@dislike_comment_query"""
293-
mutation($thread: CmsComment!, $id: ID!) {
294-
dislikeComment(thread: $thread, id: $id) {
295-
id
296-
}
297-
}
298-
"""
299-
test"login user can dislike a comment",~m(user_conn comment)ado
300-
variables=%{thread:"POST_COMMENT",id:comment.id}
301-
user_conn|>mutation_result(@dislike_comment_query,variables,"dislikeComment")
302-
303-
{:ok,found}=CMS.PostComment|>ORM.find(comment.id,preload::dislikes)
304-
305-
assertfound.dislikes|>Enum.any?(&(&1.post_comment_id==comment.id))
306-
end
307-
308-
@undo_dislike_comment_query"""
309-
mutation($thread: CmsComment!, $id: ID!) {
310-
undoDislikeComment(thread: $thread, id: $id) {
311-
id
312-
}
313-
}
314-
"""
315-
test"login user can undo dislike a comment",~m(user comment)ado
316-
variables=%{thread:"POST_COMMENT",id:comment.id}
317-
user_conn=simu_conn(:user,user)
318-
user_conn|>mutation_result(@dislike_comment_query,variables,"dislikeComment")
319-
{:ok,found}=CMS.PostComment|>ORM.find(comment.id,preload::dislikes)
320-
assertfound.dislikes|>Enum.any?(&(&1.post_comment_id==comment.id))
321-
322-
user_conn|>mutation_result(@undo_dislike_comment_query,variables,"undoDislikeComment")
323-
324-
{:ok,found}=CMS.PostComment|>ORM.find(comment.id,preload::dislikes)
325-
assertfalse==found.dislikes|>Enum.any?(&(&1.post_comment_id==comment.id))
326-
end
327-
328-
test"unloged user do/undo like/dislike comment fails",~m(guest_conn comment)ado
329-
variables=%{thread:"POST_COMMENT",id:comment.id}
330-
331-
assertguest_conn|>mutation_get_error?(@like_comment_query,variables)
332-
assertguest_conn|>mutation_get_error?(@dislike_comment_query,variables)
333-
334-
assertguest_conn|>mutation_get_error?(@undo_like_comment_query,variables)
335-
assertguest_conn|>mutation_get_error?(@undo_dislike_comment_query,variables)
336-
end
337270
end
338271
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp