Merge branch '2.4' into feature/merge-install-commands
This commit is contained in:
@@ -45,15 +45,6 @@ Here are some useful quick links:
|
|||||||
|
|
||||||
### Demo
|
### Demo
|
||||||
|
|
||||||
To test out the demo, you may login to the [Dashboard](https://demo.cachethq.io/dashboard) with the following:
|
|
||||||
|
|
||||||
- **Username:** `test` or `test@test.com`
|
|
||||||
- **Password:** `test123`
|
|
||||||
|
|
||||||
> The demo resets every 30 minutes.
|
|
||||||
|
|
||||||
### v2.4 Demo
|
|
||||||
|
|
||||||
To test out the demo, you may login to the [Dashboard](https://dev.cachethq.io/dashboard) with the following:
|
To test out the demo, you may login to the [Dashboard](https://dev.cachethq.io/dashboard) with the following:
|
||||||
|
|
||||||
- **Username:** `test` or `test@test.com`
|
- **Username:** `test` or `test@test.com`
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
namespace CachetHQ\Cachet\Console\Commands;
|
namespace CachetHQ\Cachet\Console\Commands;
|
||||||
|
|
||||||
use CachetHQ\Cachet\Models\MetricPoint;
|
use CachetHQ\Cachet\Models\MetricPoint;
|
||||||
use DateInterval;
|
|
||||||
use DateTime;
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Console\ConfirmableTrait;
|
use Illuminate\Console\ConfirmableTrait;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
@@ -66,16 +64,26 @@ class DemoMetricPointSeederCommand extends Command
|
|||||||
{
|
{
|
||||||
MetricPoint::truncate();
|
MetricPoint::truncate();
|
||||||
|
|
||||||
// Generate 11 hours of metric points
|
$points = [];
|
||||||
for ($i = 0; $i < 11; $i++) {
|
|
||||||
$metricTime = (new DateTime())->sub(new DateInterval('PT'.$i.'H'));
|
|
||||||
|
|
||||||
MetricPoint::create([
|
// Generate 24 hours of metric points
|
||||||
'metric_id' => 1,
|
for ($i = 0; $i <= 23; $i++) {
|
||||||
'value' => random_int(1, 10),
|
for ($j = 0; $j <= 59; $j++) {
|
||||||
'created_at' => $metricTime,
|
$this->info("{$i}:{$j}");
|
||||||
'updated_at' => $metricTime,
|
|
||||||
]);
|
$pointTime = date("Y-m-d {$i}:{$j}:00");
|
||||||
|
|
||||||
|
$points[] = [
|
||||||
|
'metric_id' => 1,
|
||||||
|
'value' => random_int(1, 10),
|
||||||
|
'created_at' => $pointTime,
|
||||||
|
'updated_at' => $pointTime,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (array_chunk($points, 100) as $chunk) {
|
||||||
|
MetricPoint::insert($chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use Illuminate\Support\Facades\View;
|
|||||||
/**
|
/**
|
||||||
* This is the component group controller class.
|
* This is the component group controller class.
|
||||||
*
|
*
|
||||||
* @author James Brooks <james@bluebaytravel.co.uk>
|
* @author James Brooks <james@alt-three.com>
|
||||||
*/
|
*/
|
||||||
class ComponentGroupController extends Controller
|
class ComponentGroupController extends Controller
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -81,10 +81,6 @@ class Beacon implements BeaconContract
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($contactEmail = User::admins()->active()->first()->email)) {
|
|
||||||
$contactEmail = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$setting = app(Setting::class);
|
$setting = app(Setting::class);
|
||||||
|
|
||||||
if (!$installId = $setting->get('install_id', null)) {
|
if (!$installId = $setting->get('install_id', null)) {
|
||||||
@@ -94,12 +90,11 @@ class Beacon implements BeaconContract
|
|||||||
}
|
}
|
||||||
|
|
||||||
$payload = [
|
$payload = [
|
||||||
'install_id' => $installId,
|
'install_id' => $installId,
|
||||||
'version' => CACHET_VERSION,
|
'version' => CACHET_VERSION,
|
||||||
'docker' => $this->config->get('cachet.is_docker'),
|
'docker' => $this->config->get('cachet.is_docker'),
|
||||||
'database' => $this->config->get('database.default'),
|
'database' => $this->config->get('database.default'),
|
||||||
'contact_email' => $contactEmail,
|
'data' => [
|
||||||
'data' => [
|
|
||||||
'components' => Component::all()->count(),
|
'components' => Component::all()->count(),
|
||||||
'incidents' => Incident::all()->count(),
|
'incidents' => Incident::all()->count(),
|
||||||
'metrics' => Metric::all()->count(),
|
'metrics' => Metric::all()->count(),
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ class Metric extends Model implements HasPresenter
|
|||||||
*/
|
*/
|
||||||
public function points()
|
public function points()
|
||||||
{
|
{
|
||||||
return $this->hasMany(MetricPoint::class, 'metric_id', 'id');
|
return $this->hasMany(MetricPoint::class, 'metric_id', 'id')->latest();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,6 +29,15 @@ class MetricPoint extends Model implements HasPresenter
|
|||||||
{
|
{
|
||||||
use ValidatingTrait;
|
use ValidatingTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The accessors to append to the model's array form.
|
||||||
|
*
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $appends = [
|
||||||
|
'calculated_value',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The model's attributes.
|
* The model's attributes.
|
||||||
*
|
*
|
||||||
@@ -82,19 +91,13 @@ class MetricPoint extends Model implements HasPresenter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override the value attribute.
|
* Show the actual calculated value; as per (value * counter).
|
||||||
*
|
*
|
||||||
* @param mixed $value
|
* @return int
|
||||||
*
|
|
||||||
* @return float
|
|
||||||
*/
|
*/
|
||||||
public function getActiveValueAttribute($value)
|
public function getCalculatedValueAttribute()
|
||||||
{
|
{
|
||||||
if ($this->metric->calc_type === Metric::CALC_SUM) {
|
return $this->value * $this->counter;
|
||||||
return round((float) $value * $this->counter, $this->metric->places);
|
|
||||||
}
|
|
||||||
|
|
||||||
return round((float) $value, $this->metric->places);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,7 +120,11 @@ class MetricPoint extends Model implements HasPresenter
|
|||||||
$timestamp = $createdAt->format('U');
|
$timestamp = $createdAt->format('U');
|
||||||
$timestamp = 30 * round($timestamp / 30);
|
$timestamp = 30 * round($timestamp / 30);
|
||||||
|
|
||||||
return Carbon::createFromFormat('U', $timestamp)->toDateTimeString();
|
$date = Carbon::createFromFormat('U', $timestamp)->toDateTimeString();
|
||||||
|
|
||||||
|
$this->attributes['created_at'] = $date;
|
||||||
|
|
||||||
|
return $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,16 +19,6 @@ class MetricPointPresenter extends BasePresenter implements Arrayable
|
|||||||
{
|
{
|
||||||
use TimestampsTrait;
|
use TimestampsTrait;
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the actual calculated value; as per (value * counter).
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function calculated_value()
|
|
||||||
{
|
|
||||||
return $this->wrappedObject->value * $this->wrappedObject->counter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the presenter instance to an array.
|
* Convert the presenter instance to an array.
|
||||||
*
|
*
|
||||||
@@ -37,9 +27,8 @@ class MetricPointPresenter extends BasePresenter implements Arrayable
|
|||||||
public function toArray()
|
public function toArray()
|
||||||
{
|
{
|
||||||
return array_merge($this->wrappedObject->toArray(), [
|
return array_merge($this->wrappedObject->toArray(), [
|
||||||
'created_at' => $this->created_at(),
|
'created_at' => $this->created_at(),
|
||||||
'updated_at' => $this->updated_at(),
|
'updated_at' => $this->updated_at(),
|
||||||
'calculated_value' => $this->calculated_value(),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use McCool\LaravelAutoPresenter\BasePresenter;
|
|||||||
/**
|
/**
|
||||||
* This is the user presenter class.
|
* This is the user presenter class.
|
||||||
*
|
*
|
||||||
* @author James Brooks <james@bluebaytravel.co.uk>
|
* @author James Brooks <james@alt-three.com>
|
||||||
*/
|
*/
|
||||||
class UserPresenter extends BasePresenter implements Arrayable
|
class UserPresenter extends BasePresenter implements Arrayable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ class MetricRepository
|
|||||||
$pointKey = $dateTime->format('Y-m-d H:00');
|
$pointKey = $dateTime->format('Y-m-d H:00');
|
||||||
$points = $this->repository->getPointsSinceHour($metric, $hours)->pluck('value', 'key');
|
$points = $this->repository->getPointsSinceHour($metric, $hours)->pluck('value', 'key');
|
||||||
|
|
||||||
for ($i = 0; $i <= $hours; $i++) {
|
for ($i = 0; $i < $hours; $i++) {
|
||||||
if (!$points->has($pointKey)) {
|
if (!$points->has($pointKey)) {
|
||||||
$points->put($pointKey, $metric->default_value);
|
$points->put($pointKey, $metric->default_value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ namespace CachetHQ\Cachet\Repositories\Metric;
|
|||||||
|
|
||||||
use CachetHQ\Cachet\Models\Metric;
|
use CachetHQ\Cachet\Models\Metric;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Jenssegers\Date\Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the pgsql repository class.
|
* This is the pgsql repository class.
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ namespace CachetHQ\Cachet\Repositories\Metric;
|
|||||||
|
|
||||||
use CachetHQ\Cachet\Models\Metric;
|
use CachetHQ\Cachet\Models\Metric;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Jenssegers\Date\Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the sqlite repository class.
|
* This is the sqlite repository class.
|
||||||
|
|||||||
44
composer.lock
generated
44
composer.lock
generated
@@ -409,16 +409,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "aws/aws-sdk-php",
|
"name": "aws/aws-sdk-php",
|
||||||
"version": "3.62.5",
|
"version": "3.62.6",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/aws/aws-sdk-php.git",
|
"url": "https://github.com/aws/aws-sdk-php.git",
|
||||||
"reference": "75113b0ba22fffd968c45f06ba20fa94509dc973"
|
"reference": "0be301c36a5c337b40e69ce3b4698cca5427e4b9"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/75113b0ba22fffd968c45f06ba20fa94509dc973",
|
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/0be301c36a5c337b40e69ce3b4698cca5427e4b9",
|
||||||
"reference": "75113b0ba22fffd968c45f06ba20fa94509dc973",
|
"reference": "0be301c36a5c337b40e69ce3b4698cca5427e4b9",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -485,7 +485,7 @@
|
|||||||
"s3",
|
"s3",
|
||||||
"sdk"
|
"sdk"
|
||||||
],
|
],
|
||||||
"time": "2018-06-28T21:12:53+00:00"
|
"time": "2018-06-29T22:12:11+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "bacon/bacon-qr-code",
|
"name": "bacon/bacon-qr-code",
|
||||||
@@ -3919,16 +3919,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "swiftmailer/swiftmailer",
|
"name": "swiftmailer/swiftmailer",
|
||||||
"version": "v6.0.2",
|
"version": "v6.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/swiftmailer/swiftmailer.git",
|
"url": "https://github.com/swiftmailer/swiftmailer.git",
|
||||||
"reference": "412333372fb6c8ffb65496a2bbd7321af75733fc"
|
"reference": "0ff595e1d9d7d1c929b2a5f7b774bbcfbbd81587"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/412333372fb6c8ffb65496a2bbd7321af75733fc",
|
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/0ff595e1d9d7d1c929b2a5f7b774bbcfbbd81587",
|
||||||
"reference": "412333372fb6c8ffb65496a2bbd7321af75733fc",
|
"reference": "0ff595e1d9d7d1c929b2a5f7b774bbcfbbd81587",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -3939,10 +3939,14 @@
|
|||||||
"mockery/mockery": "~0.9.1",
|
"mockery/mockery": "~0.9.1",
|
||||||
"symfony/phpunit-bridge": "~3.3@dev"
|
"symfony/phpunit-bridge": "~3.3@dev"
|
||||||
},
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-intl": "Needed to support internationalized email addresses",
|
||||||
|
"true/punycode": "Needed to support internationalized email addresses, if ext-intl is not installed"
|
||||||
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "6.0-dev"
|
"dev-master": "6.1-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -3964,13 +3968,13 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Swiftmailer, free feature-rich PHP mailer",
|
"description": "Swiftmailer, free feature-rich PHP mailer",
|
||||||
"homepage": "http://swiftmailer.symfony.com",
|
"homepage": "https://swiftmailer.symfony.com",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"email",
|
"email",
|
||||||
"mail",
|
"mail",
|
||||||
"mailer"
|
"mailer"
|
||||||
],
|
],
|
||||||
"time": "2017-09-30T22:39:41+00:00"
|
"time": "2018-07-02T20:24:38+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/console",
|
"name": "symfony/console",
|
||||||
@@ -4955,28 +4959,28 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "vlucas/phpdotenv",
|
"name": "vlucas/phpdotenv",
|
||||||
"version": "v2.4.0",
|
"version": "v2.5.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/vlucas/phpdotenv.git",
|
"url": "https://github.com/vlucas/phpdotenv.git",
|
||||||
"reference": "3cc116adbe4b11be5ec557bf1d24dc5e3a21d18c"
|
"reference": "6ae3e2e6494bb5e58c2decadafc3de7f1453f70a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/3cc116adbe4b11be5ec557bf1d24dc5e3a21d18c",
|
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/6ae3e2e6494bb5e58c2decadafc3de7f1453f70a",
|
||||||
"reference": "3cc116adbe4b11be5ec557bf1d24dc5e3a21d18c",
|
"reference": "6ae3e2e6494bb5e58c2decadafc3de7f1453f70a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.9"
|
"php": ">=5.3.9"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^4.8 || ^5.0"
|
"phpunit/phpunit": "^4.8.35 || ^5.0"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.4-dev"
|
"dev-master": "2.5-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -4986,7 +4990,7 @@
|
|||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
"license": [
|
"license": [
|
||||||
"BSD-3-Clause-Attribution"
|
"BSD-3-Clause"
|
||||||
],
|
],
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@@ -5001,7 +5005,7 @@
|
|||||||
"env",
|
"env",
|
||||||
"environment"
|
"environment"
|
||||||
],
|
],
|
||||||
"time": "2016-09-01T10:05:43+00:00"
|
"time": "2018-07-01T10:25:50+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "zendframework/zend-diactoros",
|
"name": "zendframework/zend-diactoros",
|
||||||
|
|||||||
@@ -85,9 +85,11 @@ $factory->define(Metric::class, function ($faker) {
|
|||||||
|
|
||||||
$factory->define(MetricPoint::class, function ($faker) {
|
$factory->define(MetricPoint::class, function ($faker) {
|
||||||
return [
|
return [
|
||||||
'metric_id' => factory(Metric::class)->create()->id,
|
'metric_id' => factory(Metric::class)->create()->id,
|
||||||
'value' => mt_rand(1, 100),
|
'value' => mt_rand(1, 100),
|
||||||
'counter' => 1,
|
'counter' => 1,
|
||||||
|
'created_at' => Carbon::now(),
|
||||||
|
'updated_at' => Carbon::now(),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
19
docs/beacon.md
Normal file
19
docs/beacon.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# About Beacon and the information we collect
|
||||||
|
|
||||||
|
To help us understand how Cachet is used, we collect anonymous usage data.
|
||||||
|
|
||||||
|
If you'd prefer not to provide us with this anonymous usage data, please set `CACHET_BEACON` to `false` in your `.env` file.
|
||||||
|
|
||||||
|
## Data collected by Beacon
|
||||||
|
|
||||||
|
- `install_id` - a unique, anonymous installation ID
|
||||||
|
- `version` - the version of Cachet being used
|
||||||
|
- `docker` - whether Cachet is being ran from a Docker container
|
||||||
|
- `database` - the database driver being used
|
||||||
|
- `data.components` - the amount of configured Components
|
||||||
|
- `data.incidents` - the amount of reported Incidents
|
||||||
|
- `data.metrics` - the amount of configured Metrics
|
||||||
|
- `data.users` - the amount of users
|
||||||
|
- `data.actions` - the amount of actions performed
|
||||||
|
- `data.tags` - the amount of Tags created
|
||||||
|
- `data.schedules` - the amount of reported Schedules
|
||||||
6
public/dist/css/app.css
vendored
6
public/dist/css/app.css
vendored
File diff suppressed because one or more lines are too long
12
public/dist/css/dashboard/dashboard.css
vendored
12
public/dist/css/dashboard/dashboard.css
vendored
File diff suppressed because one or more lines are too long
2
resources/assets/sass/dashboard.scss
vendored
2
resources/assets/sass/dashboard.scss
vendored
@@ -14,6 +14,7 @@
|
|||||||
@import "dashboard/pages/dashboard";
|
@import "dashboard/pages/dashboard";
|
||||||
|
|
||||||
// Styles for plugins
|
// Styles for plugins
|
||||||
|
/*! purgecss start ignore */
|
||||||
@import "plugins/jquery.minicolors";
|
@import "plugins/jquery.minicolors";
|
||||||
@import "plugins/github-markdown";
|
@import "plugins/github-markdown";
|
||||||
@import "plugins/sweetalert";
|
@import "plugins/sweetalert";
|
||||||
@@ -21,3 +22,4 @@
|
|||||||
@import "plugins/animate";
|
@import "plugins/animate";
|
||||||
@import "plugins/password-strength";
|
@import "plugins/password-strength";
|
||||||
@import "plugins/sortable";
|
@import "plugins/sortable";
|
||||||
|
/*! purgecss end ignore */
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/*! purgecss start ignore */
|
||||||
@import "./node_modules/flatpickr/dist/flatpickr";
|
@import "./node_modules/flatpickr/dist/flatpickr";
|
||||||
|
|
||||||
.flatpickr-calendar {
|
.flatpickr-calendar {
|
||||||
@@ -59,3 +60,4 @@
|
|||||||
.flatpickr-time {
|
.flatpickr-time {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
/*! purgecss end ignore */
|
||||||
|
|||||||
@@ -39,6 +39,38 @@ class MetricPointTest extends AbstractApiTestCase
|
|||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_can_get_all_metric_points_in_order_by_latests()
|
||||||
|
{
|
||||||
|
$metric = factory(Metric::class)->create();
|
||||||
|
$metricPoint1 = factory(MetricPoint::class)->create([
|
||||||
|
'metric_id' => $metric->id,
|
||||||
|
'created_at' => Carbon::parse('2016-12-01 2:00pm'),
|
||||||
|
'updated_at' => Carbon::parse('2016-12-01 2:00pm'),
|
||||||
|
]);
|
||||||
|
$metricPoint2 = factory(MetricPoint::class)->create([
|
||||||
|
'metric_id' => $metric->id,
|
||||||
|
'created_at' => Carbon::parse('2016-12-01 1:00pm'),
|
||||||
|
'updated_at' => Carbon::parse('2016-12-01 1:00pm'),
|
||||||
|
]);
|
||||||
|
$metricPoint3 = factory(MetricPoint::class)->create([
|
||||||
|
'metric_id' => $metric->id,
|
||||||
|
'created_at' => Carbon::parse('2016-12-01 4:00pm'),
|
||||||
|
'updated_at' => Carbon::parse('2016-12-01 4:00pm'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = $this->json('GET', "/api/v1/metrics/{$metric->id}/points");
|
||||||
|
|
||||||
|
$response->assertJson([
|
||||||
|
'data' => [
|
||||||
|
['id' => $metricPoint3->id],
|
||||||
|
['id' => $metricPoint1->id],
|
||||||
|
['id' => $metricPoint2->id],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_cannot_create_metric_point_without_authorization()
|
public function test_cannot_create_metric_point_without_authorization()
|
||||||
{
|
{
|
||||||
$metric = factory(Metric::class)->create();
|
$metric = factory(Metric::class)->create();
|
||||||
|
|||||||
Reference in New Issue
Block a user