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

Commit 95f7b87

Browse files
committed
test(article): body parse & test adjust
1 parent 93c757e commit 95f7b87

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

lib/groupher_server/cms/delegates/article_curd.ex

+3-2
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,14 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
405405
end
406406
end
407407

408-
defp do_update_article(article, attrs) do
408+
defp do_update_article(article, %{body: _} = attrs) do
409409
with {:ok, attrs} <- add_rich_text_attrs(attrs) do
410410
ORM.update(article, attrs)
411411
end
412412
end
413413

414+
defp do_update_article(article, attrs), do: ORM.update(article, attrs)
415+
414416
# is update or create article with body field, parsed and extand it into attrs
415417
defp add_rich_text_attrs(%{body: body} = attrs) when not is_nil(body) do
416418
with {:ok, parsed} <- Converter.Article.parse_body(body),
@@ -457,7 +459,6 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
457459
defp result({:ok, %{update_edit_status: result}}), do: {:ok, result}
458460
defp result({:ok, %{update_article: result}}), do: {:ok, result}
459461
defp result({:ok, %{set_viewer_has_states: result}}), do: result |> done()
460-
defp result({:ok, %{update_article_meta: result}}), do: {:ok, result}
461462

462463
defp result({:error, :create_article, _result, _steps}) do
463464
{:error, [message: "create article", code: ecode(:create_fails)]}

test/groupher_server/cms/articles/post_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ defmodule GroupherServer.Test.CMS.Articles.Post do
2323
end
2424

2525
describe "[cms post curd]" do
26-
@tag :wip
2726
test "can create post with valid attrs", ~m(user community post_attrs)a do
2827
assert {:error, _} = ORM.find_by(Author, user_id: user.id)
2928
{:ok, post} = CMS.create_article(community, :post, post_attrs, user)
@@ -173,6 +172,7 @@ defmodule GroupherServer.Test.CMS.Articles.Post do
173172
assert post.is_question
174173
end
175174

175+
@tag :wip
176176
test "can update post with question", ~m(user community post_attrs)a do
177177
post_attrs = Map.merge(post_attrs, %{is_question: true})
178178
{:ok, post} = CMS.create_article(community, :post, post_attrs, user)

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ defmodule GroupherServer.Test.Mutation.Articles.Post do
200200
}
201201
}
202202
"""
203-
@tag :wip
203+
204204
test "update a post without login user fails", ~m(guest_conn post)a do
205205
unique_num = System.unique_integer([:positive, :monotonic])
206206

@@ -213,7 +213,6 @@ defmodule GroupherServer.Test.Mutation.Articles.Post do
213213
assert guest_conn |> mutation_get_error?(@query, variables, ecode(:account_login))
214214
end
215215

216-
@tag :wip
217216
test "post can be update by owner", ~m(owner_conn post)a do
218217
unique_num = System.unique_integer([:positive, :monotonic])
219218

test/groupher_server_web/query/cms/abuse_reports/repo_report_test.exs

-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ defmodule GroupherServer.Test.Query.AbuseReports.RepoReport do
9191
assert results["totalCount"] == 1
9292
end
9393

94-
@tag :wip
9594
test "support article_comment", ~m(guest_conn repo user)a do
9695
{:ok, comment} = CMS.create_article_comment(:repo, repo.id, mock_comment(), user)
9796
{:ok, _} = CMS.report_article_comment(comment.id, mock_comment(), "attr", user)

0 commit comments

Comments
 (0)