Skip to content

Commit 64e4394

Browse files
committed
Add tests to check for a conversation_part when a conversation is updated with a status of closed
1 parent 6dcea77 commit 64e4394

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/code_corps/messages/messages.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ defmodule CodeCorps.Messages do
5959
%{status: status} = params
6060
case status do
6161
"reopened" ->
62-
add_part(%{"conversation_id" => conversation.id, "body" => "reopened", "author_id" => conversation.user_id, "part_type" => "reopened"})
62+
add_part(%{"conversation_id" => conversation.id, "body" => "reopened", "author_id"
63+
=> conversation.user_id, "part_type" => "reopened"})
64+
"closed" ->
65+
add_part(%{"conversation_id" => conversation.id, "body" => "closed", "author_id"
66+
=> conversation.user_id, "part_type" => "closed"})
67+
6368
end
6469
conversation |> Conversation.update_changeset(params) |> Repo.update
6570
end

test/lib/code_corps/messages/messages_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ defmodule CodeCorps.MessagesTest do
259259
assert conversation_part.conversation_id == conversation.id
260260
end
261261

262-
test "creates a conversation_part of part_type closed when a conversation is reopened" do
262+
test "creates a conversation_part of part_type closed when a conversation is closed" do
263263
conversation = insert(:conversation)
264264

265265
assert Repo.aggregate(ConversationPart, :count, :id) == 0

0 commit comments

Comments
 (0)