Skip to content

Commit

Permalink
Network Coordinator shouldn't see approval option for groups which ar…
Browse files Browse the repository at this point in the history
…e not in their network.
  • Loading branch information
edwh committed Jul 1, 2024
1 parent 78d78bf commit 147710e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/Http/Controllers/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
]);
}

Expand Down
2 changes: 1 addition & 1 deletion resources/views/group/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="tab-pane active" id="details">
<div class="vue">
<GroupAddEditPage :idgroups="{{ $id }}"
:can-approve="{{ (Auth::user()->hasRole('Administrator') || Auth::user()->hasRole('NetworkCoordinator')) ? "true" : "false" }}"
:can-approve="{{ $can_approve ? "true": "false" }}"
:can-network="{{ Auth::user()->hasRole('Administrator') ? "true" : "false" }}"
/>
</div>
Expand Down
30 changes: 30 additions & 0 deletions tests/Feature/Groups/GroupEditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Group;
use App\GroupTags;
use App\Network;
use App\Role;
use App\User;
use Carbon\Carbon;
Expand Down Expand Up @@ -189,4 +190,33 @@ public function edit_email()
$group->refresh();
$this->assertEquals('[email protected]', $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,
'[email protected]'
);

$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',
],
]);
}
}

0 comments on commit 147710e

Please sign in to comment.