Make sure the rank restriction disabled works closes #170

This commit is contained in:
Nabeel Shahzad 2018-02-20 13:28:53 -06:00
parent 4e43223f3a
commit 463de8d7e7
2 changed files with 45 additions and 1 deletions

View File

@ -2,17 +2,21 @@
use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use Tests\TestData;
use App\Repositories\SettingRepository;
/**
* Test API calls and authentication, etc
*/
class AcarsTest extends TestCase
{
protected $settingsRepo;
public function setUp()
{
parent::setUp();
$this->addData('base');
$this->settingsRepo = app(SettingRepository::class);
}
/**
@ -267,6 +271,45 @@ class AcarsTest extends TestCase
$response->assertStatus(201);
}
/**
* Test aircraft permissions being ignored
*/
public function testIgnoreAircraftAllowed()
{
$this->settingsRepo->store('pireps.restrict_aircraft_to_rank', false);
$airport = factory(App\Models\Airport::class)->create();
$airline = factory(App\Models\Airline::class)->create();
# Add subfleets and aircraft, but also add another set of subfleets
$subfleetA = $this->createSubfleetWithAircraft(1);
// User not allowed aircraft from this subfleet
$subfleetB = $this->createSubfleetWithAircraft(1);
$rank = $this->createRank(10, [$subfleetA['subfleet']->id]);
$this->user = factory(App\Models\User::class)->create([
'rank_id' => $rank->id,
]);
$uri = '/api/pireps/prefile';
$pirep = [
'airline_id' => $airline->id,
'aircraft_id' => $subfleetB['aircraft']->random()->id,
'dpt_airport_id' => $airport->icao,
'arr_airport_id' => $airport->icao,
'flight_number' => '6000',
'level' => 38000,
'planned_flight_time' => 120,
'route' => 'POINTA POINTB',
'source_name' => 'Unit test'
];
$response = $this->post($uri, $pirep);
$response->assertStatus(201);
}
/**
* Test publishing multiple, batched updates
*/

View File

@ -7,6 +7,7 @@ use App\Models\Enums\AcarsType;
use App\Models\Pirep;
use App\Models\User;
use App\Models\Enums\PirepState;
use App\Repositories\SettingRepository;
class PIREPTest extends TestCase
{