Permalink
Browse files

Episode 70

  • Loading branch information...
JeffreyWay committed Aug 22, 2017
1 parent f971754 commit 8c881b29ace1e332d233c956c34576719baae10c
@@ -91,6 +91,8 @@ public function show($channel, Thread $thread, Trending $trending)
$trending->push($thread);
$thread->increment('visits');
return view('threads.show', compact('thread'));
}
@@ -33,7 +33,8 @@
return factory('App\Channel')->create()->id;
},
'title' => $faker->sentence,
'body' => $faker->paragraph
'body' => $faker->paragraph,
'visits' => 0
];
});
@@ -18,6 +18,7 @@ public function up()
$table->unsignedInteger('user_id');
$table->unsignedInteger('channel_id');
$table->unsignedInteger('replies_count')->default(0);
$table->unsignedInteger('visits')->default(0);
$table->string('title');
$table->text('body');
$table->timestamps();
@@ -29,6 +29,10 @@
<div class="panel-body">
<div class="body">{{ $thread->body }}</div>
</div>
<div class="panel-footer">
{{ $thread->visits }} Visits
</div>
</div>
@empty
<p>There are no relevant results at this time.</p>
@@ -95,4 +95,16 @@ function a_user_can_request_all_replies_for_a_given_thread()
$this->assertCount(2, $response['data']);
$this->assertEquals(2, $response['total']);
}
/** @test */
function we_record_a_new_visit_each_time_the_thread_is_read()
{
$thread = create('App\Thread');
$this->assertSame(0, $thread->visits);
$this->call('GET', $thread->path());
$this->assertEquals(1, $thread->fresh()->visits);
}
}

0 comments on commit 8c881b2

Please sign in to comment.