updates to UI and add archiving option
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @method \Illuminate\Testing\TestResponse post(string $uri, array $data = [])
|
||||
* @method \Illuminate\Testing\TestResponse put(string $uri, array $data = [])
|
||||
* @method \Illuminate\Testing\TestResponse delete(string $uri, array $data = [])
|
||||
* @method $this actingAs(\App\Models\User $user, ?string $guard = null)
|
||||
*/
|
||||
|
||||
use App\Models\ArchiveSetting;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
/** @var \Tests\TestCase $this */
|
||||
it('creates an archive setting', function () {
|
||||
$user = User::factory()->create();
|
||||
test()->actingAs($user);
|
||||
|
||||
$response = test()->post(route('settings.archive.store'), [
|
||||
'entities' => [
|
||||
['table' => 'documents', 'conditions' => ['older_than_days' => 30]],
|
||||
],
|
||||
'strategy' => 'immediate',
|
||||
'soft' => true,
|
||||
'enabled' => true,
|
||||
]);
|
||||
|
||||
$response->assertRedirect();
|
||||
expect(ArchiveSetting::count())->toBe(1);
|
||||
});
|
||||
|
||||
it('updates an archive setting', function () {
|
||||
$user = User::factory()->create();
|
||||
test()->actingAs($user);
|
||||
$setting = ArchiveSetting::factory()->create();
|
||||
|
||||
$response = test()->put(route('settings.archive.update', $setting->id), [
|
||||
'entities' => $setting->entities,
|
||||
'strategy' => 'queued',
|
||||
'soft' => false,
|
||||
'enabled' => false,
|
||||
]);
|
||||
|
||||
$response->assertRedirect();
|
||||
$setting->refresh();
|
||||
expect($setting->strategy)->toBe('queued')
|
||||
->and($setting->soft)->toBeFalse()
|
||||
->and($setting->enabled)->toBeFalse();
|
||||
});
|
||||
|
||||
it('deletes an archive setting', function () {
|
||||
$user = User::factory()->create();
|
||||
test()->actingAs($user);
|
||||
$setting = ArchiveSetting::factory()->create();
|
||||
|
||||
$response = test()->delete(route('settings.archive.destroy', $setting->id));
|
||||
$response->assertRedirect();
|
||||
expect(ArchiveSetting::withTrashed()->count())->toBe(1) // soft deleted
|
||||
->and(ArchiveSetting::count())->toBe(0);
|
||||
});
|
||||
Reference in New Issue
Block a user