diff options
author | Sean Molenaar <sean@seanmolenaar.eu> | 2021-02-20 14:02:35 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2021-02-23 15:06:02 +0100 |
commit | 4e4108aaf80e2e49b4ca217b56065c49cf7347f4 (patch) | |
tree | c668f26cee4d4bca3481ce2361d8d705eba1c596 | |
parent | 88783899859b3e149cc034bd01893c1c9e3cc62e (diff) |
Feed: Fix rename moving file
Issue #1181
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/Controller/FeedController.php | 8 | ||||
-rw-r--r-- | tests/Unit/Controller/FeedControllerTest.php | 47 |
3 files changed, 51 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c791d6534..c03e2e62f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/Controller/FeedController.php b/lib/Controller/FeedController.php index c80a5c327..fd041ea08 100644 --- a/lib/Controller/FeedController.php +++ b/lib/Controller/FeedController.php @@ -335,7 +335,7 @@ class FeedController extends Controller ?bool $fullTextEnabled = null, ?int $updateMode = null, ?int $ordering = null, - ?int $folderId = null, + ?int $folderId = -1, ?string $title = null ) { try { @@ -344,8 +344,10 @@ class FeedController extends Controller 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); } diff --git a/tests/Unit/Controller/FeedControllerTest.php b/tests/Unit/Controller/FeedControllerTest.php index cf7bc501e..fde821088 100644 --- a/tests/Unit/Controller/FeedControllerTest.php +++ b/tests/Unit/Controller/FeedControllerTest.php @@ -636,9 +636,52 @@ class FeedControllerTest extends TestCase $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') @@ -672,7 +715,7 @@ class FeedControllerTest extends TestCase ->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() |