FIX Ensure SiteConfig defaults are used as fallback options

This commit is contained in:
Robbie Averill 2017-10-06 16:39:53 +13:00
parent c6da57f0c5
commit 11a5dc7617
2 changed files with 25 additions and 1 deletions

View File

@ -454,7 +454,10 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
$options = $this->getOptions();
if (!$options || !$options->hasExtension($this->class)) {
if (!$options
// Options can be a SiteConfig with different extension applied
|| (!$options->hasExtension($this->class) && !$options->hasExtension('ContentReviewDefaultSettings'))
) {
return false;
}

View File

@ -313,4 +313,25 @@ class SiteTreeContentReviewTest extends ContentReviewBaseTest
SS_Datetime::clear_mock_now();
}
public function testSiteConfigSettingsAreUsedAsDefaults()
{
SS_Datetime::set_mock_now("2020-03-01 12:00:00");
/** @var Member $author */
$author = $this->objFromFixture('Member', 'editor');
/** @var SiteConfig $siteConfig */
$siteConfig = SiteConfig::current_site_config();
// Set the author to a default user for reviewing
$siteConfig->OwnerUsers()->add($author);
$emptyPage = new Page;
$emptyPage->NextReviewDate = '2020-02-20 12:00:00';
$this->assertTrue($emptyPage->canBeReviewedBy($author));
SS_Datetime::clear_mock_now();
}
}