diff --git a/src/App/Users/Actions/CheckStorageCapacityAction.php b/src/App/Users/Actions/CheckStorageCapacityAction.php index d45dccad..30363fcd 100644 --- a/src/App/Users/Actions/CheckStorageCapacityAction.php +++ b/src/App/Users/Actions/CheckStorageCapacityAction.php @@ -23,7 +23,6 @@ class CheckStorageCapacityAction ->delete("chunks/$temp_filename"); // Abort uploading - // TODO: test pre exceed storage limit abort(423, 'You exceed your storage limit!'); } } diff --git a/tests/Domain/Files/FileTest.php b/tests/Domain/Files/FileTest.php index dcaae2ec..078786cc 100644 --- a/tests/Domain/Files/FileTest.php +++ b/tests/Domain/Files/FileTest.php @@ -1,4 +1,5 @@ 'storage_limitation', + 'value' => 1, + ]); + + $file = UploadedFile::fake() + ->image('fake-file.jpeg', 1000); + + $user = User::factory(User::class) + ->create(); + + $user->settings()->update([ + 'storage_capacity' => 1, + ]); + + File::factory(File::class) + ->create([ + 'user_id' => $user->id, + 'filesize' => '1000000000', + ]); + + $this + ->actingAs($user) + ->postJson('/api/upload', [ + 'filename' => $file->name, + 'file' => $file, + 'folder_id' => null, + 'is_last' => 'true', + ])->assertStatus(423); + + Storage::disk('local')->assertMissing( + "files/$user->id/fake-file.jpeg" + ); + } + /** * @test */