Skip to content

Commit

Permalink
Feature/add enable updates for deleting (#8)
Browse files Browse the repository at this point in the history
Enable updates for deleting
  • Loading branch information
danielkleach authored and joshforbes committed Nov 16, 2017
1 parent 4ee54bd commit c5a7696
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)->toDateTimeString(), $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 c5a7696

Please sign in to comment.