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

Commit ea9b660

Browse files
committed
refactor: fix test error
1 parent 1b7ac5a commit ea9b660

File tree

6 files changed

+5
-16
lines changed

6 files changed

+5
-16
lines changed

lib/groupher_server/cms/delegates/article_operation.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleOperation do
121121
{:ok, article} <-
122122
ORM.find(info.model, article_id, preload: [:communities, :original_community]),
123123
{:ok, community} <- ORM.find(Community, community_id) do
124-
case article.original_community.id == community_id do
124+
case article.original_community.id == community.id do
125125
true ->
126126
raise_error(:mirror_community, "can not unmirror original_community")
127127

test/groupher_server/cms/article_community/job_test.exs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Job do
1818
end
1919

2020
describe "[article mirror/move]" do
21-
@tag :wip2
2221
test "created job has origial community info", ~m(user community job_attrs)a do
2322
{:ok, job} = CMS.create_article(community, :job, job_attrs, user)
2423
{:ok, job} = ORM.find(CMS.Job, job.id, preload: :original_community)
2524

2625
assert job.original_community_id == community.id
2726
end
2827

29-
@tag :wip2
3028
test "job can be move to other community", ~m(user community community2 job_attrs)a do
3129
{:ok, job} = CMS.create_article(community, :job, job_attrs, user)
3230
assert job.original_community_id == community.id
@@ -37,7 +35,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Job do
3735
assert job.original_community.id == community2.id
3836
end
3937

40-
@tag :wip2
4138
test "job can be mirror to other community", ~m(user community community2 job_attrs)a do
4239
{:ok, job} = CMS.create_article(community, :job, job_attrs, user)
4340

@@ -54,7 +51,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Job do
5451
assert not is_nil(Enum.find(job.communities, &(&1.id == community2.id)))
5552
end
5653

57-
@tag :wip2
5854
test "job can be unmirror from community",
5955
~m(user community community2 community3 job_attrs)a do
6056
{:ok, job} = CMS.create_article(community, :job, job_attrs, user)
@@ -71,7 +67,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Job do
7167
assert is_nil(Enum.find(job.communities, &(&1.id == community3.id)))
7268
end
7369

74-
@tag :wip2
7570
test "job can not unmirror from original community",
7671
~m(user community community2 community3 job_attrs)a do
7772
{:ok, job} = CMS.create_article(community, :job, job_attrs, user)

test/groupher_server/cms/article_community/post_test.exs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Post do
1818
end
1919

2020
describe "[article mirror/move]" do
21-
@tag :wip2
2221
test "created post has origial community info", ~m(user community post_attrs)a do
2322
{:ok, post} = CMS.create_article(community, :post, post_attrs, user)
2423
{:ok, post} = ORM.find(CMS.Post, post.id, preload: :original_community)
2524

2625
assert post.original_community_id == community.id
2726
end
2827

29-
@tag :wip2
3028
test "post can be move to other community", ~m(user community community2 post_attrs)a do
3129
{:ok, post} = CMS.create_article(community, :post, post_attrs, user)
3230
assert post.original_community_id == community.id
@@ -37,7 +35,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Post do
3735
assert post.original_community.id == community2.id
3836
end
3937

40-
@tag :wip2
4138
test "post can be mirror to other community", ~m(user community community2 post_attrs)a do
4239
{:ok, post} = CMS.create_article(community, :post, post_attrs, user)
4340

@@ -54,7 +51,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Post do
5451
assert not is_nil(Enum.find(post.communities, &(&1.id == community2.id)))
5552
end
5653

57-
@tag :wip2
5854
test "post can be unmirror from community",
5955
~m(user community community2 community3 post_attrs)a do
6056
{:ok, post} = CMS.create_article(community, :post, post_attrs, user)
@@ -71,7 +67,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Post do
7167
assert is_nil(Enum.find(post.communities, &(&1.id == community3.id)))
7268
end
7369

74-
@tag :wip2
7570
test "post can not unmirror from original community",
7671
~m(user community community2 community3 post_attrs)a do
7772
{:ok, post} = CMS.create_article(community, :post, post_attrs, user)

test/groupher_server/cms/article_community/repo_test.exs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Repo do
1818
end
1919

2020
describe "[article mirror/move]" do
21-
@tag :wip2
2221
test "created repo has origial community info", ~m(user community repo_attrs)a do
2322
{:ok, repo} = CMS.create_article(community, :repo, repo_attrs, user)
2423
{:ok, repo} = ORM.find(CMS.Repo, repo.id, preload: :original_community)
2524

2625
assert repo.original_community_id == community.id
2726
end
2827

29-
@tag :wip2
3028
test "repo can be move to other community", ~m(user community community2 repo_attrs)a do
3129
{:ok, repo} = CMS.create_article(community, :repo, repo_attrs, user)
3230
assert repo.original_community_id == community.id
@@ -37,7 +35,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Repo do
3735
assert repo.original_community.id == community2.id
3836
end
3937

40-
@tag :wip2
4138
test "repo can be mirror to other community", ~m(user community community2 repo_attrs)a do
4239
{:ok, repo} = CMS.create_article(community, :repo, repo_attrs, user)
4340

@@ -54,7 +51,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Repo do
5451
assert not is_nil(Enum.find(repo.communities, &(&1.id == community2.id)))
5552
end
5653

57-
@tag :wip2
5854
test "repo can be unmirror from community",
5955
~m(user community community2 community3 repo_attrs)a do
6056
{:ok, repo} = CMS.create_article(community, :repo, repo_attrs, user)
@@ -71,7 +67,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Repo do
7167
assert is_nil(Enum.find(repo.communities, &(&1.id == community3.id)))
7268
end
7369

74-
@tag :wip2
7570
test "repo can not unmirror from original community",
7671
~m(user community community2 community3 repo_attrs)a do
7772
{:ok, repo} = CMS.create_article(community, :repo, repo_attrs, user)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ defmodule GroupherServer.Test.Mutation.Articles.Post do
464464
}
465465
}
466466
"""
467+
@tag :wip2
467468
test "auth user can unset community from a post", ~m(post)a do
468469
passport_rules = %{"post.community.set" => true}
469470
rule_conn = simu_conn(:user, cms: passport_rules)

test/support/factory.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ defmodule GroupherServer.Support.Factory do
2222
length: String.length(body),
2323
author: mock(:author),
2424
views: Enum.random(0..2000),
25+
original_community: mock(:community),
2526
communities: [
2627
mock(:community),
2728
mock(:community)
@@ -58,6 +59,7 @@ defmodule GroupherServer.Support.Factory do
5859
],
5960
author: mock(:author),
6061
views: Enum.random(0..2000),
62+
original_community: mock(:community),
6163
communities: [
6264
mock(:community),
6365
mock(:community)
@@ -123,6 +125,7 @@ defmodule GroupherServer.Support.Factory do
123125
field: field_enum |> Enum.at(Enum.random(0..(length(field_enum) - 1))),
124126
finance: finance_enum |> Enum.at(Enum.random(0..(length(finance_enum) - 1))),
125127
scale: scale_enum |> Enum.at(Enum.random(0..(length(scale_enum) - 1))),
128+
original_community: mock(:community),
126129
communities: [
127130
mock(:community)
128131
],

0 commit comments

Comments
 (0)