Skip to content

Commit

Permalink
fix routes and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dbakan committed Jul 13, 2024
1 parent 431da6c commit a175b6a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,28 +549,28 @@
Api\AssetFilesController::class,
'store'
]
)->name('api.assets.files');
)->name('api.assets.files.store');

Route::get('{asset_id}/files',
[
Api\AssetFilesController::class,
'list'
]
)->name('api.assets.files');
)->name('api.assets.files.index');

Route::get('{asset_id}/file/{file_id}',
[
Api\AssetFilesController::class,
'show'
]
)->name('api.assets.file');
)->name('api.assets.files.show');

Route::delete('{asset_id}/file/{file_id}',
[
Api\AssetFilesController::class,
'destroy'
]
)->name('api.assets.file');
)->name('api.assets.files.destroy');

});

Expand Down
16 changes: 8 additions & 8 deletions tests/Feature/Assets/Api/AssetFilesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testAssetApiAcceptsFileUpload()
//Upload a file
$this->actingAsForApi($user)
->post(
route('api.assets.files', ['asset_id' => $asset[0]["id"]]), [
route('api.assets.files.store', ['asset_id' => $asset[0]["id"]]), [
'file' => [UploadedFile::fake()->create("test.jpg", 100)]
])
->assertOk();
Expand All @@ -41,7 +41,7 @@ public function testAssetApiListsFiles()
// List the files
$this->actingAsForApi($user)
->getJson(
route('api.assets.files', ['asset_id' => $asset[0]["id"]]))
route('api.assets.files.index', ['asset_id' => $asset[0]["id"]]))
->assertOk()
->assertJsonStructure([
'status',
Expand All @@ -63,21 +63,21 @@ public function testAssetApiDownloadsFile()
//Upload a file
$this->actingAsForApi($user)
->post(
route('api.assets.files', ['asset_id' => $asset[0]["id"]]), [
route('api.assets.files.store', ['asset_id' => $asset[0]["id"]]), [
'file' => [UploadedFile::fake()->create("test.jpg", 100)]
])
->assertOk();

// List the files to get the file ID
$result = $this->actingAsForApi($user)
->getJson(
route('api.assets.files', ['asset_id' => $asset[0]["id"]]))
route('api.assets.files.index', ['asset_id' => $asset[0]["id"]]))
->assertOk();

// Get the file
$this->actingAsForApi($user)
->get(
route('api.assets.file', [
route('api.assets.files.show', [
'asset_id' => $asset[0]["id"],
'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"],
]))
Expand All @@ -97,21 +97,21 @@ public function testAssetApiDeletesFile()
//Upload a file
$this->actingAsForApi($user)
->post(
route('api.assets.files', ['asset_id' => $asset[0]["id"]]), [
route('api.assets.files.store', ['asset_id' => $asset[0]["id"]]), [
'file' => [UploadedFile::fake()->create("test.jpg", 100)]
])
->assertOk();

// List the files to get the file ID
$result = $this->actingAsForApi($user)
->getJson(
route('api.assets.files', ['asset_id' => $asset[0]["id"]]))
route('api.assets.files.index', ['asset_id' => $asset[0]["id"]]))
->assertOk();

// Delete the file
$this->actingAsForApi($user)
->delete(
route('api.assets.file', [
route('api.assets.files.destroy', [
'asset_id' => $asset[0]["id"],
'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"],
]))
Expand Down

0 comments on commit a175b6a

Please sign in to comment.