-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't allow review of storage requests that were not submitted #51
base: master
Are you sure you want to change the base?
Conversation
Resolves #35 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated this branch, as it was quite out of date.
Please use the "request review" feature to request a review from me when you have something ready.
->with('files') | ||
->findOrFail($id); | ||
$this->authorize('approve', $request); | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
$request = StorageRequest::factory()->create(); | ||
$id = $request->id; | ||
|
||
$this->get("storage-requests/{$id}/review")->assertRedirect('login'); | ||
$this->get("storage-requests/{$id}/review")->assertRedirect('login'); | ||
|
||
$this->actingAs($request->user) | ||
->get("storage-requests/{$id}/review") | ||
->assertStatus(403); | ||
$this->actingAs($request->user) | ||
->get("storage-requests/{$id}/review") | ||
->assertStatus(403); | ||
|
||
$user = UserTest::create([ | ||
'role_id' => Role::editorId(), | ||
]); | ||
$user = UserTest::create([ | ||
'role_id' => Role::editorId(), | ||
]); | ||
|
||
$this->actingAs($user) | ||
->get("storage-requests/{$id}/review") | ||
->assertStatus(403); | ||
$this->actingAs($user) | ||
->get("storage-requests/{$id}/review") | ||
->assertStatus(403); | ||
|
||
$user->role_id = Role::adminId(); | ||
$user->save(); | ||
$user->role_id = Role::adminId(); | ||
$user->save(); | ||
|
||
$this->actingAs($user) | ||
->get("storage-requests/{$id}/review") | ||
->assertViewIs('user-storage::review'); | ||
// Test for unsubmitted request | ||
$this->actingAs($user) | ||
->get("storage-requests/{$id}/review") | ||
->assertStatus(404); | ||
|
||
$request->update(['expires_at' => '2022-03-28 10:40:00']); | ||
$this->actingAs($user) | ||
->get("storage-requests/{$id}/review") | ||
->assertStatus(404); | ||
} | ||
// Mark the request as submitted | ||
$request->update(['submitted_at' => now()]); | ||
|
||
$this->actingAs($user) | ||
->get("storage-requests/{$id}/review") | ||
->assertViewIs('user-storage::review'); | ||
|
||
$request->update(['expires_at' => '2022-03-28 10:40:00']); | ||
$this->actingAs($user) | ||
->get("storage-requests/{$id}/review") | ||
->assertStatus(404); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the indentation here.
$this->actingAs($user) | ||
->get("storage-requests/{$id}/review") | ||
->assertStatus(403); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails with Expected response status code [403] but received 404.
No description provided.