Filters for JSON files, closes #8

This commit is contained in:
distinctm
2019-06-12 17:52:32 -04:00
parent 58f1062aeb
commit e7608ca9d6
3 changed files with 24 additions and 3 deletions

View File

@@ -106,9 +106,12 @@ class Updater
return Collection::wrap($directory . '/' . $model . '.json');
}
return collect(File::files($directory))->map(function ($path) {
return $path->getPathname();
});
return collect(File::files($directory))
->filter(function($file) {
return pathinfo($file, PATHINFO_EXTENSION) == 'json';
})->map(function ($path) {
return $path->getPathname();
});
}
/**

View File

@@ -131,4 +131,13 @@ class UpdaterTest extends TestCase
$updater = new UpdaterFake(__DIR__ . '/../test-data/ordered');
$updater->run();
}
/** @test */
public function it_ignores_non_json_files()
{
$updater = new UpdaterFake(__DIR__ . '/../test-data/not-json');
$updater->run();
$this->assertDatabaseMissing('roles', ['slug' => 'update-student-records']);
}
}

View File

@@ -0,0 +1,9 @@
[
{
"_slug": "update-student-records",
"category": "testing",
"supervisor": {
"name": "CEO"
}
}
]