diff --git a/backend/database/migrations/2024_07_08_183816_create_permissions.php b/backend/database/migrations/2024_07_08_183816_create_permissions.php new file mode 100644 index 000000000..effba90d6 --- /dev/null +++ b/backend/database/migrations/2024_07_08_183816_create_permissions.php @@ -0,0 +1,70 @@ + $role) { + Role::factory()->create([ + 'id' => $key + 1, + 'name' => $role, + ]); + } + + Permission::create(['name' => Permission::UPDATE_USERS]) + ->assignRole(Role::APPLICATION_ADMINISTRATOR); + Permission::create(['name' => Permission::UPDATE_USERS_IN_OWN_PUBLICATION]) + ->assignRole(Role::PUBLICATION_ADMINISTRATOR); + Permission::create(['name' => Permission::CREATE_PUBLICATION]) + ->assignRole(Role::APPLICATION_ADMINISTRATOR); + Permission::create(['name' => Permission::VIEW_ALL_PUBLICATIONS]) + ->assignRole(Role::APPLICATION_ADMINISTRATOR); + + Permission::create(['name' => Permission::ASSIGN_REVIEWER]) + ->assignRole(Role::APPLICATION_ADMINISTRATOR) + ->assignRole(Role::PUBLICATION_ADMINISTRATOR) + ->assignRole(Role::EDITOR); + + Permission::create(['name' => Permission::UNASSIGN_REVIEWER]) + ->assignRole(Role::APPLICATION_ADMINISTRATOR) + ->assignRole(Role::PUBLICATION_ADMINISTRATOR) + ->assignRole(Role::EDITOR); + + Permission::create(['name' => Permission::ASSIGN_REVIEW_COORDINATOR]) + ->assignRole(Role::APPLICATION_ADMINISTRATOR) + ->assignRole(Role::PUBLICATION_ADMINISTRATOR) + ->assignRole(Role::EDITOR); + + Permission::create(['name' => Permission::UNASSIGN_REVIEW_COORDINATOR]) + ->assignRole(Role::APPLICATION_ADMINISTRATOR) + ->assignRole(Role::PUBLICATION_ADMINISTRATOR) + ->assignRole(Role::EDITOR); + + Permission::create(['name' => Permission::ASSIGN_EDITOR]) + ->assignRole(Role::APPLICATION_ADMINISTRATOR) + ->assignRole(Role::PUBLICATION_ADMINISTRATOR); + + Permission::create(['name' => Permission::UNASSIGN_EDITOR]) + ->assignRole(Role::APPLICATION_ADMINISTRATOR) + ->assignRole(Role::PUBLICATION_ADMINISTRATOR); + + Permission::create(['name' => Permission::UPDATE_SITE_SETTINGS]) + ->assignRole(Role::APPLICATION_ADMINISTRATOR); + } + + + /** + * Reverse the migrations. + */ + public function down(): void + { + } +}; diff --git a/backend/database/seeders/DatabaseSeeder.php b/backend/database/seeders/DatabaseSeeder.php index f73a9b818..1e81753d2 100644 --- a/backend/database/seeders/DatabaseSeeder.php +++ b/backend/database/seeders/DatabaseSeeder.php @@ -15,7 +15,6 @@ class DatabaseSeeder extends Seeder public function run() { $this->call([ - RoleSeeder::class, UserSeeder::class, PublicationSeeder::class, StyleCriteriasSeeder::class, diff --git a/backend/database/seeders/RoleSeeder.php b/backend/database/seeders/RoleSeeder.php index e6653e103..95dc0f4af 100644 --- a/backend/database/seeders/RoleSeeder.php +++ b/backend/database/seeders/RoleSeeder.php @@ -10,18 +10,19 @@ class RoleSeeder extends Seeder { /** - * Run the database seeds. + * Run the role seeder. * + * @deprecated Permission seeding is done via migration. This seeder is only useful for development (maybe). * @return void */ public function run() { $roles = Role::getArrayOfAllRoleNames(); foreach ($roles as $key => $role) { - Role::factory()->create([ - 'id' => $key + 1, - 'name' => $role, - ]); + Role::factory()->create([ + 'id' => $key + 1, + 'name' => $role, + ]); } Permission::create(['name' => Permission::UPDATE_USERS]) diff --git a/backend/tests/ApiTestCase.php b/backend/tests/ApiTestCase.php index 7d80a2b4a..9970a697b 100644 --- a/backend/tests/ApiTestCase.php +++ b/backend/tests/ApiTestCase.php @@ -8,7 +8,4 @@ abstract class ApiTestCase extends TestCase { use MakesGraphQLRequests; - - public $seed = true; - public $seeder = 'RoleSeeder'; } diff --git a/backend/tests/TestCase.php b/backend/tests/TestCase.php index d0604834b..29a7fe493 100644 --- a/backend/tests/TestCase.php +++ b/backend/tests/TestCase.php @@ -13,9 +13,6 @@ abstract class TestCase extends BaseTestCase { use CreatesApplication; - public $seed = true; - public $seeder = 'RoleSeeder'; - /** * Act as a new user with application administrator role *