feat: disable custom script for trial users (#371)

* feat: disable custom script for  trial users

* fix: logic error for trial users

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Favour Olayinka
2024-04-15 15:14:21 +01:00
committed by GitHub
parent 75c2107b6c
commit 8d35fc8b1a
6 changed files with 111 additions and 2 deletions

View File

@@ -179,6 +179,21 @@ trait TestHelpers
return $user;
}
public function createTrialingUser()
{
$user = $this->createUser();
$user->subscriptions()->create([
'name' => 'default',
'stripe_id' => Str::random(),
'stripe_status' => 'trialing',
'stripe_price' => Str::random(),
'trial_ends_at' => now()->addDays(5),
'quantity' => 1,
]);
return $user;
}
public function actingAsUser(?User $user = null)
{
if ($user == null) {
@@ -207,6 +222,15 @@ trait TestHelpers
return $this->actingAsUser($user);
}
public function actingAsTrialingUser(User $user = null)
{
if ($user == null) {
$user = $this->createTrialingUser();
}
return $this->actingAsUser($user);
}
public function actingAsGuest()
{
if (Auth::check()) {