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:
Daniel Meltzer 2018-03-27 20:43:28 -04:00 committed by snipe
parent e9d9c0c42d
commit 69478aea58
6 changed files with 8 additions and 1491 deletions

View file

@ -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
];
});

View file

@ -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);

File diff suppressed because one or more lines are too long

View file

@ -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'

View file

@ -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

View file

@ -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: