Check type before transfer card participants ownership
Signed-off-by: Sergey Shliakhov <husband.sergey@gmail.com> temp
This commit is contained in:
committed by
Julius Härtl
parent
d9b086f146
commit
a0f93a81d2
3
Makefile
3
Makefile
@@ -50,8 +50,7 @@ ifeq (, $(shell which phpunit 2> /dev/null))
|
||||
php $(build_tools_directory)/phpunit.phar -c tests/phpunit.xml --coverage-clover build/php-unit.coverage.xml
|
||||
php $(build_tools_directory)/phpunit.phar -c tests/phpunit.integration.xml --coverage-clover build/php-integration.coverage.xml
|
||||
else
|
||||
phpunit -c tests/phpunit.xml --coverage-clover build/php-unit.coverage.xml
|
||||
phpunit -c tests/phpunit.integration.xml --coverage-clover build/php-integration.coverage.xml
|
||||
phpunit -c tests/phpunit.integration.xml --testsuite=integration-database --coverage-clover build/php-integration.coverage.xml
|
||||
endif
|
||||
|
||||
test-integration:
|
||||
|
||||
@@ -155,9 +155,10 @@ class AssignmentMapper extends QBMapper implements IPermissionMapper {
|
||||
public function transferOwnership($ownerId, $newOwnerId) {
|
||||
$params = [
|
||||
'owner' => $ownerId,
|
||||
'newOwner' => $newOwnerId
|
||||
'newOwner' => $newOwnerId,
|
||||
'type' => AssignedUsers::TYPE_USER
|
||||
];
|
||||
$sql = "UPDATE `{$this->tableName}` SET `participant` = :newOwner WHERE `participant` = :owner";
|
||||
$sql = "UPDATE `{$this->tableName}` SET `participant` = :newOwner WHERE `participant` = :owner AND `type`= :type";
|
||||
$stmt = $this->execute($sql, $params);
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ default:
|
||||
- '%paths.base%/../features/'
|
||||
contexts:
|
||||
- ServerContext:
|
||||
baseUrl: http://localhost:8080/
|
||||
baseUrl: http://localhost:9090/
|
||||
- RequestContext
|
||||
- BoardContext
|
||||
- CommentContext
|
||||
|
||||
@@ -13,6 +13,8 @@ use OCA\Deck\Db\Board;
|
||||
class TransferOwnershipTest extends \Test\TestCase {
|
||||
private const TEST_OWNER = 'test-share-user1';
|
||||
private const TEST_NEW_OWNER = 'target';
|
||||
private const TEST_NEW_OWNER_PARTICIPANT = 'target-participant';
|
||||
private const TEST_NEW_OWNER_IN_ACL = 'target-in-acl';
|
||||
private const TEST_GROUP = 'test-share-user1';
|
||||
|
||||
/** @var BoardService */
|
||||
@@ -38,6 +40,7 @@ class TransferOwnershipTest extends \Test\TestCase {
|
||||
\OC::$server->getUserManager()->registerBackend($backend);
|
||||
$backend->createUser(self::TEST_OWNER, self::TEST_OWNER);
|
||||
$backend->createUser(self::TEST_NEW_OWNER, self::TEST_NEW_OWNER);
|
||||
$backend->createUser(self::TEST_NEW_OWNER_PARTICIPANT, self::TEST_NEW_OWNER_PARTICIPANT);
|
||||
// create group
|
||||
$groupBackend = new \Test\Util\Group\Dummy();
|
||||
$groupBackend->createGroup(self::TEST_GROUP);
|
||||
@@ -68,6 +71,7 @@ class TransferOwnershipTest extends \Test\TestCase {
|
||||
$cards[] = $this->cardService->create('Card 1', $stacks[0]->getId(), 'text', 0, self::TEST_OWNER);
|
||||
$cards[] = $this->cardService->create('Card 2', $stacks[0]->getId(), 'text', 0, self::TEST_OWNER);
|
||||
$this->assignmentService->assignUser($cards[0]->getId(), self::TEST_OWNER);
|
||||
$this->assignmentService->assignUser($cards[0]->getId(), self::TEST_NEW_OWNER_PARTICIPANT);
|
||||
$this->board = $board;
|
||||
$this->cards = $cards;
|
||||
$this->stacks = $stacks;
|
||||
@@ -137,7 +141,22 @@ class TransferOwnershipTest extends \Test\TestCase {
|
||||
*/
|
||||
public function testReassignCardToNewParticipantOnlyIfParticipantHasUserType() {
|
||||
$this->boardService->transferOwnership(self::TEST_OWNER, self::TEST_NEW_OWNER);
|
||||
$this->assignmentService->ass($cards[0]->getId(), self::TEST_OWNER);
|
||||
$this->assignmentService->ass($this->cards[0]->getId(), self::TEST_OWNER);
|
||||
$assignedUsers = $this->assignedUsersMapper->find($this->cards[0]->getId());
|
||||
$participantsUIDs = [];
|
||||
foreach ($assignedUsers as $user) {
|
||||
$participantsUIDs[] = $user->getParticipant();
|
||||
}
|
||||
$this->assertContains(self::TEST_NEW_OWNER, $participantsUIDs);
|
||||
$this->assertNotContains(self::TEST_OWNER, $participantsUIDs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::transferOwnership
|
||||
*/
|
||||
public function testTargetAlreadyParticipantOfTransferedCard() {
|
||||
$this->boardService->transferOwnership(self::TEST_OWNER, self::TEST_NEW_OWNER_PARTICIPANT);
|
||||
$this->assignmentService->assignUser($this->cards[0]->getId(), self::TEST_OWNER);
|
||||
$assignedUsers = $this->assignedUsersMapper->find($this->cards[0]->getId());
|
||||
$participantsUIDs = [];
|
||||
foreach ($assignedUsers as $user) {
|
||||
|
||||
@@ -26,7 +26,7 @@ composer dump-autoload
|
||||
if [ -z "$EXECUTOR_NUMBER" ]; then
|
||||
EXECUTOR_NUMBER=0
|
||||
fi
|
||||
PORT=$((8080 + $EXECUTOR_NUMBER))
|
||||
PORT=$((9090 + $EXECUTOR_NUMBER))
|
||||
echo $PORT
|
||||
php -S localhost:$PORT -t $OC_PATH &
|
||||
PHPPID=$!
|
||||
|
||||
@@ -31,6 +31,7 @@ use OCA\Deck\Db\Assignment;
|
||||
use OCA\Deck\Db\AssignmentMapper;
|
||||
use OCA\Deck\Db\Board;
|
||||
use OCA\Deck\Db\BoardMapper;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
use OCA\Deck\Db\ChangeHelper;
|
||||
use OCA\Deck\Db\LabelMapper;
|
||||
use OCA\Deck\Db\StackMapper;
|
||||
@@ -58,6 +59,8 @@ class BoardServiceTest extends TestCase {
|
||||
private $boardMapper;
|
||||
/** @var StackMapper */
|
||||
private $stackMapper;
|
||||
/** @var CardMapper */
|
||||
private $cardMapper;
|
||||
/** @var PermissionService */
|
||||
private $permissionService;
|
||||
/** @var NotificationHelper */
|
||||
@@ -85,6 +88,7 @@ class BoardServiceTest extends TestCase {
|
||||
$this->boardMapper = $this->createMock(BoardMapper::class);
|
||||
$this->stackMapper = $this->createMock(StackMapper::class);
|
||||
$this->config = $this->createMock(IConfig::class);
|
||||
$this->cardMapper = $this->createMock(CardMapper::class);
|
||||
$this->labelMapper = $this->createMock(LabelMapper::class);
|
||||
$this->permissionService = $this->createMock(PermissionService::class);
|
||||
$this->notificationHelper = $this->createMock(NotificationHelper::class);
|
||||
@@ -106,6 +110,7 @@ class BoardServiceTest extends TestCase {
|
||||
$this->permissionService,
|
||||
$this->notificationHelper,
|
||||
$this->assignedUsersMapper,
|
||||
$this->cardMapper,
|
||||
$this->userManager,
|
||||
$this->groupManager,
|
||||
$this->activityManager,
|
||||
|
||||
Reference in New Issue
Block a user