Skip to content

Commit

Permalink
Feed: Fix rename moving file
Browse files Browse the repository at this point in the history
Issue #1181

Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
  • Loading branch information
SMillerDev committed Feb 23, 2021
1 parent 302a6cb commit a68957b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,7 @@ The format is almost based on [Keep a Changelog](https://keepachangelog.com/en/1
### Fixed
- Item list throwing error for folder and "all items"
- Articles with high IDs can be placed lower than articles with low IDs (#1147)
- Feeds are accidentally moved on rename

## [15.3.2] - 2021-02-10
No changes compared to RC2
Expand Down
8 changes: 5 additions & 3 deletions lib/Controller/FeedController.php
Expand Up @@ -335,7 +335,7 @@ public function patch(
?bool $fullTextEnabled = null,
?int $updateMode = null,
?int $ordering = null,
?int $folderId = null,
?int $folderId = -1,
?string $title = null
) {
try {
Expand All @@ -344,8 +344,10 @@ public function patch(
return $this->error($ex, Http::STATUS_NOT_FOUND);
}

$fId = $folderId === 0 ? null : $folderId;
$feed->setFolderId($fId);
if ($folderId !== -1) {
$fId = $folderId === 0 ? null : $folderId;
$feed->setFolderId($fId);
}
if ($pinned !== null) {
$feed->setPinned($pinned);
}
Expand Down
47 changes: 45 additions & 2 deletions tests/Unit/Controller/FeedControllerTest.php
Expand Up @@ -632,13 +632,56 @@ public function testRestoreDoesNotExist()
}

public function testPatch()
{
$feed = $this->getMockBuilder(Feed::class)
->getMock();

$feed->expects($this->never())
->method('setFolderId');

$feed->expects($this->once())
->method('setPinned')
->with(true);

$feed->expects($this->once())
->method('setFullTextEnabled')
->with(false);


$feed->expects($this->once())
->method('setUpdateMode')
->with(1);


$feed->expects($this->never())
->method('setOrdering')
->with(true);


$feed->expects($this->never())
->method('setTitle')
->with(true);

$this->feedService->expects($this->once())
->method('find')
->with($this->uid, 4)
->will($this->returnValue($feed));

$this->feedService->expects($this->once())
->method('update')
->with($this->uid, $feed);

$this->class->patch(4, true, false, 1);
}

public function testPatchFolder()
{
$feed = $this->getMockBuilder(Feed::class)
->getMock();

$feed->expects($this->once())
->method('setFolderId')
->with(null);
->with(5);

$feed->expects($this->once())
->method('setPinned')
Expand Down Expand Up @@ -672,7 +715,7 @@ public function testPatch()
->method('update')
->with($this->uid, $feed);

$this->class->patch(4, true, false, 1);
$this->class->patch(4, true, false, 1, null, 5);
}

public function testPatchDoesNotExist()
Expand Down

0 comments on commit a68957b

Please sign in to comment.