From 1ee31ea0c7551fcc666843627bce385f9ca826cb Mon Sep 17 00:00:00 2001 From: John Shaughnessy Date: Thu, 29 Jun 2023 12:26:24 -0400 Subject: [PATCH] Return `file_not_found` if trying to activate non existant owned file --- lib/ret/owned_file.ex | 10 +++++++++- test/ret_web/channels/entity_test.exs | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/ret/owned_file.ex b/lib/ret/owned_file.ex index 28cb0bd03..16af0bc6d 100644 --- a/lib/ret/owned_file.ex +++ b/lib/ret/owned_file.ex @@ -41,12 +41,20 @@ defmodule Ret.OwnedFile do def set_active(owned_file_uuid, account_id) do get_by_uuid_and_account(owned_file_uuid, account_id) |> set_state(:active) + + case get_by_uuid_and_account(owned_file_uuid, account_id) do + nil -> + {:error, :file_not_found} + + owned_file -> + set_state(owned_file, :active) + end end def set_inactive(owned_file_uuid, account_id) do case get_by_uuid_and_account(owned_file_uuid, account_id) do nil -> - {:error, :non_existent_file_id} + {:error, :file_not_found} owned_file -> set_state(owned_file, :inactive) diff --git a/test/ret_web/channels/entity_test.exs b/test/ret_web/channels/entity_test.exs index f1bb85647..3c734683d 100644 --- a/test/ret_web/channels/entity_test.exs +++ b/test/ret_web/channels/entity_test.exs @@ -175,7 +175,7 @@ defmodule RetWeb.EntityTest do Map.put(@payload_delete_entity_state, "file_id", "non_existent_file_id") assert_reply push(socket, "delete_entity_state", non_existent_file_payload), :error, %{ - reason: :non_existent_file_id + reason: :file_not_found } end