Skip to content

Commit

Permalink
Episode 19 Complete
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Jan 22, 2019
1 parent 89d8ecb commit 47adf55
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/ProjectsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ public function update(Project $project)
protected function validateRequest()
{
return request()->validate([
'title' => 'required',
'description' => 'required',
'notes' => 'min:3'
'title' => 'sometimes|required',
'description' => 'sometimes|required',
'notes' => 'nullable'
]);
}
}
7 changes: 7 additions & 0 deletions resources/views/errors.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@if ($errors->any())
<div class="field mt-6">
@foreach ($errors->all() as $error)
<li class="text-sm text-red">{{ $error }}</li>
@endforeach
</div>
@endif
8 changes: 1 addition & 7 deletions resources/views/projects/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,4 @@ class="textarea bg-transparent border border-grey-light rounded p-2 text-xs w-fu
</div>
</div>

@if ($errors->any())
<div class="field mt-6">
@foreach ($errors->all() as $error)
<li class="text-sm text-red">{{ $error }}</li>
@endforeach
</div>
@endif
@include ('errors')
2 changes: 2 additions & 0 deletions resources/views/projects/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class="card w-full mb-4"

<button type="submit" class="button">Save</button>
</form>

@include ('errors')
</div>
</div>

Expand Down
12 changes: 12 additions & 0 deletions tests/Feature/ManageProjectsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ function a_user_can_update_a_project()
$this->assertDatabaseHas('projects', $attributes);
}

/** @test */
function a_user_can_update_a_projects_general_notes()
{
$project = ProjectFactory::create();

$this->actingAs($project->owner)
->patch($project->path(), $attributes = ['notes' => 'Changed']);

$this->assertDatabaseHas('projects', $attributes);

}

/** @test */
public function a_user_can_view_their_project()
{
Expand Down

0 comments on commit 47adf55

Please sign in to comment.