@@ -5,10 +5,8 @@ defmodule GroupherServer.Test.CMS.CiteContent do
55
66 alias Helper.ORM
77 alias GroupherServer.CMS
8- alias Helper.Converter . { EditorToHTML , HtmlSanitizer , Converter }
98
10- alias EditorToHTML . { Class , Validator }
11- alias CMS.Model . { Author , Community , Post }
9+ alias CMS.Model.Post
1210
1311 alias CMS.Delegate.BlockTasks
1412
@@ -31,8 +29,8 @@ defmodule GroupherServer.Test.CMS.CiteContent do
3129 end
3230
3331 describe "[cite basic]" do
34- @ tag :wip
35- test "basic " , ~m( user community post2 post3 post4 post5 post_attrs) a do
32+ # @tag :wip
33+ test "cited multi post should work " , ~m( user community post2 post3 post4 post5 post_attrs) a do
3634 body =
3735 mock_rich_text (
3836 ~s( the <a href=#{ @ site_host } /post/#{ post2 . id } /> and <a href=#{ @ site_host } /post/#{
@@ -45,17 +43,37 @@ defmodule GroupherServer.Test.CMS.CiteContent do
4543 )
4644
4745 post_attrs = post_attrs |> Map . merge ( % { body: body } )
48-
4946 { :ok , post } = CMS . create_article ( community , :post , post_attrs , user )
47+
48+ body = mock_rich_text ( ~s( the <a href=#{ @ site_host } /post/#{ post3 . id } />) )
49+ post_attrs = post_attrs |> Map . merge ( % { body: body } )
50+ { :ok , post_n } = CMS . create_article ( community , :post , post_attrs , user )
51+
5052 BlockTasks . handle ( post )
53+ BlockTasks . handle ( post_n )
5154
5255 { :ok , post2 } = ORM . find ( Post , post2 . id )
5356 { :ok , post3 } = ORM . find ( Post , post3 . id )
5457 { :ok , post4 } = ORM . find ( Post , post4 . id )
58+ { :ok , post5 } = ORM . find ( Post , post5 . id )
5559
5660 assert post2 . meta . citing_count == 1
57- assert post3 . meta . citing_count == 1
61+ assert post3 . meta . citing_count == 2
5862 assert post4 . meta . citing_count == 1
63+ assert post5 . meta . citing_count == 1
64+ end
65+
66+ @ tag :wip
67+ test "cited post itself should not work" , ~m( user community post post_attrs) a do
68+ { :ok , post } = CMS . create_article ( community , :post , post_attrs , user )
69+
70+ body = mock_rich_text ( ~s( the <a href=#{ @ site_host } /post/#{ post . id } />) )
71+ { :ok , post } = CMS . update_article ( post , % { body: body } )
72+
73+ BlockTasks . handle ( post )
74+
75+ { :ok , post } = ORM . find ( Post , post . id )
76+ assert post . meta . citing_count == 0
5977 end
6078 end
6179end
0 commit comments