Skip to content
Permalink
Browse files

Episode 35

  • Loading branch information...
JeffreyWay committed Mar 22, 2019
1 parent 5c38e83 commit 3d69a1640fe9b44a066942836ff7635891323085
@@ -91,7 +91,7 @@ public function update(Project $project)
*/
public function destroy(Project $project)
{
$this->authorize('update', $project);
$this->authorize('manage', $project);
$project->delete();
@@ -6,6 +6,7 @@
return [
'title' => $faker->sentence(4),
'description' => $faker->sentence(4),
'notes' => 'Foobar notes',
'owner_id' => factory(App\User::class)
];
});
@@ -5,11 +5,13 @@

<div class="text-grey mb-4 flex-1">{{ str_limit($project->description, 100) }}</div>

<footer>
<form method="POST" action="{{ $project->path() }}" class="text-right">
@method('DELETE')
@csrf
<button type="submit" class="text-xs">Delete</button>
</form>
</footer>
@can ('manage', $project)
<footer>
<form method="POST" action="{{ $project->path() }}" class="text-right">
@method('DELETE')
@csrf
<button type="submit" class="text-xs">Delete</button>
</form>
</footer>
@endcan
</div>
@@ -31,19 +31,8 @@ public function a_user_can_create_a_project()
$this->get('/projects/create')->assertStatus(200);
$attributes = [
'title' => $this->faker->sentence,
'description' => $this->faker->sentence,
'notes' => 'General notes here.'
];
$response = $this->post('/projects', $attributes);
$project = Project::where($attributes)->first();
$response->assertRedirect($project->path());
$this->get($project->path())
$this->followingRedirects()
->post('/projects', $attributes = factory(Project::class)->raw())
->assertSee($attributes['title'])
->assertSee($attributes['description'])
->assertSee($attributes['notes']);
@@ -65,10 +54,13 @@ function unauthorized_users_cannot_delete_projects()
$this->delete($project->path())
->assertRedirect('/login');
$this->signIn();
$user = $this->signIn();
$this->delete($project->path())
->assertStatus(403);
$this->delete($project->path())->assertStatus(403);
$project->invite($user);
$this->actingAs($user)->delete($project->path())->assertStatus(403);
}
/** @test */

0 comments on commit 3d69a16

Please sign in to comment.
You can’t perform that action at this time.