Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:navjobs/temporal-models into dev…
Browse files Browse the repository at this point in the history
…elop
  • Loading branch information
joshforbes committed Nov 16, 2017
2 parents 05298a8 + c5a7696 commit 64d1fad
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Temporal.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ protected function canUpdate()
count($this->getDirty()) == 1,
]);

return $truthChecks->filter()->count() === $truthChecks->count();
return $truthChecks->filter()->count() === $truthChecks->count() ? null : false;
}

/**
Expand All @@ -187,8 +187,12 @@ protected function canUpdate()
*/
protected function endOrDelete()
{
if ($this->enableUpdates) {
return;
}

if ($this->valid_start > Carbon::now()) {
return true;
return;
}

if ($this->isValid()) {
Expand Down
17 changes: 16 additions & 1 deletion tests/TemporalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ public function testItCorrectlySetsTheValidEndOfTheCurrentWhenThereIsAScheduling
'valid_end' => null
]);

$this->assertEquals(Carbon::now()->addDays(15), $currentCommission->fresh()->valid_end);
$this->assertEquals(
Carbon::now()->addDays(15)->toDateString(),
$currentCommission->fresh()->valid_end->toDateString()
);
}

/**
Expand Down Expand Up @@ -310,6 +313,18 @@ public function testItDeletesACommissionCompletelyIfItHasNotStartedYet()
$this->assertNull($commission);
}

/**
* Tests...
*/
public function testItCanDeleteIfTheUserHasSpecifiedToAllowUpdates()
{
$commission = $this->createCommission();
$commission->enableUpdates()->delete();
$commission = $commission->fresh();

$this->assertNull($commission);
}

/**
* Tests...
*/
Expand Down

0 comments on commit 64d1fad

Please sign in to comment.