Merge branch 'sprint/devops16_wangyidong_test' into 'sprint/devops16'

Sprint/devops16 wangyidong test

See merge request easycorp/zentaopms!888
This commit is contained in:
李玉春
2021-12-10 07:06:16 +00:00
14 changed files with 255 additions and 22 deletions
+7
View File
@@ -203,6 +203,7 @@ CREATE TABLE IF NOT EXISTS `zt_bug` (
`caseVersion` smallint(6) NOT NULL DEFAULT '1',
`result` mediumint(8) unsigned NOT NULL,
`repo` mediumint(8) unsigned NOT NULL,
`mr` mediumint(8) unsigned NOT NULL,
`entry` varchar(255) NOT NULL,
`lines` varchar(10) NOT NULL,
`v1` varchar(40) NOT NULL,
@@ -1250,6 +1251,12 @@ CREATE TABLE IF NOT EXISTS `zt_task` (
`lastEditedBy` varchar(30) NOT NULL,
`lastEditedDate` datetime NOT NULL,
`activatedDate` date NOT NULL,
`repo` mediumint(8) unsigned NOT NULL,
`mr` mediumint(8) unsigned NOT NULL,
`entry` varchar(255) NOT NULL,
`lines` varchar(10) NOT NULL,
`v1` varchar(40) NOT NULL,
`v2` varchar(40) NOT NULL,
`deleted` enum('0','1') NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `execution` (`execution`),
+3
View File
@@ -357,6 +357,7 @@ $lang->action->dynamicAction->release['notified'] = 'Notify Release';
$lang->action->dynamicAction->release['hidden'] = 'Hide Release';
$lang->action->dynamicAction->story['opened'] = 'Create Story';
$lang->action->dynamicAction->story['importfromgitlab'] = "Issue associate create story";
$lang->action->dynamicAction->story['edited'] = 'Edit Story';
$lang->action->dynamicAction->story['activated'] = 'Activate Story';
$lang->action->dynamicAction->story['reviewed'] = 'Review Story';
@@ -397,6 +398,7 @@ $lang->action->dynamicAction->kanbanlane['moved'] = 'Move Swimlane';
$lang->action->dynamicAction->team['managedTeam'] = 'Manage Team';
$lang->action->dynamicAction->task['opened'] = 'Create Task';
$lang->action->dynamicAction->task['importfromgitlab'] = "Issue associate create task";
$lang->action->dynamicAction->task['edited'] = 'Edit Task';
$lang->action->dynamicAction->task['commented'] = 'Task Comment';
$lang->action->dynamicAction->task['assigned'] = 'Assign Task';
@@ -430,6 +432,7 @@ $lang->action->dynamicAction->build['edited'] = 'Edit Build';
$lang->action->dynamicAction->build['deleted'] = 'Delete Build';
$lang->action->dynamicAction->bug['opened'] = 'Report Bug';
$lang->action->dynamicAction->bug['importfromgitlab'] = "Issue associate create bug";
$lang->action->dynamicAction->bug['edited'] = 'Edit Bug';
$lang->action->dynamicAction->bug['activated'] = 'Activate Bug';
$lang->action->dynamicAction->bug['assigned'] = 'Assign Bug';
+3
View File
@@ -357,6 +357,7 @@ $lang->action->dynamicAction->release['notified'] = '通知发布';
$lang->action->dynamicAction->release['hidden'] = '隐藏发布';
$lang->action->dynamicAction->story['opened'] = "创建{$lang->SRCommon}";
$lang->action->dynamicAction->story['importfromgitlab'] = "从Gitlab关联创建{$lang->SRCommon}";
$lang->action->dynamicAction->story['edited'] = "编辑{$lang->SRCommon}";
$lang->action->dynamicAction->story['activated'] = "激活{$lang->SRCommon}";
$lang->action->dynamicAction->story['reviewed'] = "评审{$lang->SRCommon}";
@@ -397,6 +398,7 @@ $lang->action->dynamicAction->kanbanlane['moved'] = '移动泳道';
$lang->action->dynamicAction->team['managedTeam'] = '维护团队';
$lang->action->dynamicAction->task['opened'] = '创建任务';
$lang->action->dynamicAction->task['importfromgitlab'] = "从Gitlab关联创建任务";
$lang->action->dynamicAction->task['edited'] = '编辑任务';
$lang->action->dynamicAction->task['commented'] = '备注任务';
$lang->action->dynamicAction->task['assigned'] = '指派任务';
@@ -430,6 +432,7 @@ $lang->action->dynamicAction->build['edited'] = '编辑版本';
$lang->action->dynamicAction->build['deleted'] = '删除版本';
$lang->action->dynamicAction->bug['opened'] = '创建Bug';
$lang->action->dynamicAction->bug['importfromgitlab'] = "从Gitlab关联创建Bug";
$lang->action->dynamicAction->bug['edited'] = '编辑Bug';
$lang->action->dynamicAction->bug['activated'] = '激活Bug';
$lang->action->dynamicAction->bug['assigned'] = '指派Bug';
+5 -1
View File
@@ -47,15 +47,19 @@ function deleteItem(obj)
$(document).on('change', '[id^="levels"]', function()
{
$tr = $(this).closest('tr');
$next = $(this).closest('td').next()
if($(this).val() == '50')
var ownerLevel = 50;
if($(this).val() == ownerLevel)
{
$next.prepend('<input type="text" value="" class="form-control disabled" disabled autocomplete="off" />');
$next.find('[id^="expires"]').addClass('hidden');
$tr.find('a[onclick^="deleteItem"]').addClass('disabled');
}
else
{
$next.find('[id^="expires"]').removeClass('hidden');
$next.find('input.disabled').remove();
$tr.find('a[onclick^="deleteItem"]').removeClass('disabled');
}
})
@@ -19,13 +19,14 @@
</tr>
</thead>
<tbody>
<?php $ownerLevel = 50;?>
<?php $i = 0;?>
<?php foreach($currentMembers as $member):?>
<tr>
<td><?php echo html::input("names[$i]", $member->name, "class='form-control' readonly");?></td>
<td><?php echo html::select("levels[$i]", array(''=>'') + $this->lang->gitlab->accessLevels, $member->access_level, "class='form-control chosen'");?></td>
<td>
<?php if($member->access_level == '50'):?>
<?php if($member->access_level == $ownerLevel):?>
<input type="text" value="" class="form-control disabled" disabled autocomplete="off" />
<?php echo html::input("expires[$i]", $member->expires_at, "class='form-control form-date hidden'");?>
<?php else:?>
@@ -35,7 +36,7 @@
</td>
<td class='c-actions text-center'>
<?php echo html::a('javascript:;', "<i class='icon-plus'></i>", '', "onclick='addItem(this)' class='btn btn-link'");?>
<?php echo html::a('javascript:;', "<i class='icon icon-close'></i>", '', "onclick='deleteItem(this)' class='btn btn-link'");?>
<?php echo html::a('javascript:;', "<i class='icon icon-close'></i>", '', "onclick='deleteItem(this)' class='btn btn-link" . ($member->access_level == $ownerLevel ? ' disabled' : '') . "'");?>
</td>
</tr>
<?php $i ++;?>
+1 -1
View File
@@ -800,7 +800,7 @@ class mr extends control
{
if($this->post->reviewType == 'bug') $result = $this->mr->saveBug($repoID, $mr, $v1, $v2);
if($this->post->reviewType == 'task') $result = $this->mr->saveTask($repoID, $mr, $v1, $v2);
if(dao::isError()) die(json_encode($result));
if($result['result'] == 'fail') die(json_encode($result));
$objectID = $result['id'];
$repo = $this->repo->getRepoById($repoID);
+15 -12
View File
@@ -573,7 +573,7 @@ class mrModel extends model
if($singleDiff->state == 'empty') continue;
$commits = $singleDiff->commits;
$diffs = $singleDiff->diffs;
foreach ($diffs as $index => $diff)
foreach($diffs as $index => $diff)
{
if(empty($commits[$index])) continue;
/* Make sure every file with same commitID is unique in $lines. */
@@ -793,11 +793,13 @@ class mrModel extends model
*/
public function getReview($repoID, $MRID, $revision = '')
{
if(empty($repoID) OR empty($MRID)) return array();
$reviews = array();
$bugs = $this->dao->select('t1.*, t2.realname')->from(TABLE_BUG)->alias('t1')
->leftJoin(TABLE_USER)->alias('t2')->on('t1.openedBy = t2.account')
->where('t1.repo')->eq($repoID)
->andWhere('t1.mr')->eq($MRID)
->where('t1.repo')->eq((int)$repoID)
->andWhere('t1.mr')->eq((int)$MRID)
->beginIF($revision)->andWhere('t1.v2')->eq($revision)->fi()
->andWhere('t1.deleted')->eq(0)
->fetchAll('id');
@@ -813,8 +815,8 @@ class mrModel extends model
$tasks = $this->dao->select('t1.*, t2.realname')->from(TABLE_TASK)->alias('t1')
->leftJoin(TABLE_USER)->alias('t2')->on('t1.openedBy = t2.account')
->where('t1.repo')->eq($repoID)
->andWhere('t1.mr')->eq($MRID)
->where('t1.repo')->eq((int)$repoID)
->andWhere('t1.mr')->eq((int)$MRID)
->beginIF($revision)->andWhere('t1.v2')->eq($revision)->fi()
->andWhere('t1.deleted')->eq(0)
->fetchAll('id');
@@ -914,7 +916,7 @@ class mrModel extends model
unset($data->commentText);
$this->loadModel('bug');
foreach(explode(',', $this->config->bug->create->requiredFields) as $requiredField)
foreach(explode(',', $this->config->bug->create->requiredFields . ',repo,mr') as $requiredField)
{
$requiredField = trim($requiredField);
if(empty($requiredField)) continue;
@@ -923,7 +925,7 @@ class mrModel extends model
{
$fieldName = $requiredField;
if(isset($this->lang->bug->$requiredField)) $fieldName = $this->lang->bug->$requiredField;
dao::$errors[] = sprintf($this->lang->error->notempty, $fieldName);
dao::$errors[$requiredField][] = sprintf($this->lang->error->notempty, $fieldName);
}
}
if(dao::isError()) return array('result' => 'fail', 'message' => dao::getError());
@@ -992,7 +994,7 @@ class mrModel extends model
if($task->assignedTo) $task->assignedDate = $now;
$this->loadModel('task');
foreach(explode(',', $this->config->task->create->requiredFields) as $requiredField)
foreach(explode(',', $this->config->task->create->requiredFields . ',repo,mr') as $requiredField)
{
$requiredField = trim($requiredField);
if(empty($requiredField)) continue;
@@ -1001,7 +1003,7 @@ class mrModel extends model
{
$fieldName = $requiredField;
if(isset($this->lang->task->$requiredField)) $fieldName = $this->lang->task->$requiredField;
dao::$errors[] = sprintf($this->lang->error->notempty, $fieldName);
dao::$errors[$requiredField][] = sprintf($this->lang->error->notempty, $fieldName);
}
}
if(dao::isError()) return array('result' => 'fail', 'message' => dao::getError());
@@ -1082,10 +1084,11 @@ class mrModel extends model
*/
public function getLastReviewInfo($repoID)
{
$lastReview = new stdclass();
$lastReview->bug = $this->dao->select('*')->from(TABLE_BUG)->where('repo')->eq($repoID)->orderby('id_desc')->fetch();
$lastReview->task = $this->dao->select('*')->from(TABLE_TASK)->where('repo')->eq($repoID)->orderby('id_desc')->fetch();
if(empty($repoID)) return null;
$lastReview = new stdclass();
$lastReview->bug = $this->dao->select('*')->from(TABLE_BUG)->where('repo')->eq((int)$repoID)->orderby('id_desc')->fetch();
$lastReview->task = $this->dao->select('*')->from(TABLE_TASK)->where('repo')->eq((int)$repoID)->orderby('id_desc')->fetch();
return $lastReview;
}
+8 -6
View File
@@ -44,13 +44,13 @@ $this->loadModel('repo');
$taskModuleSelect = html::select('taskModule', $taskModules, $taskRepoModule, 'class="form-control chosen"');
$taskUserSelect = html::select('taskAssignedTo', $taskMembers, '', 'class="form-control chosen"');
$taskExecutionSelect = html::select('taskExecution', $taskExecutions, $repoExecution, 'class="form-control chosen"');
$taskExecutionSelect = html::select('taskExecution', $taskExecutions, $repoExecution, 'class="form-control chosen" onchange="changeExecution(this)"');
$reviewUrl = $this->createLink('mr', 'addReview', "repoID=$repoID&mr={$MR->id}&v1=$v1&v2=");
$productSelect = html::select('product', $products, $repoProduct, 'class="product form-control chosen" onchange="changeProduct(this)"');
$branches = $this->loadModel('branch')->getPairs($repoProduct);
$moduleSelect = html::select('module', $modules, $bugRepoModule, 'class="form-control chosen"');
$executionSelect = html::select('execution', $executions, '', 'class="form-control chosen" onchange="changeExecution(this)"');
$executionSelect = html::select('execution', $executions, '', 'class="form-control chosen"');
$typeSelect = html::select('repoType', $lang->repo->typeList, '', 'class="form-control chosen"');
$userSelect = html::select('assignedTo', $users, '', 'class="form-control chosen assignedTo"');
@@ -96,12 +96,14 @@ js::set('revision', '');
<div class="reviewFormContainer">
<table class='table table-form'>
<tr>
<th><?php echo $lang->mr->reviewType;?></th>
<td><?php echo html::select('reviewType', $lang->mr->reviewTypeList, 'bug', "class='form-control' onchange=changeReviewType(this)")?></td>
<th class='w-100px'><?php echo $lang->mr->reviewType;?></th>
<td class='w-p45'><?php echo html::select('reviewType', $lang->mr->reviewTypeList, 'bug', "class='form-control' onchange=changeReviewType(this)")?></td>
<th class='w-100px'></th>
<td class='w-p45'></td>
</tr>
<tr>
<th><?php echo $lang->repo->product?></th>
<td class='w-p45'>
<td>
<div class='input-group'>
<?php echo $productSelect?>
<?php if($branches) echo html::select('branch', $branches, '', "class='form-control' style='width:95px'");?>
@@ -161,7 +163,7 @@ js::set('revision', '');
</form>
<?php else:?>
<form id='reviewForm' class='reviewForm hide'>
<?php printf($lang->user->errorDeny, $lang->repo->common, $lang->repo->addReview);?>
<?php printf($lang->user->errorDeny, $lang->mr->common, $lang->mr->addReview);?>
</form>
<?php endif;?>
+24
View File
@@ -735,6 +735,10 @@ class upgradeModel extends model
$this->updateObjectBranch();
$this->updateProjectStories();
$this->appendExec('15_7_1');
case '16_0_beta1':
$this->saveLogs('Execute 16_0_beta1');
$this->adjustPriv16_0_beta1();
$this->appendExec('16_0_beta1');
}
$this->deletePatch();
@@ -5404,4 +5408,24 @@ class upgradeModel extends model
return true;
}
/**
* Adjust priv 16_0_beta1.
*
* @access public
* @return bool
*/
public function adjustPriv16_0_beta1()
{
$groups = $this->dao->select('`group`')->from(TABLE_GROUPPRIV)->where('module')->eq('mr')->andWhere('method')->eq('addBug')->fetchPairs('group', 'group');
foreach($groups as $groupID)
{
$groupPriv = new stdclass();
$groupPriv->group = $groupID;
$groupPriv->module = 'mr';
$groupPriv->method = 'addReview';
$this->dao->replace(TABLE_GROUPPRIV)->data($groupPriv)->exec();
}
return true;
}
}
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
/**
title=测试 mrModel::getDiffs();
cid=1
pid=1
使用空的MR >> return null
使用正确的MR >> return normal
*/
$mrModel = $tester->loadModel('mr');
$MR = '';
$result = $mrModel->getDiffs($MR);
if(empty($result)) $result = 'return null';
r($result) && p() && e('return null'); //使用空的MR
$MR = $tester->dao->select('*')->from(TABLE_MR)->orderBy('id_desc')->limit(1)->fetch();
$result = $mrModel->getDiffs($MR);
if(!empty($result))
{
$first = reset($result);
if(isset($first->fileName) and is_array($first->contents)) $result = 'return normal';
}
r($result) && p() && e('return normal'); //使用正确的MR
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
/**
title=测试 mrModel::getLastReviewInfo();
cid=1
pid=1
使用空的repoID >> return null
使用正确的repoID >> return normal
*/
$mrModel = $tester->loadModel('mr');
$repoID = 0;
$result = $mrModel->getLastReviewInfo($repoID);
if(empty($result)) $result = 'return null';
r($result) && p() && e('return null'); //使用空的repoID
$repo = $tester->dao->select('*')->from(TABLE_REPO)->orderBy('id_desc')->limit(1)->fetch();
$result = $mrModel->getLastReviewInfo($repo->id);
if(isset($result->bug) and isset($result->task)) $result = 'return normal';
r($result) && p() && e('return normal'); //使用正确的repoID
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
/**
title=测试 mrModel::getReview();
cid=1
pid=1
使用空的repoID, MRID, revision >> return null
使用正确的repoID, MRID >> return normal
使用正确的repoID, MRID, 错误的revision >> return null
*/
$mrModel = $tester->loadModel('mr');
$repoID = 0;
$MRID = 0;
$revision = '';
$result = $mrModel->getReview($repoID, $MRID, $revision);
if(empty($result)) $result = 'return null';
r($result) && p() && e('return null'); //使用空的repoID, MRID, revision
$MR = $tester->dao->select('*')->from(TABLE_MR)->orderBy('id_desc')->limit(1)->fetch();
$repoID = $MR->repoID;
$MRID = $MR->id;
$result = $mrModel->getReview($repoID, $MRID, $revision);
if(!empty($result))
{
$first = reset($result);
if(isset($first['bug']) or isset($first['task'])) $result = 'return normal';
}
r($result) && p() && e('return normal'); //使用正确的repoID, MRID
$revision = '123qwe';
$result = $mrModel->getReview($repoID, $MRID, $revision);
if(empty($result)) $result = 'return null';
r($result) && p() && e('return null'); //使用正确的repoID, MRID, 错误的revision
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
/**
title=测试 mrModel::saveBug();
cid=1
pid=1
使用空的repoID, MRID >> return false
使用正确的repoID, MRID。空的title。 >> return false
使用正确的repoID, MRID。POST数据正确。 >> Test Bug Review
*/
$mrModel = $tester->loadModel('mr');
$_POST = array();
$_POST['title'] = 'Test Bug Review';
$_POST['commentText'] = 'Test Bug Review';
$_POST['module'] = '1';
$_POST['begin'] = '8';
$_POST['end'] = '8';
$_POST['product'] = '1';
$_POST['assignedTo'] = '';
$repoID = 0;
$MRID = 0;
$v1 = 0;
$v2 = '';
$result = $mrModel->saveBug($repoID, $MRID, $v1, $v2);
if($result['result'] == 'fail' and isset($result['message']['mr']) and isset($result['message']['repo'])) $result = 'return false';
r($result) && p() && e('return false'); //使用空的repoID, MRID
$_POST['title'] = '';
$MR = $tester->dao->select('*')->from(TABLE_MR)->orderBy('id_desc')->limit(1)->fetch();
$result = $mrModel->saveBug($MR->repoID, $MR->id, $v1, $v2);
if($result['result'] == 'fail' and isset($result['message']['title'])) $result = 'return false';
r($result) && p() && e('return false'); //使用正确的repoID, MRID。空的title。
$_POST['title'] = 'Test Bug Review';
$result = $mrModel->saveBug($MR->repoID, $MR->id, $v1, $v2);
r($result) && p('title') && e('Test Bug Review'); //使用正确的repoID, MRID。POST数据正确。
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
/**
title=测试 mrModel::saveTask();
cid=1
pid=1
使用空的repoID, MRID >> return false
使用正确的repoID, MRID。空的title。 >> return false
使用正确的repoID, MRID。POST数据正确。 >> Test Task Review
*/
$mrModel = $tester->loadModel('mr');
$_POST = array();
$_POST['title'] = 'Test Task Review';
$_POST['commentText'] = 'Test Task Review';
$_POST['taskModule'] = '1';
$_POST['taskExecution'] = '1';
$_POST['begin'] = '8';
$_POST['end'] = '8';
$_POST['taskAssignedTo'] = '';
$_POST['entry'] = '';
$repoID = 0;
$MRID = 0;
$v1 = 0;
$v2 = '';
$result = $mrModel->saveTask($repoID, $MRID, $v1, $v2);
if($result['result'] == 'fail' and isset($result['message']['mr']) and isset($result['message']['repo'])) $result = 'return false';
r($result) && p() && e('return false'); //使用空的repoID, MRID
$_POST['title'] = '';
$MR = $tester->dao->select('*')->from(TABLE_MR)->orderBy('id_desc')->limit(1)->fetch();
$result = $mrModel->saveTask($MR->repoID, $MR->id, $v1, $v2);
if($result['result'] == 'fail' and isset($result['message']['name'])) $result = 'return false';
r($result) && p() && e('return false'); //使用正确的repoID, MRID。空的title。
$_POST['title'] = 'Test Task Review';
$result = $mrModel->saveTask($MR->repoID, $MR->id, $v1, $v2);
r($result) && p('title') && e('Test Task Review'); //使用正确的repoID, MRID。POST数据正确。