test: add destroy post tests for status filters and redirect param
This commit is contained in:
parent
44f9f67b7d
commit
6fc9defb89
1 changed files with 28 additions and 1 deletions
|
|
@ -241,7 +241,7 @@
|
|||
$response->assertRedirect(route('login'));
|
||||
});
|
||||
|
||||
test('destroy post deletes the post', function () {
|
||||
test('destroy post deletes the post and redirects back', function () {
|
||||
$post = Post::factory()->create([
|
||||
'workspace_id' => $this->workspace->id,
|
||||
'user_id' => $this->user->id,
|
||||
|
|
@ -255,6 +255,33 @@
|
|||
expect(Post::find($post->id))->toBeNull();
|
||||
});
|
||||
|
||||
test('destroy post from status filter redirects back to filter', function (string $status) {
|
||||
$post = Post::factory()->create([
|
||||
'workspace_id' => $this->workspace->id,
|
||||
'user_id' => $this->user->id,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($this->user)
|
||||
->from(route('posts.index', ['status' => $status]))
|
||||
->delete(route('posts.destroy', $post));
|
||||
|
||||
$response->assertRedirect(route('posts.index', ['status' => $status]));
|
||||
expect(Post::find($post->id))->toBeNull();
|
||||
})->with(['draft', 'scheduled', 'published']);
|
||||
|
||||
test('destroy post with redirect param redirects to specified route', function () {
|
||||
$post = Post::factory()->create([
|
||||
'workspace_id' => $this->workspace->id,
|
||||
'user_id' => $this->user->id,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($this->user)
|
||||
->delete(route('posts.destroy', $post).'?redirect=posts.index');
|
||||
|
||||
$response->assertRedirect(route('posts.index'));
|
||||
expect(Post::find($post->id))->toBeNull();
|
||||
});
|
||||
|
||||
test('destroy post returns 404 for post from different workspace', function () {
|
||||
$otherWorkspace = Workspace::factory()->create();
|
||||
$post = Post::factory()->create([
|
||||
|
|
|
|||
Loading…
Reference in a new issue