Skip to content

Commit d3f67fb

Browse files
Change defaults for project uploadquota and autoremovetimeframe (#3738)
This PR moves the default project settings from database defaults to Eloquent attribute defaults, allowing defaults to be changed without database migrations in the future. I plan to make a series of follow-up PRs to do the same for other tables. This PR also increases the default `uploadquota` from 0 to 10 GB, and increases `autoremovetimeframe` from 0 to 90.
1 parent 2db9dac commit d3f67fb

8 files changed

Lines changed: 81 additions & 19 deletions

File tree

app/Models/Project.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
* @property bool $emailbrokensubmission
3232
* @property bool $emailredundantfailures
3333
* @property ?string $cvsviewertype
34-
* @property int $testtimestd
35-
* @property int $testtimestdthreshold
34+
* @property float $testtimestd
35+
* @property float $testtimestdthreshold
3636
* @property bool $showtesttime
3737
* @property int $testtimemaxstatus
3838
* @property int $emailmaxitems
@@ -108,6 +108,33 @@ class Project extends Model
108108
'coveragethreshold' => 'integer',
109109
'showcoveragecode' => 'boolean',
110110
'authenticatesubmissions' => 'boolean',
111+
'testtimestd' => 'float',
112+
'testtimestdthreshold' => 'float',
113+
'testtimemaxstatus' => 'integer',
114+
'emailmaxitems' => 'integer',
115+
'emailmaxchars' => 'integer',
116+
'autoremovetimeframe' => 'integer',
117+
'uploadquota' => 'integer',
118+
];
119+
120+
protected $attributes = [
121+
'coveragethreshold' => 70,
122+
'nightlytime' => '00:00:00',
123+
'emaillowcoverage' => false,
124+
'emailtesttimingchanged' => false,
125+
'emailbrokensubmission' => true,
126+
'emailredundantfailures' => false,
127+
'testtimestd' => 4,
128+
'testtimestdthreshold' => 1,
129+
'showtesttime' => false,
130+
'testtimemaxstatus' => 3,
131+
'emailmaxitems' => 5,
132+
'emailmaxchars' => 255,
133+
'displaylabels' => true,
134+
'autoremovetimeframe' => 90,
135+
'uploadquota' => 10,
136+
'showcoveragecode' => true,
137+
'authenticatesubmissions' => false,
111138
];
112139

113140
public const PROJECT_ADMIN = 2;

app/cdash/tests/case/CDash/MultipleSubprojectsEmailTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@
3232
use Illuminate\Support\Facades\URL;
3333
use Illuminate\Support\Str;
3434
use PHPUnit\Framework\MockObject\MockObject;
35+
use Tests\Traits\CreatesProjects;
3536

3637
class MultipleSubprojectsEmailTest extends CDashUseCaseTestCase
3738
{
39+
use CreatesProjects;
40+
3841
private static $tz;
3942
private static $database;
4043

@@ -109,9 +112,8 @@ public function setUp(): void
109112
URL::forceRootUrl('http://open.cdash.org');
110113

111114
if (self::$projectid === -1) {
112-
self::$projectid = DB::table('project')->insertGetId([
113-
'name' => 'TestProject1',
114-
]);
115+
$project = $this->makePublicProject('TestProject1');
116+
self::$projectid = $project->id;
115117

116118
// A hack to make sure builds exist and can be referenced so we don't violate our foreign key constraints
117119
for ($i = 0; $i < 10; $i++) {

app/cdash/tests/case/CDash/TestUseCaseTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@
99
use CDash\Test\UseCase\UseCase;
1010
use Illuminate\Support\Collection;
1111
use Illuminate\Support\Facades\DB;
12+
use Tests\Traits\CreatesProjects;
1213

1314
class TestUseCaseTest extends CDashUseCaseTestCase
1415
{
16+
use CreatesProjects;
17+
1518
private int $projectid = -1;
1619

1720
public function setUp(): void
1821
{
1922
$this->createApplication();
20-
$this->projectid = DB::table('project')->insertGetId([
21-
'name' => 'TestProject1',
22-
]);
23+
$project = $this->makePublicProject('TestProject1');
24+
$this->projectid = $project->id;
2325

2426
// A hack to make sure builds exist and can be referenced so we don't violate our foreign key constraints
2527
for ($i = 0; $i < 10; $i++) {

app/cdash/tests/test_buildmodel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function __construct()
3232

3333
$project = Project::create([
3434
'name' => 'BuildModel',
35+
'public' => Project::ACCESS_PUBLIC,
3536
]);
3637

3738
DB::table('buildgroup')->insertOrIgnore([
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Support\Facades\DB;
5+
6+
return new class extends Migration {
7+
public function up(): void
8+
{
9+
DB::statement('ALTER TABLE project ALTER COLUMN name DROP DEFAULT');
10+
DB::statement('ALTER TABLE project ALTER COLUMN public DROP DEFAULT');
11+
DB::statement('ALTER TABLE project ALTER COLUMN coveragethreshold DROP DEFAULT');
12+
DB::statement('ALTER TABLE project ALTER COLUMN nightlytime DROP DEFAULT');
13+
DB::statement('ALTER TABLE project ALTER COLUMN emaillowcoverage DROP DEFAULT');
14+
DB::statement('ALTER TABLE project ALTER COLUMN emailtesttimingchanged DROP DEFAULT');
15+
DB::statement('ALTER TABLE project ALTER COLUMN emailbrokensubmission DROP DEFAULT');
16+
DB::statement('ALTER TABLE project ALTER COLUMN emailredundantfailures DROP DEFAULT');
17+
DB::statement('ALTER TABLE project ALTER COLUMN testtimestd DROP DEFAULT');
18+
DB::statement('ALTER TABLE project ALTER COLUMN testtimestdthreshold DROP DEFAULT');
19+
DB::statement('ALTER TABLE project ALTER COLUMN showtesttime DROP DEFAULT');
20+
DB::statement('ALTER TABLE project ALTER COLUMN testtimemaxstatus DROP DEFAULT');
21+
DB::statement('ALTER TABLE project ALTER COLUMN emailmaxitems DROP DEFAULT');
22+
DB::statement('ALTER TABLE project ALTER COLUMN emailmaxchars DROP DEFAULT');
23+
DB::statement('ALTER TABLE project ALTER COLUMN displaylabels DROP DEFAULT');
24+
DB::statement('ALTER TABLE project ALTER COLUMN autoremovetimeframe DROP DEFAULT');
25+
DB::statement('ALTER TABLE project ALTER COLUMN uploadquota DROP DEFAULT');
26+
DB::statement('ALTER TABLE project ALTER COLUMN showcoveragecode DROP DEFAULT');
27+
DB::statement('ALTER TABLE project ALTER COLUMN authenticatesubmissions DROP DEFAULT');
28+
}
29+
30+
public function down(): void
31+
{
32+
}
33+
};

tests/Browser/Pages/CreateProjectPageTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use App\Models\Project;
66
use App\Models\User;
7-
use App\Services\ProjectService;
87
use Illuminate\Support\Str;
98
use Laravel\Dusk\Browser;
109
use PHPUnit\Framework\Attributes\DataProvider;
@@ -88,9 +87,7 @@ public function testShowsErrorWhenProjectAlreadyExists(): void
8887

8988
$project_name = Str::uuid()->toString();
9089

91-
$this->projects[] = ProjectService::create([
92-
'name' => $project_name,
93-
]);
90+
$this->projects[] = $this->makePublicProject($project_name);
9491

9592
$this->browse(function (Browser $browser) use ($project_name): void {
9693
$browser->loginAs($this->users['admin'])

tests/Feature/AutoRemoveBuildsCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
namespace Tests\Feature;
44

55
use App\Models\Project;
6-
use App\Services\ProjectService;
76
use CDash\Database;
87
use CDash\Model\Build;
98
use DateTime;
109
use DateTimeZone;
1110
use Illuminate\Foundation\Testing\DatabaseTransactions;
1211
use Tests\TestCase;
12+
use Tests\Traits\CreatesProjects;
1313

1414
class AutoRemoveBuildsCommand extends TestCase
1515
{
16+
use CreatesProjects;
1617
use DatabaseTransactions;
1718

1819
protected Project $project;
@@ -21,10 +22,9 @@ public function setUp(): void
2122
{
2223
parent::setUp();
2324

24-
$this->project = ProjectService::create([
25-
'name' => 'AutoRemoveProject',
26-
'autoremovetimeframe' => 45,
27-
]);
25+
$this->project = $this->makePublicProject('AutoRemoveProject');
26+
$this->project->autoremovetimeframe = 45;
27+
$this->project->save();
2828
}
2929

3030
public function tearDown(): void

tests/Feature/GraphQL/Mutations/UpdateProjectTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ public static function fieldValues(): array
196196
['emailTestTimingChanged', true, 'emailtesttimingchanged', true],
197197
['emailBrokenSubmissions', true, 'emailbrokensubmission', true],
198198
['emailRedundantFailures', true, 'emailredundantfailures', true],
199-
['testTimeStdMultiplier', 5.0, 'testtimestd', '5.00'],
200-
['testTimeStdThreshold', 2.0, 'testtimestdthreshold', '2.00'],
199+
['testTimeStdMultiplier', 5.0, 'testtimestd', 5.0],
200+
['testTimeStdThreshold', 2.0, 'testtimestdthreshold', 2.0],
201201
['enableTestTiming', false, 'showtesttime', false],
202202
['timeStatusFailureThreshold', 3, 'testtimemaxstatus', 3],
203203
['emailMaxItems', 20, 'emailmaxitems', 20],

0 commit comments

Comments
 (0)