Add pirep fields to the API response; add tests for setting/getting them
This commit is contained in:
@@ -28,6 +28,8 @@ class Pirep extends Resource
|
|||||||
'curr_airport_id' => $this->user->curr_airport_id,
|
'curr_airport_id' => $this->user->curr_airport_id,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$pirep['fields'] = $this->fields;
|
||||||
|
|
||||||
return $pirep;
|
return $pirep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ Route::group([], function()
|
|||||||
Route::group(['middleware' => ['api.auth']], function ()
|
Route::group(['middleware' => ['api.auth']], function ()
|
||||||
{
|
{
|
||||||
Route::post('pireps/prefile', 'PirepController@prefile');
|
Route::post('pireps/prefile', 'PirepController@prefile');
|
||||||
|
|
||||||
|
Route::put('pireps/{pirep_id}', 'PirepController@update');
|
||||||
Route::post('pireps/{pirep_id}/update', 'PirepController@update');
|
Route::post('pireps/{pirep_id}/update', 'PirepController@update');
|
||||||
|
|
||||||
Route::post('pireps/{pirep_id}/file', 'PirepController@file');
|
Route::post('pireps/{pirep_id}/file', 'PirepController@file');
|
||||||
Route::post('pireps/{pirep_id}/comments', 'PirepController@comments_post');
|
Route::post('pireps/{pirep_id}/comments', 'PirepController@comments_post');
|
||||||
Route::delete('pireps/{pirep_id}/cancel', 'PirepController@cancel');
|
Route::delete('pireps/{pirep_id}/cancel', 'PirepController@cancel');
|
||||||
|
|||||||
@@ -106,6 +106,9 @@ class AcarsTest extends TestCase
|
|||||||
'planned_flight_time' => 120,
|
'planned_flight_time' => 120,
|
||||||
'route' => 'POINTA POINTB',
|
'route' => 'POINTA POINTB',
|
||||||
'source_name' => 'UnitTest',
|
'source_name' => 'UnitTest',
|
||||||
|
'fields' => [
|
||||||
|
'custom_field' => 'custom_value',
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->post($uri, $pirep);
|
$response = $this->post($uri, $pirep);
|
||||||
@@ -124,6 +127,28 @@ class AcarsTest extends TestCase
|
|||||||
$this->assertEquals(PirepState::IN_PROGRESS, $pirep['state']);
|
$this->assertEquals(PirepState::IN_PROGRESS, $pirep['state']);
|
||||||
$this->assertEquals(PirepStatus::PREFILE, $pirep['status']);
|
$this->assertEquals(PirepStatus::PREFILE, $pirep['status']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the fields
|
||||||
|
*/
|
||||||
|
$this->assertHasKeys($pirep, ['fields']);
|
||||||
|
$this->assertEquals('custom_field', $pirep['fields'][0]['name']);
|
||||||
|
$this->assertEquals('custom_value', $pirep['fields'][0]['value']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the custom field
|
||||||
|
*/
|
||||||
|
$uri = '/api/pireps/' . $pirep_id . '/update';
|
||||||
|
$this->post($uri, ['fields' => [
|
||||||
|
'custom_field' => 'custom_value_changed',
|
||||||
|
]]);
|
||||||
|
|
||||||
|
$pirep = $this->getPirep($pirep_id);
|
||||||
|
$this->assertEquals('custom_value_changed', $pirep['fields'][0]['value']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add some position updates
|
||||||
|
*/
|
||||||
|
|
||||||
$uri = '/api/pireps/' . $pirep_id . '/acars/position';
|
$uri = '/api/pireps/' . $pirep_id . '/acars/position';
|
||||||
|
|
||||||
# Test missing positions field
|
# Test missing positions field
|
||||||
|
|||||||
Reference in New Issue
Block a user