Delete media items (#20)
* Added method for deleting media files and their content * Adds controllers and methods for deleting media and files * Improved tmpfile setup and teardown for tests * Actually got tmpfile cleanup running once per suite run * Finally fixed flash messages
This commit is contained in:
@@ -34,6 +34,7 @@ defmodule PinchflatWeb.ConnCase do
|
||||
|
||||
setup tags do
|
||||
Pinchflat.DataCase.setup_sandbox(tags)
|
||||
Pinchflat.DataCase.setup_temp_filepaths()
|
||||
{:ok, conn: Phoenix.ConnTest.build_conn()}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,6 +32,20 @@ defmodule Pinchflat.DataCase do
|
||||
|
||||
setup tags do
|
||||
Pinchflat.DataCase.setup_sandbox(tags)
|
||||
Pinchflat.DataCase.setup_temp_filepaths()
|
||||
:ok
|
||||
end
|
||||
|
||||
@doc """
|
||||
Sets up the temp filepaths for the media and metadata directories.
|
||||
"""
|
||||
def setup_temp_filepaths do
|
||||
File.rm_rf!(Application.get_env(:pinchflat, :media_directory))
|
||||
File.rm_rf!(Application.get_env(:pinchflat, :metadata_directory))
|
||||
|
||||
File.mkdir_p!(Application.get_env(:pinchflat, :media_directory))
|
||||
File.mkdir_p!(Application.get_env(:pinchflat, :metadata_directory))
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 69 KiB |
@@ -31,9 +31,9 @@ defmodule Pinchflat.MediaFixtures do
|
||||
def media_item_with_metadata(attrs \\ %{}) do
|
||||
json_filepath =
|
||||
Path.join([
|
||||
Path.dirname(__ENV__.file),
|
||||
File.cwd!(),
|
||||
"test",
|
||||
"support",
|
||||
"fixtures",
|
||||
"files",
|
||||
"media_metadata.json"
|
||||
])
|
||||
@@ -44,4 +44,28 @@ defmodule Pinchflat.MediaFixtures do
|
||||
|
||||
media_item_fixture(merged_attrs)
|
||||
end
|
||||
|
||||
def media_item_with_attachments(attrs \\ %{}) do
|
||||
stored_media_filepath =
|
||||
Path.join([
|
||||
Application.get_env(:pinchflat, :media_directory),
|
||||
"#{:rand.uniform(1_000_000)}",
|
||||
"#{:rand.uniform(1_000_000)}_media.mkv"
|
||||
])
|
||||
|
||||
fixture_media_filepath =
|
||||
Path.join([
|
||||
File.cwd!(),
|
||||
"test",
|
||||
"support",
|
||||
"files",
|
||||
"media.mkv"
|
||||
])
|
||||
|
||||
:ok = File.mkdir_p(Path.dirname(stored_media_filepath))
|
||||
:ok = File.cp(fixture_media_filepath, stored_media_filepath)
|
||||
|
||||
merged_attrs = Map.merge(attrs, %{media_filepath: stored_media_filepath})
|
||||
media_item_fixture(merged_attrs)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user