Fix tests
This commit is contained in:
@@ -92,13 +92,17 @@ class MetricPoint extends Model implements HasPresenter
|
|||||||
/**
|
/**
|
||||||
* Round the created at value into intervals of 30 seconds.
|
* Round the created at value into intervals of 30 seconds.
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $createdAt
|
||||||
*
|
*
|
||||||
* @return void
|
* @return string|void
|
||||||
*/
|
*/
|
||||||
public function setCreatedAtAttribute($value)
|
public function setCreatedAtAttribute($createdAt)
|
||||||
{
|
{
|
||||||
$timestamp = $value->format('U');
|
if (!$createdAt) return;
|
||||||
|
|
||||||
|
$createdAt = Carbon::parse($createdAt);
|
||||||
|
|
||||||
|
$timestamp = $createdAt->format('U');
|
||||||
$timestamp = 30 * round($timestamp / 30);
|
$timestamp = 30 * round($timestamp / 30);
|
||||||
|
|
||||||
return Carbon::createFromFormat('U', $timestamp)->toDateTimeString();
|
return Carbon::createFromFormat('U', $timestamp)->toDateTimeString();
|
||||||
|
|||||||
@@ -78,11 +78,12 @@ class MetricPointTest extends AbstractApiTestCase
|
|||||||
$postData['timestamp'] = $timestamp;
|
$postData['timestamp'] = $timestamp;
|
||||||
|
|
||||||
$response = $this->json('POST', "/api/v1/metrics/{$metric->id}/points", $postData);
|
$response = $this->json('POST', "/api/v1/metrics/{$metric->id}/points", $postData);
|
||||||
|
$response->dump();
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
$response->assertJsonFragment([
|
$response->assertJsonFragment([
|
||||||
'value' => $metricPoint->value,
|
'value' => $metricPoint->value,
|
||||||
'created_at' => date('Y-m-d H:i:s', 1434369116),
|
'created_at' => date('Y-m-d H:i:00', 1434369116),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user