Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/Activity/ActivityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ private function createEvent($objectType, $entity, $subject, $additionalParams =

if ($subject === self::SUBJECT_CARD_UPDATE_DESCRIPTION && isset($params['after'])) {
$newContent = $params['after'];
unset($params['before'], $params['after'], $params['card']['description']);
unset($params['before'], $params['after'], $params['card']['description'], $params['card']['descriptionPrev']);

$params['after'] = mb_substr($newContent, 0, self::SHORTENED_DESCRIPTION_MAX_LENGTH);
if (mb_strlen($newContent) > self::SHORTENED_DESCRIPTION_MAX_LENGTH) {
Expand Down Expand Up @@ -520,6 +520,13 @@ private function findDetailsForCard($cardId, $subject = null) {
$card = $this->cardMapper->find($cardId);
$stack = $this->stackMapper->find($card->getStackId());
$board = $this->boardMapper->find($stack->getBoardId());

// Reduce the data size in activity table
$boardArray = [
'id' => $board->getId(),
'title' => $board->getTitle(),
];

if ($subject !== self::SUBJECT_CARD_UPDATE_DESCRIPTION) {
$card = [
'id' => $card->getId(),
Expand All @@ -530,7 +537,7 @@ private function findDetailsForCard($cardId, $subject = null) {
return [
'card' => $card,
'stack' => $stack,
'board' => $board
'board' => $boardArray,
];
}

Expand Down
49 changes: 30 additions & 19 deletions tests/unit/Activity/ActivityManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ public function testCreateEvent() {
}

public function testCreateEventDescription() {
$board = new Board();
$board->setId(123);
$board->setTitle('');
$boardData = [
'id' => 123,
'title' => ''
];
$board = Board::fromRow($boardData);
$this->boardMapper->expects(self::once())
->method('find')
->willReturn($board);
Expand All @@ -173,11 +175,11 @@ public function testCreateEventDescription() {
->willReturn($stack);

$expectedCard = $card->jsonSerialize();
unset($expectedCard['description']);
unset($expectedCard['description'], $expectedCard['descriptionPrev']);
$event = $this->expectEventCreation(ActivityManager::SUBJECT_CARD_UPDATE_DESCRIPTION, [
'card' => $expectedCard,
'stack' => $stack->jsonSerialize(),
'board' => $board->jsonSerialize(),
'board' => $boardData,
'diff' => true,
'author' => 'admin',
'after' => str_repeat('C', 2000),
Expand All @@ -196,9 +198,11 @@ public function testCreateEventDescription() {
}

public function testCreateEventLongDescription() {
$board = new Board();
$board->setId(123);
$board->setTitle('');
$boardData = [
'id' => 123,
'title' => ''
];
$board = Board::fromRow($boardData);
$this->boardMapper->expects(self::once())
->method('find')
->willReturn($board);
Expand All @@ -219,11 +223,11 @@ public function testCreateEventLongDescription() {
->willReturn($stack);

$expectedCard = $card->jsonSerialize();
unset($expectedCard['description']);
unset($expectedCard['description'], $expectedCard['descriptionPrev']);
$event = $this->expectEventCreation(ActivityManager::SUBJECT_CARD_UPDATE_DESCRIPTION, [
'card' => $expectedCard,
'stack' => $stack->jsonSerialize(),
'board' => $board->jsonSerialize(),
'board' => $boardData,
'diff' => true,
'author' => 'admin',
'after' => str_repeat('C', 2000) . '...',
Expand All @@ -242,10 +246,11 @@ public function testCreateEventLongDescription() {
}

public function testCreateEventLabel() {
$board = Board::fromRow([
$boardData = [
'id' => 123,
'title' => 'My board'
]);
];
$board = Board::fromRow($boardData);
$this->boardMapper->expects(self::once())
->method('find')
->willReturn($board);
Expand All @@ -272,7 +277,7 @@ public function testCreateEventLabel() {
'archived' => false,
],
'stack' => $stack,
'board' => $board,
'board' => $boardData,
'author' => 'admin',
]);

Expand Down Expand Up @@ -426,8 +431,11 @@ public function testFindDetailsForCard() {
$stack = new Stack();
$stack->setId(123);
$stack->setBoardId(999);
$board = new Board();
$board->setId(999);
$boardData = [
'id' => 999,
'title' => 'Title',
];
$board = Board::fromRow($boardData);
$this->cardMapper->expects(self::once())
->method('find')
->with(555)
Expand All @@ -441,7 +449,7 @@ public function testFindDetailsForCard() {
->willReturn($board);
$this->assertEquals([
'stack' => $stack,
'board' => $board,
'board' => $boardData,
'card' => [
'id' => $card->getId(),
'title' => $card->getTitle(),
Expand All @@ -460,8 +468,11 @@ public function testFindDetailsForAttachment() {
$stack = new Stack();
$stack->setId(123);
$stack->setBoardId(999);
$board = new Board();
$board->setId(999);
$boardData = [
'id' => 999,
'title' => 'Title',
];
$board = Board::fromRow($boardData);
$this->cardMapper->expects(self::once())
->method('find')
->with(555)
Expand All @@ -475,7 +486,7 @@ public function testFindDetailsForAttachment() {
->willReturn($board);
$this->assertEquals([
'stack' => $stack,
'board' => $board,
'board' => $boardData,
'card' => [
'id' => $card->getId(),
'title' => $card->getTitle(),
Expand Down
Loading