Skip to content

Commit

Permalink
limit scope to comment part type
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Dec 26, 2017
1 parent 65ec89b commit 8ce7a66
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/code_corps/policy/conversation_part.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ defmodule CodeCorps.Policy.ConversationPart do
queryable
|> where(author_id: ^id)
|> or_where([cp], cp.conversation_id in ^scoped_conversation_ids)
|> where(part_type: "comment")
end

def create?(%User{} = user, %{"conversation_id" => _} = params) do
Expand Down
3 changes: 3 additions & 0 deletions test/lib/code_corps/policy/conversation_part_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ defmodule CodeCorps.Policy.ConversationPartTest do
insert(:conversation_part, conversation: conversation_when_owner)
part_in_some_other_conversation =
insert(:conversation_part, conversation: some_other_conversation)
part_closed =
insert(:conversation_part, conversation: conversation_when_target, part_type: "closed")

result_ids =
ConversationPart
Expand All @@ -84,6 +86,7 @@ defmodule CodeCorps.Policy.ConversationPartTest do
assert part_in_administered_project.id in result_ids
assert part_in_owned_project.id in result_ids
refute part_in_some_other_conversation.id in result_ids
refute part_closed.id in result_ids
end
end

Expand Down

0 comments on commit 8ce7a66

Please sign in to comment.