Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/groupher_server/cms/cms.ex
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ defmodule GroupherServer.CMS do
defdelegate pin_article_comment(comment_id), to: ArticleComment
defdelegate undo_pin_article_comment(comment_id), to: ArticleComment

defdelegate make_emotion(comment_id, args, user), to: ArticleComment
defdelegate emotion_to_comment(comment_id, args, user), to: ArticleComment
defdelegate fold_article_comment(comment_id, user), to: ArticleComment
defdelegate unfold_article_comment(comment_id, user), to: ArticleComment
defdelegate report_article_comment(comment_id, user), to: ArticleComment
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/cms/delegates/article_comment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
end

@doc "make emotion to a comment"
def make_emotion(comment_id, emotion, %User{} = user) do
def emotion_to_comment(comment_id, emotion, %User{} = user) do
with {:ok, comment} <-
ORM.find(ArticleComment, comment_id) do
Multi.new()
Expand Down
30 changes: 15 additions & 15 deletions test/groupher_server/cms/article_comment_emotions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ defmodule GroupherServer.Test.CMS.ArticleCommentEmotions do

first_comment = List.first(all_comment)

{:ok, _} = CMS.make_emotion(first_comment.id, :downvote, user)
{:ok, _} = CMS.make_emotion(first_comment.id, :beer, user)
{:ok, _} = CMS.make_emotion(first_comment.id, :popcorn, user)
{:ok, _} = CMS.emotion_to_comment(first_comment.id, :downvote, user)
{:ok, _} = CMS.emotion_to_comment(first_comment.id, :beer, user)
{:ok, _} = CMS.emotion_to_comment(first_comment.id, :popcorn, user)

{:ok, paged_comments} =
CMS.list_article_comments(
Expand Down Expand Up @@ -82,8 +82,8 @@ defmodule GroupherServer.Test.CMS.ArticleCommentEmotions do
parent_content = "parent comment"
{:ok, parent_comment} = CMS.create_article_comment(:post, post.id, parent_content, user)

{:ok, _} = CMS.make_emotion(parent_comment.id, :downvote, user)
{:ok, _} = CMS.make_emotion(parent_comment.id, :downvote, user2)
{:ok, _} = CMS.emotion_to_comment(parent_comment.id, :downvote, user)
{:ok, _} = CMS.emotion_to_comment(parent_comment.id, :downvote, user2)

{:ok, %{emotions: emotions}} = ORM.find(ArticleComment, parent_comment.id)

Expand All @@ -97,8 +97,8 @@ defmodule GroupherServer.Test.CMS.ArticleCommentEmotions do
parent_content = "parent comment"
{:ok, parent_comment} = CMS.create_article_comment(:post, post.id, parent_content, user)

{:ok, _} = CMS.make_emotion(parent_comment.id, :downvote, user)
{:ok, _} = CMS.make_emotion(parent_comment.id, :downvote, user)
{:ok, _} = CMS.emotion_to_comment(parent_comment.id, :downvote, user)
{:ok, _} = CMS.emotion_to_comment(parent_comment.id, :downvote, user)

{:ok, parent_comment} = ORM.find(ArticleComment, parent_comment.id)

Expand All @@ -110,9 +110,9 @@ defmodule GroupherServer.Test.CMS.ArticleCommentEmotions do
test "different user can make same emotions on same comment", ~m(post user user2 user3)a do
{:ok, parent_comment} = CMS.create_article_comment(:post, post.id, "parent comment", user)

{:ok, _} = CMS.make_emotion(parent_comment.id, :beer, user)
{:ok, _} = CMS.make_emotion(parent_comment.id, :beer, user2)
{:ok, _} = CMS.make_emotion(parent_comment.id, :beer, user3)
{:ok, _} = CMS.emotion_to_comment(parent_comment.id, :beer, user)
{:ok, _} = CMS.emotion_to_comment(parent_comment.id, :beer, user2)
{:ok, _} = CMS.emotion_to_comment(parent_comment.id, :beer, user3)

{:ok, %{emotions: emotions}} = ORM.find(ArticleComment, parent_comment.id)
# IO.inspect(emotions, label: "the parent_comment")
Expand All @@ -128,11 +128,11 @@ defmodule GroupherServer.Test.CMS.ArticleCommentEmotions do
parent_content = "parent comment"
{:ok, parent_comment} = CMS.create_article_comment(:post, post.id, parent_content, user)

{:ok, _} = CMS.make_emotion(parent_comment.id, :downvote, user)
{:ok, _} = CMS.make_emotion(parent_comment.id, :downvote, user)
{:ok, _} = CMS.make_emotion(parent_comment.id, :beer, user)
{:ok, _} = CMS.make_emotion(parent_comment.id, :heart, user)
{:ok, _} = CMS.make_emotion(parent_comment.id, :orz, user)
{:ok, _} = CMS.emotion_to_comment(parent_comment.id, :downvote, user)
{:ok, _} = CMS.emotion_to_comment(parent_comment.id, :downvote, user)
{:ok, _} = CMS.emotion_to_comment(parent_comment.id, :beer, user)
{:ok, _} = CMS.emotion_to_comment(parent_comment.id, :heart, user)
{:ok, _} = CMS.emotion_to_comment(parent_comment.id, :orz, user)

{:ok, %{emotions: emotions}} = ORM.find(ArticleComment, parent_comment.id)

Expand Down
10 changes: 5 additions & 5 deletions test/groupher_server_web/query/cms/article_comment_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ defmodule GroupherServer.Test.Query.ArticleComment do
comment = all_comment |> Enum.at(0)
comment2 = all_comment |> Enum.at(1)

{:ok, _} = CMS.make_emotion(comment.id, :downvote, user)
{:ok, _} = CMS.make_emotion(comment.id, :downvote, user2)
{:ok, _} = CMS.make_emotion(comment2.id, :beer, user2)
{:ok, _} = CMS.emotion_to_comment(comment.id, :downvote, user)
{:ok, _} = CMS.emotion_to_comment(comment.id, :downvote, user2)
{:ok, _} = CMS.emotion_to_comment(comment2.id, :beer, user2)

variables = %{id: post.id, thread: "POST", filter: %{page: 1, size: page_size}}
results = guest_conn |> query_result(@query, variables, "pagedArticleComments")
Expand Down Expand Up @@ -463,8 +463,8 @@ defmodule GroupherServer.Test.Query.ArticleComment do
comment = all_comment |> Enum.at(0)
comment2 = all_comment |> Enum.at(1)

{:ok, _} = CMS.make_emotion(comment.id, :downvote, user)
{:ok, _} = CMS.make_emotion(comment2.id, :downvote, user2)
{:ok, _} = CMS.emotion_to_comment(comment.id, :downvote, user)
{:ok, _} = CMS.emotion_to_comment(comment2.id, :downvote, user2)

variables = %{id: post.id, thread: "POST", filter: %{page: 1, size: page_size}}
results = user_conn |> query_result(@query, variables, "pagedArticleComments")
Expand Down