Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

abezine
Copy link

@abezine abezine commented Nov 14, 2024

No description provided.

@mzur
Copy link
Member

mzur commented Nov 27, 2024

Resolves #35

@mzur mzur linked an issue Nov 27, 2024 that may be closed by this pull request
@mzur mzur changed the title Don't allow review of storage requests Don't allow review of storage requests that were not submitted Nov 27, 2024
Copy link
Member

@mzur mzur left a 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);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines +55 to +92
{
$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);
}
Copy link
Member

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.

Comment on lines +69 to +71
$this->actingAs($user)
->get("storage-requests/{$id}/review")
->assertStatus(403);
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't allow review of storage requests that were not submitted
2 participants