diff options
-rw-r--r-- | appinfo/routes.php | 4 | ||||
-rw-r--r-- | bl/itembl.php | 7 | ||||
-rw-r--r-- | controller/itemcontroller.php | 5 | ||||
-rw-r--r-- | js/app/services/persistence.coffee | 10 | ||||
-rw-r--r-- | js/public/app.js | 10 | ||||
-rw-r--r-- | js/tests/services/persistenceSpec.coffee | 10 | ||||
-rw-r--r-- | templates/part.settings.php | 3 | ||||
-rw-r--r-- | tests/bl/ItemBlTest.php | 14 | ||||
-rw-r--r-- | tests/controller/ItemControllerTest.php | 18 |
9 files changed, 52 insertions, 29 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php index ac0ecb315..4397b4750 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -151,13 +151,13 @@ $this->create('news_items_unread', '/items/{itemId}/unread')->post()->action( } ); -$this->create('news_items_star', '/items/{itemId}/star')->post()->action( +$this->create('news_items_star', '/items/{feedId}/{guidHash}/star')->post()->action( function($params){ App::main('ItemController', 'star', $params, new DIContainer()); } ); -$this->create('news_items_unstar', '/items/{itemId}/unstar')->post()->action( +$this->create('news_items_unstar', '/items/{feedId}/{guidHash}/unstar')->post()->action( function($params){ App::main('ItemController', 'unstar', $params, new DIContainer()); } diff --git a/bl/itembl.php b/bl/itembl.php index 3c8649201..ee87d373a 100644 --- a/bl/itembl.php +++ b/bl/itembl.php @@ -90,10 +90,11 @@ class ItemBl extends Bl { } - public function star($itemId, $isStarred, $userId){ - $item = $this->find($itemId, $userId); + public function star($feedId, $guidHash, $isStarred, $userId){ + // FIXME: this can throw two possible exceptions + $item = $this->mapper->findByGuidHash($feedId, $guidHash, $userId); if($isStarred){ - $item->setStarred(); + $item->setStarred(); } else { $item->setUnstarred(); } diff --git a/controller/itemcontroller.php b/controller/itemcontroller.php index 2c00fb1bd..2a8aa6725 100644 --- a/controller/itemcontroller.php +++ b/controller/itemcontroller.php @@ -95,9 +95,10 @@ class ItemController extends Controller { private function setStarred($isStarred){ $userId = $this->api->getUserId(); - $itemId = (int) $this->params('itemId'); + $feedId = (int) $this->params('feedId'); + $guidHash = $this->params('guidHash'); - $this->itemBl->star($itemId, $isStarred, $userId); + $this->itemBl->star($feedId, $guidHash, $isStarred, $userId); } /** diff --git a/js/app/services/persistence.coffee b/js/app/services/persistence.coffee index 24b371b54..41aa13722 100644 --- a/js/app/services/persistence.coffee +++ b/js/app/services/persistence.coffee @@ -81,25 +81,27 @@ angular.module('News').factory '_Persistence', -> @_request.get 'news_items_starred', params - starItem: (itemId) -> + starItem: (feedId, guidHash) -> ### Stars an item ### params = routeParams: - itemId: itemId + feedId: feedId + guidHash: guidHash @_request.post 'news_items_star', params - unstarItem: (itemId) -> + unstarItem: (feedId, guidHash) -> ### Unstars an item ### params = routeParams: - itemId: itemId + feedId: feedId + guidHash: guidHash @_request.post 'news_items_unstar', params diff --git a/js/public/app.js b/js/public/app.js index e5b6e3cab..06cbb6e3e 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -1122,7 +1122,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return this._request.get('news_items_starred', params); }; - Persistence.prototype.starItem = function(itemId) { + Persistence.prototype.starItem = function(feedId, guidHash) { /* Stars an item */ @@ -1130,13 +1130,14 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. var params; params = { routeParams: { - itemId: itemId + feedId: feedId, + guidHash: guidHash } }; return this._request.post('news_items_star', params); }; - Persistence.prototype.unstarItem = function(itemId) { + Persistence.prototype.unstarItem = function(feedId, guidHash) { /* Unstars an item */ @@ -1144,7 +1145,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. var params; params = { routeParams: { - itemId: itemId + feedId: feedId, + guidHash: guidHash } }; return this._request.post('news_items_unstar', params); diff --git a/js/tests/services/persistenceSpec.coffee b/js/tests/services/persistenceSpec.coffee index 091fcd60c..dc36661a4 100644 --- a/js/tests/services/persistenceSpec.coffee +++ b/js/tests/services/persistenceSpec.coffee @@ -101,10 +101,11 @@ describe '_Persistence', -> it 'send a correct star item request', => params = routeParams: - itemId: 2 + feedId: 2 + guidHash: 'dfdfdf' pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope) - pers.starItem(params.routeParams.itemId) + pers.starItem(params.routeParams.feedId, params.routeParams.guidHash) expect(@req.post).toHaveBeenCalledWith('news_items_star', params) @@ -112,10 +113,11 @@ describe '_Persistence', -> it 'send a correct unstar item request', => params = routeParams: - itemId: 2 + feedId: 2 + guidHash: 'dfdfdf' pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope) - pers.unstarItem(params.routeParams.itemId) + pers.unstarItem(params.routeParams.feedId, params.routeParams.guidHash) expect(@req.post).toHaveBeenCalledWith('news_items_unstar', params) diff --git a/templates/part.settings.php b/templates/part.settings.php index b5860124d..4fd963e8a 100644 --- a/templates/part.settings.php +++ b/templates/part.settings.php @@ -1,7 +1,8 @@ <fieldset class="personalblock"> <legend><strong><?php p($l->t('Import / Export OPML')); ?></strong></legend> <input type="file" id="opml-upload" name="files[]" read-file/> - <button title="<?php p($l->t('Import')); ?>" forward-click="{selector:'#opml-upload'}"> + <button title="<?php p($l->t('Import')); ?>" + oc-forward-click="{selector:'#opml-upload'}"> <?php p($l->t('Import')); ?> </button> <button ng-disabled="feeds.length==0" title="<?php p($l->t('Export')); ?>" diff --git a/tests/bl/ItemBlTest.php b/tests/bl/ItemBlTest.php index 225435b7d..dc8f46a2c 100644 --- a/tests/bl/ItemBlTest.php +++ b/tests/bl/ItemBlTest.php @@ -187,21 +187,25 @@ class ItemBlTest extends \OCA\AppFramework\Utility\TestUtility { public function testStar(){ - $itemId = 3; + $feedId = 3; + $guidHash = md5('hihi'); + $item = new Item(); $item->setStatus(128); - $item->setId($itemId); + $item->setId($feedId); $this->mapper->expects($this->once()) - ->method('find') - ->with($this->equalTo($itemId), $this->equalTo($this->user)) + ->method('findByGuidHash') + ->with($this->equalTo($feedId), + $this->equalTo($guidHash), + $this->equalTo($this->user)) ->will($this->returnValue($item)); $this->mapper->expects($this->once()) ->method('update') ->with($this->equalTo($item)); - $this->bl->star($itemId, false, $this->user); + $this->bl->star($feedId, $guidHash, false, $this->user); $this->assertTrue($item->isUnstarred()); } diff --git a/tests/controller/ItemControllerTest.php b/tests/controller/ItemControllerTest.php index 3ab3de145..6ec73f8b8 100644 --- a/tests/controller/ItemControllerTest.php +++ b/tests/controller/ItemControllerTest.php @@ -145,7 +145,8 @@ class ItemControllerTest extends ControllerTestUtility { public function testStar(){ $url = array( - 'itemId' => 4 + 'feedId' => 4, + 'guidHash' => md5('test') ); $this->controller = $this->getPostController(array(), $url); @@ -154,7 +155,11 @@ class ItemControllerTest extends ControllerTestUtility { ->will($this->returnValue($this->user)); $this->bl->expects($this->once()) ->method('star') - ->with($url['itemId'], true, $this->user); + ->with( + $this->equalTo($url['feedId']), + $this->equalTo($url['guidHash']), + $this->equalTo(true), + $this->equalTo($this->user)); $this->controller->star(); } @@ -162,7 +167,8 @@ class ItemControllerTest extends ControllerTestUtility { public function testUnstar(){ $url = array( - 'itemId' => 4 + 'feedId' => 4, + 'guidHash' => md5('test') ); $this->controller = $this->getPostController(array(), $url); @@ -171,7 +177,11 @@ class ItemControllerTest extends ControllerTestUtility { ->will($this->returnValue($this->user)); $this->bl->expects($this->once()) ->method('star') - ->with($url['itemId'], false, $this->user); + ->with( + $this->equalTo($url['feedId']), + $this->equalTo($url['guidHash']), + $this->equalTo(false), + $this->equalTo($this->user)); $this->controller->unstar(); } |