Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit2f53345

Browse files
committed
fix(community): error test
1 parent2ea73d3 commit2f53345

File tree

5 files changed

+23
-35
lines changed

5 files changed

+23
-35
lines changed

‎lib/groupher_server/cms/delegates/community_operation.ex‎

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
7171
:insert_editor,
7272
CommunityEditor.changeset(%CommunityEditor{},~m(user_id community_id title)a)
7373
)
74-
|>Multi.run(:update_editors_count,fn_,_->
74+
|>Multi.run(:update_community_count,fn_,_->
7575
with{:ok,community}<-ORM.find(Community,community_id)do
7676
CommunityCURD.update_community_count_field(community,user_id,:editors_count,:inc)
7777
end
@@ -92,7 +92,7 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
9292
|>Multi.run(:delete_editor,fn_,_->
9393
ORM.findby_delete!(CommunityEditor,~m(user_id community_id)a)
9494
end)
95-
|>Multi.run(:update_editors_count,fn_,_->
95+
|>Multi.run(:update_community_count,fn_,_->
9696
with{:ok,community}<-ORM.find(Community,community_id)do
9797
CommunityCURD.update_community_count_field(community,user_id,:editors_count,:dec)
9898
end
@@ -143,16 +143,14 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
143143
"""
144144
defunsubscribe_community(%Community{id:community_id},%User{id:user_id})do
145145
with{:ok,community}<-ORM.find(Community,community_id),
146-
true<-community.raw!=="home",
147-
{:ok,record}<-
148-
ORM.findby_delete!(CommunitySubscriber,community_id:community.id,user_id:user_id)do
146+
true<-community.raw!=="home"do
149147
Multi.new()
150-
|>Multi.run(:unsubscribed_community,fn_,_->
151-
ORM.find(Community,record.community_id)
152-
end)
153-
|>Multi.run(:update_community_count,fn_,%{unsubscribed_community:community}->
148+
|>Multi.run(:update_community_count,fn_,_->
154149
CommunityCURD.update_community_count_field(community,user_id,:subscribers_count,:dec)
155150
end)
151+
|>Multi.run(:unsubscribed_community,fn_,_->
152+
ORM.findby_delete!(CommunitySubscriber,%{community_id:community.id,user_id:user_id})
153+
end)
156154
|>Repo.transaction()
157155
|>result()
158156
else
@@ -170,19 +168,17 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
170168
remote_ip
171169
)do
172170
with{:ok,community}<-ORM.find(Community,community_id),
173-
true<-community.raw!=="home",
174-
{:ok,record}<-
175-
CommunitySubscriber|>ORM.findby_delete!(community_id:community.id,user_id:user_id)do
171+
true<-community.raw!=="home"do
176172
Multi.new()
173+
|>Multi.run(:update_community_count,fn_,_->
174+
CommunityCURD.update_community_count_field(community,user_id,:subscribers_count,:dec)
175+
end)
177176
|>Multi.run(:unsubscribed_community,fn_,_->
178-
ORM.find(Community,record.community_id)
177+
ORM.findby_delete!(CommunitySubscriber,%{community_id:community.id,user_id:user_id})
179178
end)
180179
|>Multi.run(:update_community_geo,fn_,_->
181180
update_community_geo(community_id,user_id,remote_ip,:dec)
182181
end)
183-
|>Multi.run(:update_community_count,fn_,%{unsubscribed_community:community}->
184-
CommunityCURD.update_community_count_field(community,user_id,:subscribers_count,:dec)
185-
end)
186182
|>Repo.transaction()
187183
|>result()
188184
else
@@ -200,19 +196,17 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
200196
_remote_ip
201197
)do
202198
with{:ok,community}<-ORM.find(Community,community_id),
203-
true<-community.raw!=="home",
204-
{:ok,record}<-
205-
CommunitySubscriber|>ORM.findby_delete!(community_id:community.id,user_id:user_id)do
199+
true<-community.raw!=="home"do
206200
Multi.new()
201+
|>Multi.run(:update_community_count,fn_,_->
202+
CommunityCURD.update_community_count_field(community,user_id,:subscribers_count,:dec)
203+
end)
207204
|>Multi.run(:unsubscribed_community,fn_,_->
208-
ORM.find(Community,record.community_id)
205+
ORM.findby_delete!(CommunitySubscriber,%{community_id:community.id,user_id:user_id})
209206
end)
210207
|>Multi.run(:update_community_geo_city,fn_,_->
211208
update_community_geo_map(community.id,city,:dec)
212209
end)
213-
|>Multi.run(:update_community_count,fn_,%{unsubscribed_community:community}->
214-
CommunityCURD.update_community_count_field(community,user_id,:subscribers_count,:dec)
215-
end)
216210
|>Repo.transaction()
217211
|>result()
218212
else
@@ -311,7 +305,7 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
311305
{:ok,result}
312306
end
313307

314-
defpresult({:ok,%{update_editors_count:result}})do
308+
defpresult({:ok,%{update_community_count:result}})do
315309
{:ok,result}
316310
end
317311

‎test/groupher_server/cms/community/community_test.exs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ defmodule GroupherServer.Test.CMS.Community do
4040
assertuser2.idnot incommunity.meta.subscribed_user_ids
4141
end
4242

43-
@tag:wip2
4443
test"read editored community should have a flag",~m(community user user2)ado
4544
title="chief editor"
4645
{:ok,community}=CMS.set_editor(community,title,user)
@@ -58,7 +57,6 @@ defmodule GroupherServer.Test.CMS.Community do
5857
end
5958

6059
describe"[cms community editor]"do
61-
@tag:wip2
6260
test"can set editor to a community",~m(user community)ado
6361
title="chief editor"
6462
{:ok,community}=CMS.set_editor(community,title,user)
@@ -67,7 +65,6 @@ defmodule GroupherServer.Test.CMS.Community do
6765
assertuser.idincommunity.meta.editors_ids
6866
end
6967

70-
@tag:wip2
7168
test"can unset editor to a community",~m(user community)ado
7269
title="chief editor"
7370
{:ok,community}=CMS.set_editor(community,title,user)

‎test/groupher_server_web/mutation/cms/cms_test.exs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,10 @@ defmodule GroupherServer.Test.Mutation.CMS.Basic do
529529
mutation($communityId: ID!){
530530
unsubscribeCommunity(communityId: $communityId) {
531531
id
532-
subscribers {
533-
id
534-
}
535532
}
536533
}
537534
"""
535+
@tag:wip2
538536
test"login user can unsubscribe community",~m(user community)ado
539537
{:ok,cur_subscribers}=
540538
CMS.community_members(:subscribers,%Community{id:community.id},%{page:1,size:10})
@@ -547,7 +545,6 @@ defmodule GroupherServer.Test.Mutation.CMS.Basic do
547545
CMS.community_members(:subscribers,%Community{id:community.id},%{page:1,size:10})
548546

549547
asserttrue==cur_subscribers.entries|>Enum.any?(&(&1.id==user.id))
550-
551548
login_conn=simu_conn(:user,user)
552549

553550
variables=%{communityId:community.id}

‎test/groupher_server_web/query/cms/articles/repo_test.exs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmodule GroupherServer.Test.Query.Articles.Repo do
1919
}
2020
}
2121
"""
22-
@tag:wip2
22+
2323
test"basic graphql query on repo with logined user",~m(user_conn repo)ado
2424
variables=%{id:repo.id}
2525
results=user_conn|>query_result(@query,variables,"repo")

‎test/groupher_server_web/query/cms/cms_test.exs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ defmodule GroupherServer.Test.Query.CMS.Basic do
322322
}
323323
}
324324
"""
325-
@tag:wip2
325+
326326
test"guest can get editors count of a community",~m(guest_conn community)ado
327327
title="chief editor"
328328
{:ok,users}=db_insert_multi(:user,assert_v(:inner_page_size))
@@ -350,7 +350,7 @@ defmodule GroupherServer.Test.Query.CMS.Basic do
350350
}
351351
}
352352
"""
353-
@tag:wip2
353+
354354
test"guest user can get paged editors",~m(guest_conn community)ado
355355
title="chief editor"
356356
{:ok,users}=db_insert_multi(:user,25)
@@ -373,7 +373,7 @@ defmodule GroupherServer.Test.Query.CMS.Basic do
373373
}
374374
}
375375
"""
376-
@tag:wip2
376+
377377
test"guest can get subscribers count of a community",~m(guest_conn community)ado
378378
{:ok,users}=db_insert_multi(:user,assert_v(:inner_page_size))
379379

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp