feat: revenue cat
This commit is contained in:
@@ -5,9 +5,11 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
it('grants analysis access during the generic trial', function () {
|
||||
it('grants analysis access during a RevenueCat subscription trial', function () {
|
||||
$user = User::factory()->create([
|
||||
'trial_ends_at' => now()->addDay(),
|
||||
'subscription_expires_at' => now()->addDay(),
|
||||
'subscription_is_trial' => true,
|
||||
'subscription_product_id' => 'monthly',
|
||||
]);
|
||||
|
||||
expect($user->canAnalyzeMeals())->toBeTrue()
|
||||
@@ -16,23 +18,20 @@ it('grants analysis access during the generic trial', function () {
|
||||
|
||||
it('grants analysis access to active subscribers', function () {
|
||||
$user = User::factory()->create([
|
||||
'trial_ends_at' => now()->subDay(),
|
||||
]);
|
||||
|
||||
$user->subscriptions()->create([
|
||||
'type' => 'default',
|
||||
'stripe_id' => 'sub_active',
|
||||
'stripe_status' => 'active',
|
||||
'stripe_price' => 'price_subscription',
|
||||
'subscription_expires_at' => now()->addYear(),
|
||||
'subscription_is_trial' => false,
|
||||
'subscription_product_id' => 'yearly',
|
||||
]);
|
||||
|
||||
expect($user->canAnalyzeMeals())->toBeTrue()
|
||||
->and($user->analysisAccessLevel())->toBe('subscribed');
|
||||
});
|
||||
|
||||
it('keeps publishing accounts free without analysis access after the trial', function () {
|
||||
it('keeps publishing accounts free without a subscription', function () {
|
||||
$user = User::factory()->create([
|
||||
'trial_ends_at' => now()->subDay(),
|
||||
'subscription_expires_at' => now()->subDay(),
|
||||
'subscription_is_trial' => true,
|
||||
'subscription_product_id' => 'monthly',
|
||||
]);
|
||||
|
||||
expect($user->canAnalyzeMeals())->toBeFalse()
|
||||
|
||||
Reference in New Issue
Block a user