mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 01:24:36 -04:00
Accept migration over the API (#3356)
This commit is contained in:
parent
6ca0841626
commit
cf3bcb90be
@ -190,7 +190,11 @@ class MigrationController extends BaseController
|
|||||||
'migrations', $request->file('migration')->getClientOriginalName()
|
'migrations', $request->file('migration')->getClientOriginalName()
|
||||||
);
|
);
|
||||||
|
|
||||||
// config('ninja.environment') - Returns 'selfhosted' instead of 'testing' while running with PhpUnit, which makes it run the migration file.
|
if(!auth()->user()->company)
|
||||||
|
return response()->json(['message' => 'Company doesn\'t exists.'], 402);
|
||||||
|
|
||||||
|
if($request->has('force'))
|
||||||
|
$this->purgeCompany(auth()->user()->company);
|
||||||
|
|
||||||
if(app()->environment() !== 'testing') {
|
if(app()->environment() !== 'testing') {
|
||||||
StartMigration::dispatchNow($file, auth()->user(), auth()->user()->company);
|
StartMigration::dispatchNow($file, auth()->user(), auth()->user()->company);
|
||||||
|
@ -23,8 +23,15 @@ class UploadMigrationFileRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
$rules = [
|
||||||
'migration' => [], // TODO: Write mimes check for zip file.
|
'migration' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/** We'll skip mime validation while running tests. */
|
||||||
|
if(app()->environment() !== 'testing') {
|
||||||
|
$rules['migration'] = ['required', 'mimes:zip'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rules;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,25 +95,25 @@ class MigrationTest extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function testMigrationFileUpload()
|
public function testMigrationFileUpload()
|
||||||
// {
|
{
|
||||||
// $file = new UploadedFile(base_path('tests/Unit/Migration/migration.zip'), 'migration.zip');
|
$file = new UploadedFile(base_path('tests/Unit/Migration/migration.zip'), 'migration.zip');
|
||||||
|
|
||||||
// $data = [
|
$data = [
|
||||||
// 'migration' => $file,
|
'migration' => $file,
|
||||||
// ];
|
'force' => true,
|
||||||
|
];
|
||||||
|
|
||||||
// $token = $this->company->tokens->first()->token;
|
$token = $this->company->tokens->first()->token;
|
||||||
|
|
||||||
// $response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
// 'X-API-TOKEN' => $token,
|
'X-API-TOKEN' => $token,
|
||||||
// 'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
// 'X-Requested-With' => 'XMLHttpRequest',
|
'X-Requested-With' => 'XMLHttpRequest',
|
||||||
// 'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||||
// ])->post('/api/v1/migration/start', $data);
|
])->post('/api/v1/migration/start', $data);
|
||||||
|
|
||||||
// $response->assertStatus(200);
|
|
||||||
// $this->assertTrue(file_exists(base_path('storage/migrations/migration/migration.json')));
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$this->assertTrue(file_exists(base_path('storage/migrations/migration/migration.json')));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user