Skip to content

Commit

Permalink
Apply suggestions from review
Browse files Browse the repository at this point in the history
  • Loading branch information
lehecht committed Jan 9, 2025
1 parent f3a5325 commit 8893578
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
25 changes: 11 additions & 14 deletions src/Http/Controllers/Views/StorageRequestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,16 @@ public function create(Request $request)
*
* @return \Illuminate\Http\Response
*/
public function review($id)
{
$request = StorageRequest::whereNull('expires_at')
->whereNotNull('submitted_at')
->with('files')
->findOrFail($id);
$this->authorize('approve', $request);

public function review($id)
{
$request = StorageRequest::whereNull('expires_at')
->whereNotNull('submitted_at')
->with('files')
->findOrFail($id);

$this->authorize('approve', $request);

return view('user-storage::review', [
'request' => $request,
]);
}

return view('user-storage::review', [
'request' => $request,
]);
}
}
26 changes: 15 additions & 11 deletions tests/Http/Controllers/Views/StorageRequestControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,45 +50,49 @@ public function testIndex()
->get('storage-requests')
->assertViewIs('user-storage::index');
}

public function testReview()
{
$request = StorageRequest::factory()->create(['submitted_at' => now()]);
$id = $request->id;

$this->get("storage-requests/{$id}/review")->assertRedirect('login');

$this->actingAs($request->user)
->get("storage-requests/{$id}/review")
->assertStatus(403);

$user = UserTest::create([
'role_id' => Role::editorId(),
]);

$this->actingAs($user)
->get("storage-requests/{$id}/review")
->assertStatus(403);

$user->role_id = Role::adminId();
$user->save();

$this->actingAs($user)
->get("storage-requests/{$id}/review")
->assertViewIs('user-storage::review');

$request->update(['expires_at' => now()]);
$this->actingAs($user)
->get("storage-requests/{$id}/review")
->assertStatus(404);

}

public function testReviewUnsubmittedRequest(){
$user = UserTest::create([
'role_id' => Role::editorId(),
]);
$unsubmittedRequest = StorageRequest::factory()->create([
'submitted_at' => null,
]);

$this->actingAs($user)
->get("storage-requests/{$unsubmittedRequest->id}/review")
->assertStatus(404);
}


}

0 comments on commit 8893578

Please sign in to comment.