Skip to content

Commit

Permalink
Return file_not_found if trying to activate non existant owned file
Browse files Browse the repository at this point in the history
  • Loading branch information
johnshaughnessy committed Jun 29, 2023
1 parent f16b5fb commit 1ee31ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/ret/owned_file.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/ret_web/channels/entity_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1ee31ea

Please sign in to comment.