Browse Source

User can see issue comments

pull/37/head
Nafies Luthfi 7 years ago
parent
commit
bc9f380c85
  1. 3
      app/Http/Controllers/Projects/IssueController.php
  2. 9
      resources/views/projects/issues/partials/comment-section.blade.php
  3. 2
      resources/views/projects/issues/show.blade.php
  4. 29
      tests/Feature/Projects/IssueCommentsTest.php

3
app/Http/Controllers/Projects/IssueController.php

@ -50,12 +50,13 @@ class IssueController extends Controller
public function show(Project $project, Issue $issue)
{
$comments = $issue->comments;
$priorities = Priority::toArray();
$statuses = IssueStatus::toArray();
$users = User::pluck('name', 'id');
return view('projects.issues.show', compact(
'project', 'issue', 'users', 'statuses', 'priorities'
'project', 'issue', 'users', 'statuses', 'priorities', 'comments'
));
}

9
resources/views/projects/issues/partials/comment-section.blade.php

@ -0,0 +1,9 @@
@foreach($comments as $comment)
<div class="alert alert-warning">
<legend style="font-size: 14px;margin-bottom: 10px;">
<span class="label label-default pull-right">{{ $comment->time_display }}</span>
<strong>{{ $comment->creator->name }}</strong>
</legend>
{!! nl2br($comment->body) !!}
</div>
@endforeach

2
resources/views/projects/issues/show.blade.php

@ -32,6 +32,8 @@
{{ link_to_route('projects.issues.index', __('issue.back_to_index'), [$project], ['class' => 'btn btn-default pull-right']) }}
</div>
</div>
@include('projects.issues.partials.comment-section')
</div>
<div class="col-md-6">
{{ Form::model($issue, ['route' => ['issues.options.update', $issue], 'method' => 'patch']) }}

29
tests/Feature/Projects/IssueCommentsTest.php

@ -0,0 +1,29 @@
<?php
namespace Tests\Feature\Projects;
use Tests\TestCase;
use App\Entities\Projects\Issue;
use App\Entities\Projects\Comment;
use Illuminate\Foundation\Testing\RefreshDatabase;
class IssueCommentsTest extends TestCase
{
use RefreshDatabase;
/** @test */
public function user_can_view_issue_comments()
{
$this->adminUserSigningIn();
$issue = factory(Issue::class)->create();
$comment = factory(Comment::class)->create([
'commentable_type' => 'issues',
'commentable_id' => $issue->id,
'body' => 'This is issue comment.',
]);
$this->visitRoute('projects.issues.show', [$issue->project, $issue]);
$this->seeText('This is issue comment.');
}
}
Loading…
Cancel
Save