Skip to content

Commit

Permalink
Add testing of removing volunteers
Browse files Browse the repository at this point in the history
  • Loading branch information
edwh committed Jul 28, 2021
1 parent 7f8fb34 commit d088eff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/Helpers/Fixometer.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public static function userIsHostOfGroup($groupId, $userId)
->where('group', $groupId)
->where('user', $userId)
->where('role', 3)
->whereNull('deleted_at')
->first();

if ( ! empty($user_group_association)) {
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Controllers/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,6 @@ public function getRemoveVolunteer($group_id, $user_id, Request $request)
return redirect()->back()->with('warning', 'Sorry, you do not have permission to do this');
}

// TODO: is this alive?
// It's still in the action menu, but I don't believe it has been updated recently.
public function volunteersNearby($groupid)
{
if (isset($_GET['action']) && isset($_GET['code'])) {
Expand Down
16 changes: 16 additions & 0 deletions tests/Feature/Groups/GroupHostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ public function testHostMakeHost() {

$response = $this->get("/group/make-host/{$this->idgroups}/{$host->id}");
$response->assertSessionHas('success');

// Remove them.
$response = $this->get("/group/remove-volunteer/{$this->idgroups}/{$host->id}");
$response->assertSessionHas('success');

// Remove them again - should redirect back with warning.
$response = $this->from('/')->get("/group/remove-volunteer/{$this->idgroups}/{$host->id}");
$response->assertRedirect('/');
$response->assertSessionHas('warning');

// Removed host tries and fails to remove the first host.
$response = $this->get('/logout');
$this->actingAs($host);
$response = $this->from('/')->get("/group/remove-volunteer/{$this->idgroups}/{$firsthost->id}");
$response->assertRedirect('/');
$response->assertSessionHas('warning');
}

public function testIrrelevantHost() {
Expand Down

0 comments on commit d088eff

Please sign in to comment.