Skip to content

Commit

Permalink
Test guest users cannot manage posts
Browse files Browse the repository at this point in the history
  • Loading branch information
unclexo committed Dec 15, 2022
1 parent 7087140 commit b938a75
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/views/posts/edit.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
16 changes: 16 additions & 0 deletions tests/Feature/PostModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,20 @@ public function a_user_can_delete_a_post()

$this->assertDatabaseMissing('posts', $post->only('id'));
}

/** @test */
public function guest_users_can_not_manage_posts()
{
$post = Post::factory()->create();

$this->get(route('posts.index'))->assertRedirect(route('login'));

$this->get($post->path())->assertRedirect(route('login'));

$this->get(route('posts.create'))->assertRedirect(route('login'));

$this->get(route('posts.edit', $post->id))->assertRedirect(route('login'));

$this->post(route('posts.store'), $post->toArray())->assertRedirect(route('login'));
}
}

0 comments on commit b938a75

Please sign in to comment.