Skip to content

Commit

Permalink
Merge pull request #735 from TheRestartProject/RES-1984_network_coord…
Browse files Browse the repository at this point in the history
…inators_group_approval

RES-1984 Network Coordinator shouldn't see approval option
  • Loading branch information
edwh authored Jul 11, 2024
2 parents 7f3f82e + 147710e commit 25d8a25
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('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',
],
]);
}
}

0 comments on commit 25d8a25

Please sign in to comment.