activity = Activity.get_by_id_with_object(last_activity_id)
- # Conversations return all users except current user when current user is not only participant
+ # Conversations return all users except the current user,
+ # except when the current user is the only participant
users =
if length(participation.recipients) > 1 do
Enum.reject(participation.recipients, &(&1.id == user.id))
assert Participation.unread_count(user_one) == 0
end
- test "special behaviour when conversation have only one user", %{
+ test "includes the user if the user is the only participant", %{
user: user_one,
- user_two: user_two,
conn: conn
} do
- {:ok, direct} = create_direct_message(user_one, [])
+ {:ok, _direct} = create_direct_message(user_one, [])
res_conn = get(conn, "/api/v1/conversations")
assert [
%{
- "accounts" => res_accounts,
- "last_status" => res_last_status
+ "accounts" => [account]
}
] = response
- account_ids = Enum.map(res_accounts, & &1["id"])
- assert length(res_accounts) == 1
- assert user_one.id in account_ids
+ assert user_one.id == account["id"]
end
test "observes limit params", %{
assert conversation.last_status.id == activity.id
assert conversation.last_status.account.id == user.id
- account_ids = Enum.map(conversation.accounts, & &1.id)
- assert length(conversation.accounts) == 1
- assert other_user.id in account_ids
+ assert [account] = conversation.accounts
+ assert account.id == other_user.id
+
assert conversation.last_status.pleroma.direct_conversation_id == participation.id
end
end