From 147710ed6d45377c5bb27d882441289b4d384621 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Mon, 1 Jul 2024 12:18:31 +0100 Subject: [PATCH] Network Coordinator shouldn't see approval option for groups which are not in their network. --- app/Http/Controllers/GroupController.php | 4 +++- resources/views/group/edit.blade.php | 2 +- tests/Feature/Groups/GroupEditTest.php | 30 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/GroupController.php b/app/Http/Controllers/GroupController.php index 6677de97f5..8021f3a22e 100644 --- a/app/Http/Controllers/GroupController.php +++ b/app/Http/Controllers/GroupController.php @@ -503,7 +503,9 @@ public function edit(Request $request, $id, Geocoder $geocoder) 'id' => $id, 'name' => $group->name, 'audits' => $group->audits, - 'networks' => Network::all() + 'networks' => Network::all(), + 'can_approve' => Fixometer::hasRole($user, 'Administrator') || + Fixometer::hasRole($user, 'NetworkCoordinator') && $isCoordinatorForGroup ]); } diff --git a/resources/views/group/edit.blade.php b/resources/views/group/edit.blade.php index c660922bf2..ce7f2fca51 100644 --- a/resources/views/group/edit.blade.php +++ b/resources/views/group/edit.blade.php @@ -19,7 +19,7 @@
diff --git a/tests/Feature/Groups/GroupEditTest.php b/tests/Feature/Groups/GroupEditTest.php index 86df3762f4..c29ec12540 100644 --- a/tests/Feature/Groups/GroupEditTest.php +++ b/tests/Feature/Groups/GroupEditTest.php @@ -4,6 +4,7 @@ use App\Group; use App\GroupTags; +use App\Network; use App\Role; use App\User; use Carbon\Carbon; @@ -189,4 +190,33 @@ public function edit_email() $group->refresh(); $this->assertEquals('info@test.com', $group->email); } + + public function testEditAsNetworkCoordinator() { + $network = Network::factory()->create(); + $coordinator = User::factory()->restarter()->create(); + $network->addCoordinator($coordinator); + $coordinator->refresh(); + $this->actingAs($coordinator); + + $idgroups = $this->createGroup( + 'Test Group', + 'https://therestartproject.org', + 'London', + 'Some text.', + true, + false, + 'info@test.com' + ); + + $response = $this->get('/group/edit/' . $idgroups); + $response->assertStatus(200); + + // Shouldn't be able to approve the group, as it has not yet been put in our network (by an admin). + $this->assertVueProperties($response, [ + [], + [ + ':can-approve' => 'false', + ], + ]); + } }