@@ -19,26 +19,22 @@ defmodule MastaniServer.Test.CMS do
1919 test "create tag with valid data" , ~m( community user) a do
2020 valid_attrs = mock_attrs ( :tag )
2121
22- { :ok , tag } = CMS . create_tag ( community , :post , valid_attrs , % User { id: user . id } )
22+ { :ok , tag } = CMS . create_tag ( community , :post , valid_attrs , user )
2323 assert tag . title == valid_attrs . title
2424 end
2525
2626 test "create tag with non-exsit user fails" , ~m( user) a do
2727 invalid_attrs = mock_attrs ( :tag )
2828
2929 assert { :error , _ } =
30- CMS . create_tag ( % Community { id: non_exsit_id ( ) } , :post , invalid_attrs , % User {
31- id: user . id
32- } )
30+ CMS . create_tag ( % Community { id: non_exsit_id ( ) } , :post , invalid_attrs , user )
3331 end
3432
3533 test "create tag with non-exsit community fails" , ~m( user) a do
3634 invalid_attrs = mock_attrs ( :tag )
3735
3836 assert { :error , _ } =
39- CMS . create_tag ( % Community { id: non_exsit_id ( ) } , :post , invalid_attrs , % User {
40- id: user . id
41- } )
37+ CMS . create_tag ( % Community { id: non_exsit_id ( ) } , :post , invalid_attrs , user )
4238 end
4339 end
4440
@@ -49,7 +45,7 @@ defmodule MastaniServer.Test.CMS do
4945 valid_attrs = mock_attrs ( :category , % { user_id: user . id } )
5046 ~m( title raw) a = valid_attrs
5147
52- { :ok , category } = CMS . create_category ( ~m( title raw) a , % User { id: user . id } )
48+ { :ok , category } = CMS . create_category ( ~m( title raw) a , user )
5349
5450 assert category . title == valid_attrs . title
5551 end
@@ -58,36 +54,38 @@ defmodule MastaniServer.Test.CMS do
5854 valid_attrs = mock_attrs ( :category , % { user_id: user . id } )
5955 ~m( title raw) a = valid_attrs
6056
61- assert { :ok , _ } = CMS . create_category ( ~m( title raw) a , % User { id: user . id } )
62- assert { :error , _ } = CMS . create_category ( ~m( title) a , % User { id: user . id } )
57+ assert { :ok , _ } = CMS . create_category ( ~m( title raw) a , user )
58+ assert { :error , _ } = CMS . create_category ( ~m( title) a , user )
6359 end
6460
6561 test "update category with valid attrs" , ~m( user) a do
6662 valid_attrs = mock_attrs ( :category , % { user_id: user . id } )
6763 ~m( title raw) a = valid_attrs
6864
69- { :ok , category } = CMS . create_category ( ~m( title raw) a , % User { id: user . id } )
65+ { :ok , category } = CMS . create_category ( ~m( title raw) a , user )
7066
7167 assert category . title == valid_attrs . title
7268 { :ok , updated } = CMS . update_category ( % Category { id: category . id , title: "new title" } )
7369
7470 assert updated . title == "new title"
7571 end
7672
73+ @ tag :wip
7774 test "update title to existing title fails" , ~m( user) a do
7875 valid_attrs = mock_attrs ( :category , % { user_id: user . id } )
7976 ~m( title raw) a = valid_attrs
8077
81- { :ok , category } = CMS . create_category ( ~m( title raw) a , % User { id: user . id } )
78+ { :ok , category } = CMS . create_category ( ~m( title raw) a , user )
8279
8380 new_category_attrs = % { title: "category2 title" , raw: "category2 title" }
84- { :ok , category2 } = CMS . create_category ( new_category_attrs , % User { id: user . id } )
81+ { :ok , category2 } = CMS . create_category ( new_category_attrs , user )
8582
8683 { :error , _ } = CMS . update_category ( % Category { id: category . id , title: category2 . title } )
8784 end
8885
86+ @ tag :wip
8987 test "can set a category to a community" , ~m( community category) a do
90- { :ok , _ } = CMS . set_category ( % Community { id: community . id } , % Category { id: category . id } )
88+ { :ok , _ } = CMS . set_category ( community , category )
9189
9290 { :ok , found_community } = ORM . find ( Community , community . id , preload: :categories )
9391 { :ok , found_category } = ORM . find ( Category , category . id , preload: :communities )
@@ -99,10 +97,10 @@ defmodule MastaniServer.Test.CMS do
9997 assert community . id in assoc_communities
10098 end
10199
100+ @ tag :wip
102101 test "can unset a category to a community" , ~m( community category) a do
103- { :ok , _ } = CMS . set_category ( % Community { id: community . id } , % Category { id: category . id } )
104-
105- CMS . unset_category ( % Community { id: community . id } , % Category { id: category . id } )
102+ { :ok , _ } = CMS . set_category ( community , category )
103+ CMS . unset_category ( community , category )
106104
107105 { :ok , found_community } = ORM . find ( Community , community . id , preload: :categories )
108106 { :ok , found_category } = ORM . find ( Category , category . id , preload: :communities )
@@ -169,14 +167,12 @@ defmodule MastaniServer.Test.CMS do
169167 assert { :error , _error } = CMS . create_thread ( ~m( title raw) a )
170168 end
171169
170+ @ tag :wip
172171 test "can set a thread to community" , ~m( community) a do
173172 title = "POST"
174173 raw = title
175174 { :ok , thread } = CMS . create_thread ( ~m( title raw) a )
176- thread_id = thread . id
177- community_id = community . id
178-
179- { :ok , ret_community } = CMS . set_thread ( % Community { id: community_id } , % Thread { id: thread_id } )
175+ { :ok , ret_community } = CMS . set_thread ( community , thread )
180176
181177 assert ret_community . id == community . id
182178 end
@@ -185,6 +181,7 @@ defmodule MastaniServer.Test.CMS do
185181 describe "[cms community editors]" do
186182 alias CMS . { Community , CommunityEditor }
187183
184+ @ tag :wip
188185 test "can add editor to a community, editor has default passport" , ~m( user community) a do
189186 title = "chief editor"
190187
@@ -193,7 +190,7 @@ defmodule MastaniServer.Test.CMS do
193190 related_rules = Certification . passport_rules ( cms: title )
194191
195192 { :ok , editor } = CommunityEditor |> ORM . find_by ( user_id: user . id )
196- { :ok , user_passport } = CMS . get_passport ( % User { id: user . id } )
193+ { :ok , user_passport } = CMS . get_passport ( user )
197194
198195 assert editor . user_id == user . id
199196 assert editor . community_id == community . id
0 commit comments