From 4e4108aaf80e2e49b4ca217b56065c49cf7347f4 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sat, 20 Feb 2021 14:02:35 +0100 Subject: Feed: Fix rename moving file Issue #1181 Signed-off-by: Sean Molenaar --- CHANGELOG.md | 1 + lib/Controller/FeedController.php | 8 +++-- 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 @@ -632,13 +632,56 @@ class FeedControllerTest extends TestCase } 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') @@ -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() -- cgit v1.2.3