Merge pull request #69 from creative-commoners/pulls/3.0/siteconfig-defaults

FIX Ensure SiteConfig defaults are used as fallback options
This commit is contained in:
Dylan Wagstaff 2017-10-12 12:49:57 +13:00 committed by GitHub
commit 95d697fcba
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();
}
}