1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Allow "Test Plan" to be disabled in config

Summary:
This is a somewhat common request, and far more difficult than necessary currently.

I think the field is useful enough to leave it default-enabled, but there's wide diversity in testing philosophy.

Test Plan: Verified "test plan" field appeared. Disabled config. Verified "test plan" field vanished.

Reviewers: btrahan, vrana, jungejason

Reviewed By: vrana

CC: aran, asouza

Differential Revision: https://secure.phabricator.com/D2193
This commit is contained in:
epriestley 2012-04-10 13:36:05 -07:00
parent 5f615c1e6e
commit 01907bcccc
4 changed files with 56 additions and 23 deletions

View file

@ -675,6 +675,18 @@ return array(
// enable them. // enable them.
'differential.show-host-field' => false, 'differential.show-host-field' => false,
// Differential has a required "Test Plan" field by default, which requires
// authors to fill out information about how they verified the correctness of
// their changes when sending code for review. If you'd prefer not to use
// this field, you can disable it here. You can also make it optional
// (instead of required) below.
'differential.show-test-plan-field' => true,
// Differential has a required "Test Plan" field by default. You can make it
// optional by setting this to false. You can also completely remove it above,
// if you prefer.
'differential.require-test-plan-field' => true,
// If you set this to true, users can "!accept" revisions via email (normally, // If you set this to true, users can "!accept" revisions via email (normally,
// they can take other actions but can not "!accept"). This action is disabled // they can take other actions but can not "!accept"). This action is disabled
// by default because email authentication can be configured to be very weak, // by default because email authentication can be configured to be very weak,

View file

@ -23,26 +23,30 @@ final class DifferentialDefaultFieldSelector
$fields = array( $fields = array(
new DifferentialTitleFieldSpecification(), new DifferentialTitleFieldSpecification(),
new DifferentialSummaryFieldSpecification(), new DifferentialSummaryFieldSpecification(),
new DifferentialTestPlanFieldSpecification(),
new DifferentialRevisionStatusFieldSpecification(),
new DifferentialAuthorFieldSpecification(),
new DifferentialReviewersFieldSpecification(),
new DifferentialReviewedByFieldSpecification(),
new DifferentialCCsFieldSpecification(),
new DifferentialUnitFieldSpecification(),
new DifferentialLintFieldSpecification(),
new DifferentialCommitsFieldSpecification(),
new DifferentialDependenciesFieldSpecification(),
new DifferentialManiphestTasksFieldSpecification(),
); );
if (PhabricatorEnv::getEnvConfig('differential.show-test-plan-field')) {
$fields[] = new DifferentialTestPlanFieldSpecification();
}
$fields = array_merge(
$fields,
array(
new DifferentialRevisionStatusFieldSpecification(),
new DifferentialAuthorFieldSpecification(),
new DifferentialReviewersFieldSpecification(),
new DifferentialReviewedByFieldSpecification(),
new DifferentialCCsFieldSpecification(),
new DifferentialUnitFieldSpecification(),
new DifferentialLintFieldSpecification(),
new DifferentialCommitsFieldSpecification(),
new DifferentialDependenciesFieldSpecification(),
new DifferentialManiphestTasksFieldSpecification(),
));
if (PhabricatorEnv::getEnvConfig('differential.show-host-field')) { if (PhabricatorEnv::getEnvConfig('differential.show-host-field')) {
$fields = array_merge( $fields[] = new DifferentialHostFieldSpecification();
$fields, $fields[] = new DifferentialPathFieldSpecification();
array(
new DifferentialHostFieldSpecification(),
new DifferentialPathFieldSpecification(),
));
} }
$fields = array_merge( $fields = array_merge(

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,7 +20,9 @@ final class DifferentialTestPlanFieldSpecification
extends DifferentialFieldSpecification { extends DifferentialFieldSpecification {
private $plan; private $plan;
private $error = true;
// NOTE: This means "uninitialized".
private $error = false;
public function shouldAppearOnEdit() { public function shouldAppearOnEdit() {
return true; return true;
@ -37,6 +39,14 @@ final class DifferentialTestPlanFieldSpecification
} }
public function renderEditControl() { public function renderEditControl() {
if ($this->error === false) {
if ($this->isRequired()) {
$this->error = true;
} else {
$this->error = null;
}
}
return id(new AphrontFormTextAreaControl()) return id(new AphrontFormTextAreaControl())
->setLabel('Test Plan') ->setLabel('Test Plan')
->setName('testplan') ->setName('testplan')
@ -49,10 +59,12 @@ final class DifferentialTestPlanFieldSpecification
} }
public function validateField() { public function validateField() {
if (!strlen($this->plan)) { if ($this->isRequired()) {
$this->error = 'Required'; if (!strlen($this->plan)) {
throw new DifferentialFieldValidationException( $this->error = 'Required';
"You must provide a test plan."); throw new DifferentialFieldValidationException(
"You must provide a test plan.");
}
} }
} }
@ -85,4 +97,8 @@ final class DifferentialTestPlanFieldSpecification
return $value; return $value;
} }
private function isRequired() {
return PhabricatorEnv::getEnvConfig('differential.require-test-plan-field');
}
} }

View file

@ -8,6 +8,7 @@
phutil_require_module('phabricator', 'applications/differential/field/exception/validation'); phutil_require_module('phabricator', 'applications/differential/field/exception/validation');
phutil_require_module('phabricator', 'applications/differential/field/specification/base'); phutil_require_module('phabricator', 'applications/differential/field/specification/base');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'view/form/control/textarea'); phutil_require_module('phabricator', 'view/form/control/textarea');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');