1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Testing Permissions

This commit is contained in:
David Bomba 2021-04-06 14:02:27 +10:00
parent 6d1d950c4e
commit 355d0ae7b5
2 changed files with 16 additions and 2 deletions

View File

@ -239,12 +239,13 @@ class Account extends BaseModel
}
$trial_active = false;
if ($trial_plan && $include_trial) {
$trial_started = $this->trial_started;
$trial_expires = $this->trial_started->addSeconds($this->trial_duration);
// $trial_expires->modify('+2 weeks');
if($trial_expires->lessThan(now())){
if($trial_expires->greaterThan(now())){
$trial_active = true;
}
@ -270,6 +271,7 @@ class Account extends BaseModel
return null;
}
// Should we show plan details or trial details?
if (($plan && ! $trial_plan) || ! $include_trial) {
$use_plan = true;

View File

@ -42,13 +42,25 @@ class PlanTest extends TestCase
public function testTrialPlans()
{
config(['ninja.production' => true]);
$this->assertFalse($this->account->hasFeature(Account::FEATURE_USERS));
$this->account->trial_plan = 'enterprise';
$this->account->trial_started = now();
$this->account->trial_duration = 60*60*24*31;
$this->account->save();
$this->assertTrue($this->account->hasFeature(Account::FEATURE_USERS));
nlog($this->account->getPlanDetails());
$this->assertFalse($this->account->hasFeature(Account::FEATURE_USERS));
$this->account->trial_plan = 'pro';
$this->account->save();
$this->assertFalse($this->account->hasFeature(Account::FEATURE_USERS));
$this->assertTrue($this->account->hasFeature(Account::FEATURE_CUSTOM_URL));
}