From 260beb6b12b8955fbc1e4bf1a4494a51851a819c Mon Sep 17 00:00:00 2001 From: Davide Saurino Date: Sat, 16 Nov 2013 12:51:13 +0100 Subject: Rename Feed: tests added --- .../businesslayer/feedbusinesslayerSpec.coffee | 11 ++++++++++ js/tests/services/persistenceSpec.coffee | 12 +++++++++++ tests/unit/businesslayer/FeedBusinessLayerTest.php | 22 ++++++++++++++++++++ tests/unit/controller/FeedControllerTest.php | 24 ++++++++++++++++++++++ 4 files changed, 69 insertions(+) diff --git a/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee b/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee index 26e5a2973..6061d8767 100644 --- a/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee +++ b/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee @@ -345,3 +345,14 @@ describe 'FeedBusinessLayer', -> jasmine.any(Function)) expect(callback).toHaveBeenCalled() + + it 'should make a rename feed request and disable editing', => + @persistence.renameFeed = jasmine.createSpy('Rename feed') + @FeedModel.add({id: 2, unreadCount:134, url: 'a1', folderId: 3}) + @FeedBusinessLayer.renameFeed(2, "New Title") + + expect(@persistence.renameFeed).toHaveBeenCalledWith(2, "New Title") + expect(@FeedModel.getById(2).editing).toBe(false) + + + diff --git a/js/tests/services/persistenceSpec.coffee b/js/tests/services/persistenceSpec.coffee index 38e02705a..708a68b07 100644 --- a/js/tests/services/persistenceSpec.coffee +++ b/js/tests/services/persistenceSpec.coffee @@ -178,6 +178,18 @@ describe 'Persistence', -> expect(@req.post).toHaveBeenCalledWith('news_feeds_move', params) + it 'create a correct request for renaming a feed', => + params = + data: + feedTitle: "New Feed Title" + routeParams: + feedId: 3 + + @Persistence.renameFeed(params.routeParams.feedId, params.data.feedTitle) + + expect(@req.post).toHaveBeenCalledWith('news_feeds_rename', params) + + it 'shoud send a correct request for marking all items of a feed read', => params = data: diff --git a/tests/unit/businesslayer/FeedBusinessLayerTest.php b/tests/unit/businesslayer/FeedBusinessLayerTest.php index 5e379525d..454a4966e 100644 --- a/tests/unit/businesslayer/FeedBusinessLayerTest.php +++ b/tests/unit/businesslayer/FeedBusinessLayerTest.php @@ -459,6 +459,28 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility { } + public function testRenameFeed(){ + $feedId = 3; + $feedTitle = "New Feed Title"; + $feed = new Feed(); + $feed->setTitle("Feed Title"); + $feed->setId($feedId); + + $this->feedMapper->expects($this->once()) + ->method('find') + ->with($this->equalTo($feedId), $this->equalTo($this->user)) + ->will($this->returnValue($feed)); + + $this->feedMapper->expects($this->once()) + ->method('update') + ->with($this->equalTo($feed)); + + $this->feedBusinessLayer->rename($feedId, $feedTitle, $this->user); + + $this->assertEquals($feedTitle, $feed->getTitle()); + } + + public function testImportArticles(){ $url = 'http://owncloud/nofeed'; diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php index e3204517b..296f87b22 100644 --- a/tests/unit/controller/FeedControllerTest.php +++ b/tests/unit/controller/FeedControllerTest.php @@ -543,6 +543,30 @@ class FeedControllerTest extends ControllerTestUtility { } + public function testRename(){ + $post = array( + 'feedTitle' => "New Feed Title" + ); + $url = array( + 'feedId' => 4 + ); + $this->controller = $this->getPostController($post, $url); + + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); + $this->feedBusinessLayer->expects($this->once()) + ->method('rename') + ->with($this->equalTo($url['feedId']), + $this->equalTo($post['feedTitle']), + $this->equalTo($this->user)); + + $response = $this->controller->rename(); + + $this->assertTrue($response instanceof JSONResponse); + } + + public function testImportArticles() { $feed = new Feed(); -- cgit v1.2.3