Skip to content

Commit 166ff1a

Browse files
snewcomerbegedin
authored andcommitted
Scope CommentPart records to "comment" type for regular users (#1344)
1 parent c7f8eb9 commit 166ff1a

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/code_corps/policy/conversation_part.ex

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ defmodule CodeCorps.Policy.ConversationPart do
2424
queryable
2525
|> where(author_id: ^id)
2626
|> or_where([cp], cp.conversation_id in ^scoped_conversation_ids)
27+
|> where(part_type: "comment")
2728
end
2829

2930
def create?(%User{} = user, %{"conversation_id" => _} = params) do

test/lib/code_corps/policy/conversation_part_test.exs

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ defmodule CodeCorps.Policy.ConversationPartTest do
7171
insert(:conversation_part, conversation: conversation_when_owner)
7272
part_in_some_other_conversation =
7373
insert(:conversation_part, conversation: some_other_conversation)
74+
part_closed =
75+
insert(:conversation_part, conversation: conversation_when_target, part_type: "closed")
7476

7577
result_ids =
7678
ConversationPart
@@ -84,6 +86,7 @@ defmodule CodeCorps.Policy.ConversationPartTest do
8486
assert part_in_administered_project.id in result_ids
8587
assert part_in_owned_project.id in result_ids
8688
refute part_in_some_other_conversation.id in result_ids
89+
refute part_closed.id in result_ids
8790
end
8891
end
8992

0 commit comments

Comments
 (0)