Don't allow cancels from certain states (#396)

* Don't allow cancels from certain states

* Unused imports

* Don't reset the state doubly

* Move SetUserActive into listener; code cleanup

* Unused imports

* Add missing files into htaccess

* Move Command contract to correct folder
This commit is contained in:
Nabeel S
2019-09-16 13:08:26 -04:00
committed by GitHub
parent 41baefbf4a
commit aedb1f22b6
61 changed files with 231 additions and 138 deletions

View File

@@ -2,6 +2,7 @@
use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use App\Models\PirepFare;
use App\Repositories\SettingRepository;
/**
@@ -217,7 +218,7 @@ class AcarsTest extends TestCase
$pirep = $response->json('data');
// See that the fields and fares were set
$fares = \App\Models\PirepFare::where('pirep_id', $pirep['id'])->get();
$fares = PirepFare::where('pirep_id', $pirep['id'])->get();
$this->assertCount(1, $fares);
$saved_fare = $fares->first();
@@ -246,16 +247,30 @@ class AcarsTest extends TestCase
];
$response = $this->post($uri, $update);
$response->assertStatus(200);
$updated_pirep = $response->json('data');
$response->assertOk();
// Make sure there are no duplicates
$fares = \App\Models\PirepFare::where('pirep_id', $pirep['id'])->get();
$fares = PirepFare::where('pirep_id', $pirep['id'])->get();
$this->assertCount(1, $fares);
$saved_fare = $fares->first();
$this->assertEquals($fare->id, $saved_fare['fare_id']);
$this->assertEquals($fare->capacity, $saved_fare['count']);
/*
* Try cancelling the PIREP now
*/
$uri = '/api/pireps/'.$pirep['id'].'/cancel';
$response = $this->put($uri, []);
$response->assertOk();
// Read it
$uri = '/api/pireps/'.$pirep['id'];
$response = $this->get($uri);
$response->assertOk();
$body = $response->json('data');
$this->assertEquals($body['state'], PirepState::CANCELLED);
}
/**
@@ -460,11 +475,6 @@ class AcarsTest extends TestCase
$body = $this->get('/api/pireps/'.$pirep_id)->json('data');
$this->assertNotNull($body['block_off_time']);
$this->assertNotNull($body['block_on_time']);
// make sure the time matches up
/*$block_on = new Carbon($body['block_on_time'], 'UTC');
$block_off = new Carbon($body['block_off_time'], 'UTC');
$this->assertEquals($block_on->subMinutes($body['flight_time']), $block_off);*/
}
/**