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

Commit 076ad21

Browse files
committed
refactor(mention): clean up
1 parent ac43691 commit 076ad21

File tree

7 files changed

+35
-147
lines changed

7 files changed

+35
-147
lines changed

test/groupher_server/cms/hooks/cite_blog_test.exs

Lines changed: 7 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ defmodule GroupherServer.Test.CMS.Hooks.CiteBlog do
3131
test "cited multi blog should work", ~m(user community blog2 blog3 blog4 blog5 blog_attrs)a do
3232
body =
3333
mock_rich_text(
34-
~s(the <a href=#{@site_host}/blog/#{blog2.id} /> and <a href=#{@site_host}/blog/#{blog2.id}>same la</a> is awesome, the <a href=#{
35-
@site_host
36-
}/blog/#{blog3.id}></a> is awesome too.),
34+
~s(the <a href=#{@site_host}/blog/#{blog2.id} /> and <a href=#{@site_host}/blog/#{
35+
blog2.id
36+
}>same la</a> is awesome, the <a href=#{@site_host}/blog/#{blog3.id}></a> is awesome too.),
3737
# second paragraph
3838
~s(the paragraph 2 <a href=#{@site_host}/blog/#{blog2.id} class=#{blog2.title}> again</a>, the paragraph 2 <a href=#{
3939
@site_host
@@ -90,7 +90,7 @@ defmodule GroupherServer.Test.CMS.Hooks.CiteBlog do
9090
assert cited_comment.meta.citing_count == 0
9191
end
9292

93-
@tag :wip
93+
@tag :wip2
9494
test "can cite blog's comment in blog", ~m(community user blog blog2 blog_attrs)a do
9595
{:ok, comment} = CMS.create_comment(:blog, blog.id, mock_rich_text("hello"), user)
9696

@@ -136,9 +136,9 @@ defmodule GroupherServer.Test.CMS.Hooks.CiteBlog do
136136
test "can cited blog inside a comment", ~m(user blog blog2 blog3 blog4 blog5)a do
137137
comment_body =
138138
mock_rich_text(
139-
~s(the <a href=#{@site_host}/blog/#{blog2.id} /> and <a href=#{@site_host}/blog/#{blog2.id}>same la</a> is awesome, the <a href=#{
140-
@site_host
141-
}/blog/#{blog3.id}></a> is awesome too.),
139+
~s(the <a href=#{@site_host}/blog/#{blog2.id} /> and <a href=#{@site_host}/blog/#{
140+
blog2.id
141+
}>same la</a> is awesome, the <a href=#{@site_host}/blog/#{blog3.id}></a> is awesome too.),
142142
# second paragraph
143143
~s(the paragraph 2 <a href=#{@site_host}/blog/#{blog2.id} class=#{blog2.title}> again</a>, the paragraph 2 <a href=#{
144144
@site_host
@@ -221,60 +221,4 @@ defmodule GroupherServer.Test.CMS.Hooks.CiteBlog do
221221
assert result.total_count == 3
222222
end
223223
end
224-
225-
describe "[cross cite]" do
226-
test "can citing multi type thread and comment in one time", ~m(user community blog2)a do
227-
blog_attrs = mock_attrs(:blog, %{community_id: community.id})
228-
blog_attrs = mock_attrs(:blog, %{community_id: community.id})
229-
blog_attrs = mock_attrs(:blog, %{community_id: community.id})
230-
231-
body = mock_rich_text(~s(the <a href=#{@site_host}/blog/#{blog2.id} />))
232-
233-
{:ok, blog} = CMS.create_article(community, :blog, Map.merge(blog_attrs, %{body: body}), user)
234-
235-
Hooks.Cite.handle(blog)
236-
237-
Process.sleep(1000)
238-
239-
{:ok, blog} = CMS.create_article(community, :blog, Map.merge(blog_attrs, %{body: body}), user)
240-
Hooks.Cite.handle(blog)
241-
242-
Process.sleep(1000)
243-
244-
comment_body = mock_comment(~s(the <a href=#{@site_host}/blog/#{blog2.id} />))
245-
{:ok, comment} = CMS.create_comment(:blog, blog.id, comment_body, user)
246-
247-
Hooks.Cite.handle(comment)
248-
249-
Process.sleep(1000)
250-
251-
{:ok, blog} =
252-
CMS.create_article(community, :blog, Map.merge(blog_attrs, %{body: body}), user)
253-
254-
Hooks.Cite.handle(blog)
255-
256-
{:ok, result} = CMS.paged_citing_contents("BLOG", blog2.id, %{page: 1, size: 10})
257-
# IO.inspect(result, label: "the result")
258-
259-
assert result.total_count == 4
260-
261-
result_blog = result.entries |> List.first()
262-
result_blog = result.entries |> Enum.at(1)
263-
result_comment = result.entries |> Enum.at(2)
264-
result_blog = result.entries |> List.last()
265-
266-
assert result_blog.id == blog.id
267-
assert result_blog.thread == :blog
268-
269-
assert result_blog.id == blog.id
270-
assert result_blog.thread == :blog
271-
272-
assert result_comment.id == blog.id
273-
assert result_comment.thread == :blog
274-
assert result_comment.comment_id == comment.id
275-
276-
assert result_blog.id == blog.id
277-
assert result_blog.thread == :blog
278-
end
279-
end
280224
end

test/groupher_server/cms/hooks/cite_job_test.exs

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ defmodule GroupherServer.Test.CMS.Hooks.CiteJob do
9090
assert cited_comment.meta.citing_count == 0
9191
end
9292

93-
@tag :wip
93+
@tag :wip2
9494
test "can cite job's comment in job", ~m(community user job job2 job_attrs)a do
9595
{:ok, comment} = CMS.create_comment(:job, job.id, mock_rich_text("hello"), user)
9696

@@ -221,60 +221,4 @@ defmodule GroupherServer.Test.CMS.Hooks.CiteJob do
221221
assert result.total_count == 3
222222
end
223223
end
224-
225-
describe "[cross cite]" do
226-
test "can citing multi type thread and comment in one time", ~m(user community job2)a do
227-
job_attrs = mock_attrs(:job, %{community_id: community.id})
228-
job_attrs = mock_attrs(:job, %{community_id: community.id})
229-
blog_attrs = mock_attrs(:blog, %{community_id: community.id})
230-
231-
body = mock_rich_text(~s(the <a href=#{@site_host}/job/#{job2.id} />))
232-
233-
{:ok, job} = CMS.create_article(community, :job, Map.merge(job_attrs, %{body: body}), user)
234-
235-
Hooks.Cite.handle(job)
236-
237-
Process.sleep(1000)
238-
239-
{:ok, job} = CMS.create_article(community, :job, Map.merge(job_attrs, %{body: body}), user)
240-
Hooks.Cite.handle(job)
241-
242-
Process.sleep(1000)
243-
244-
comment_body = mock_comment(~s(the <a href=#{@site_host}/job/#{job2.id} />))
245-
{:ok, comment} = CMS.create_comment(:job, job.id, comment_body, user)
246-
247-
Hooks.Cite.handle(comment)
248-
249-
Process.sleep(1000)
250-
251-
{:ok, blog} =
252-
CMS.create_article(community, :blog, Map.merge(blog_attrs, %{body: body}), user)
253-
254-
Hooks.Cite.handle(blog)
255-
256-
{:ok, result} = CMS.paged_citing_contents("JOB", job2.id, %{page: 1, size: 10})
257-
# IO.inspect(result, label: "the result")
258-
259-
assert result.total_count == 4
260-
261-
result_job = result.entries |> List.first()
262-
result_job = result.entries |> Enum.at(1)
263-
result_comment = result.entries |> Enum.at(2)
264-
result_blog = result.entries |> List.last()
265-
266-
assert result_job.id == job.id
267-
assert result_job.thread == :job
268-
269-
assert result_job.id == job.id
270-
assert result_job.thread == :job
271-
272-
assert result_comment.id == job.id
273-
assert result_comment.thread == :job
274-
assert result_comment.comment_id == comment.id
275-
276-
assert result_blog.id == blog.id
277-
assert result_blog.thread == :blog
278-
end
279-
end
280224
end

test/groupher_server/cms/hooks/cite_post_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ defmodule GroupherServer.Test.CMS.Hooks.CitePost do
9090
assert cited_comment.meta.citing_count == 0
9191
end
9292

93-
@tag :wip
93+
@tag :wip2
9494
test "can cite post's comment in post", ~m(community user post post2 post_attrs)a do
9595
{:ok, comment} = CMS.create_comment(:post, post.id, mock_rich_text("hello"), user)
9696

test/groupher_server/cms/hooks/notify_blog_test.exs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyBlog do
2121
end
2222

2323
describe "[upvote notify]" do
24-
@tag :wip2
24+
@tag :wip22
2525
test "upvote hook should work on blog", ~m(user2 blog)a do
2626
{:ok, blog} = preload_author(blog)
2727

@@ -41,7 +41,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyBlog do
4141
assert user_exist_in?(user2, notify.from_users)
4242
end
4343

44-
@tag :wip2
44+
@tag :wip22
4545
test "upvote hook should work on blog comment", ~m(user2 blog comment)a do
4646
{:ok, comment} = CMS.upvote_comment(comment.id, user2)
4747
{:ok, comment} = preload_author(comment)
@@ -62,7 +62,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyBlog do
6262
assert user_exist_in?(user2, notify.from_users)
6363
end
6464

65-
@tag :wip2
65+
@tag :wip22
6666
test "undo upvote hook should work on blog", ~m(user2 blog)a do
6767
{:ok, blog} = preload_author(blog)
6868

@@ -78,7 +78,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyBlog do
7878
assert notifications.total_count == 0
7979
end
8080

81-
@tag :wip2
81+
@tag :wip22
8282
test "undo upvote hook should work on blog comment", ~m(user2 comment)a do
8383
{:ok, comment} = CMS.upvote_comment(comment.id, user2)
8484

@@ -97,7 +97,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyBlog do
9797
end
9898

9999
describe "[collect notify]" do
100-
@tag :wip2
100+
@tag :wip22
101101
test "collect hook should work on blog", ~m(user2 blog)a do
102102
{:ok, blog} = preload_author(blog)
103103

@@ -117,7 +117,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyBlog do
117117
assert user_exist_in?(user2, notify.from_users)
118118
end
119119

120-
@tag :wip2
120+
@tag :wip22
121121
test "undo collect hook should work on blog", ~m(user2 blog)a do
122122
{:ok, blog} = preload_author(blog)
123123

@@ -135,7 +135,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyBlog do
135135
end
136136

137137
describe "[comment notify]" do
138-
@tag :wip2
138+
@tag :wip22
139139
test "blog author should get notify after some one comment on it", ~m(user2 blog)a do
140140
{:ok, blog} = preload_author(blog)
141141

@@ -155,7 +155,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyBlog do
155155
assert user_exist_in?(user2, notify.from_users)
156156
end
157157

158-
@tag :wip2
158+
@tag :wip22
159159
test "blog comment author should get notify after some one reply it", ~m(user2 user3 blog)a do
160160
{:ok, blog} = preload_author(blog)
161161

test/groupher_server/cms/hooks/notify_job_test.exs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyJob do
2121
end
2222

2323
describe "[upvote notify]" do
24-
@tag :wip2
24+
@tag :wip22
2525
test "upvote hook should work on job", ~m(user2 job)a do
2626
{:ok, job} = preload_author(job)
2727

@@ -41,7 +41,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyJob do
4141
assert user_exist_in?(user2, notify.from_users)
4242
end
4343

44-
@tag :wip2
44+
@tag :wip22
4545
test "upvote hook should work on job comment", ~m(user2 job comment)a do
4646
{:ok, comment} = CMS.upvote_comment(comment.id, user2)
4747
{:ok, comment} = preload_author(comment)
@@ -62,7 +62,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyJob do
6262
assert user_exist_in?(user2, notify.from_users)
6363
end
6464

65-
@tag :wip2
65+
@tag :wip22
6666
test "undo upvote hook should work on job", ~m(user2 job)a do
6767
{:ok, job} = preload_author(job)
6868

@@ -78,7 +78,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyJob do
7878
assert notifications.total_count == 0
7979
end
8080

81-
@tag :wip2
81+
@tag :wip22
8282
test "undo upvote hook should work on job comment", ~m(user2 comment)a do
8383
{:ok, comment} = CMS.upvote_comment(comment.id, user2)
8484

@@ -97,7 +97,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyJob do
9797
end
9898

9999
describe "[collect notify]" do
100-
@tag :wip2
100+
@tag :wip22
101101
test "collect hook should work on job", ~m(user2 job)a do
102102
{:ok, job} = preload_author(job)
103103

@@ -117,7 +117,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyJob do
117117
assert user_exist_in?(user2, notify.from_users)
118118
end
119119

120-
@tag :wip2
120+
@tag :wip22
121121
test "undo collect hook should work on job", ~m(user2 job)a do
122122
{:ok, job} = preload_author(job)
123123

@@ -135,7 +135,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyJob do
135135
end
136136

137137
describe "[comment notify]" do
138-
@tag :wip2
138+
@tag :wip22
139139
test "job author should get notify after some one comment on it", ~m(user2 job)a do
140140
{:ok, job} = preload_author(job)
141141

@@ -155,7 +155,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyJob do
155155
assert user_exist_in?(user2, notify.from_users)
156156
end
157157

158-
@tag :wip2
158+
@tag :wip22
159159
test "job comment author should get notify after some one reply it", ~m(user2 user3 job)a do
160160
{:ok, job} = preload_author(job)
161161

test/groupher_server/cms/hooks/notify_post_test.exs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyPost do
2121
end
2222

2323
describe "[upvote notify]" do
24-
@tag :wip2
24+
@tag :wip22
2525
test "upvote hook should work on post", ~m(user2 post)a do
2626
{:ok, post} = preload_author(post)
2727

@@ -41,7 +41,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyPost do
4141
assert user_exist_in?(user2, notify.from_users)
4242
end
4343

44-
@tag :wip2
44+
@tag :wip22
4545
test "upvote hook should work on post comment", ~m(user2 post comment)a do
4646
{:ok, comment} = CMS.upvote_comment(comment.id, user2)
4747
{:ok, comment} = preload_author(comment)
@@ -62,7 +62,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyPost do
6262
assert user_exist_in?(user2, notify.from_users)
6363
end
6464

65-
@tag :wip2
65+
@tag :wip22
6666
test "undo upvote hook should work on post", ~m(user2 post)a do
6767
{:ok, post} = preload_author(post)
6868

@@ -78,7 +78,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyPost do
7878
assert notifications.total_count == 0
7979
end
8080

81-
@tag :wip2
81+
@tag :wip22
8282
test "undo upvote hook should work on post comment", ~m(user2 comment)a do
8383
{:ok, comment} = CMS.upvote_comment(comment.id, user2)
8484

@@ -97,7 +97,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyPost do
9797
end
9898

9999
describe "[collect notify]" do
100-
@tag :wip2
100+
@tag :wip22
101101
test "collect hook should work on post", ~m(user2 post)a do
102102
{:ok, post} = preload_author(post)
103103

@@ -117,7 +117,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyPost do
117117
assert user_exist_in?(user2, notify.from_users)
118118
end
119119

120-
@tag :wip2
120+
@tag :wip22
121121
test "undo collect hook should work on post", ~m(user2 post)a do
122122
{:ok, post} = preload_author(post)
123123

@@ -135,7 +135,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyPost do
135135
end
136136

137137
describe "[comment notify]" do
138-
@tag :wip2
138+
@tag :wip22
139139
test "post author should get notify after some one comment on it", ~m(user2 post)a do
140140
{:ok, post} = preload_author(post)
141141

@@ -155,7 +155,7 @@ defmodule GroupherServer.Test.CMS.Hooks.NotifyPost do
155155
assert user_exist_in?(user2, notify.from_users)
156156
end
157157

158-
@tag :wip2
158+
@tag :wip22
159159
test "post comment author should get notify after some one reply it", ~m(user2 user3 post)a do
160160
{:ok, post} = preload_author(post)
161161

0 commit comments

Comments
 (0)