mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Avoid populating db manually. (#5255)
* Avoid populating db manually. Instead rely on a seeded database existing and use api/fucntional tests based on that. * Seed the Setting object with default values. * Update Setting seeder to match web default. Also only generate one Setting instance.
This commit is contained in:
parent
4c43226b99
commit
bf2d6dd0fa
|
@ -86,10 +86,10 @@ $factory->define(App\Models\Setting::class, function ($faker) {
|
|||
'site_name' => $faker->sentence,
|
||||
'auto_increment_assets' => false,
|
||||
'alert_email' => $faker->safeEmail(),
|
||||
'alerts_enabled' => false,
|
||||
'alerts_enabled' => true,
|
||||
'brand' => 1,
|
||||
'default_currency' => $faker->currencyCode,
|
||||
'locale' => $faker->locale,
|
||||
'pwd_secure_min' => 5,
|
||||
'pwd_secure_min' => 10, // Match web setup
|
||||
];
|
||||
});
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
|
@ -33,6 +34,10 @@ class DatabaseSeeder extends Seeder
|
|||
$this->call(ActionlogSeeder::class);
|
||||
$this->call(CustomFieldSeeder::class);
|
||||
|
||||
// Only create default settings if they do not exist in the db.
|
||||
if(!Setting::first()) {
|
||||
factory(Setting::class)->create();
|
||||
}
|
||||
Artisan::call('snipeit:sync-asset-locations', ['--output' => 'all']);
|
||||
$output = Artisan::output();
|
||||
\Log::info($output);
|
||||
|
|
1472
tests/_data/dump.sql
1472
tests/_data/dump.sql
File diff suppressed because one or more lines are too long
|
@ -9,4 +9,3 @@ modules:
|
|||
dsn: 'mysql:host=localhost;dbname=snipeit_unit'
|
||||
user: 'travis'
|
||||
password: ''
|
||||
populator: 'mysql -u travis snipeit_unit < tests/_data/dump.sql'
|
||||
|
|
|
@ -7,13 +7,6 @@ modules:
|
|||
depends: Laravel5
|
||||
timeout: 10
|
||||
- Asserts
|
||||
- Db:
|
||||
dsn: 'mysql:host=localhost;dbname=snipeittests'
|
||||
user: 'snipeit_laravel'
|
||||
password: ''
|
||||
dump: tests/_data/dump.sql
|
||||
populate: true
|
||||
cleanup: false
|
||||
config:
|
||||
- Laravel5:
|
||||
environment_file: .env.tests
|
||||
|
|
|
@ -12,14 +12,6 @@ modules:
|
|||
- Laravel5:
|
||||
environment_file: .env.tests
|
||||
cleanup: true
|
||||
- Db:
|
||||
dsn: 'mysql:host=localhost;dbname=snipeittests'
|
||||
user: 'snipeit_laravel'
|
||||
password: ''
|
||||
dump: tests/_data/dump.sql
|
||||
populate: true
|
||||
populator: 'mysql -u snipeit_laravel snipeittests < tests/_data/dump.sql'
|
||||
cleanup: false
|
||||
- REST:
|
||||
depends: Laravel5
|
||||
groups:
|
||||
|
|
Loading…
Reference in a new issue