diff options
Diffstat (limited to 'src/Wallabag/ApiBundle')
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/WallabagRestController.php | 12 | ||||
-rw-r--r-- | src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php | 18 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 29cab1f4..2633a311 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php | |||
@@ -112,10 +112,14 @@ class WallabagRestController extends FOSRestController | |||
112 | $isArchived = $request->request->get('archive'); | 112 | $isArchived = $request->request->get('archive'); |
113 | $isStarred = $request->request->get('starred'); | 113 | $isStarred = $request->request->get('starred'); |
114 | 114 | ||
115 | $entry = $this->get('wallabag_core.content_proxy')->updateEntry( | 115 | $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($url, $this->getUser()->getId()); |
116 | new Entry($this->getUser()), | 116 | |
117 | $url | 117 | if (false === $entry) { |
118 | ); | 118 | $entry = $this->get('wallabag_core.content_proxy')->updateEntry( |
119 | new Entry($this->getUser()), | ||
120 | $url | ||
121 | ); | ||
122 | } | ||
119 | 123 | ||
120 | $tags = $request->request->get('tags', ''); | 124 | $tags = $request->request->get('tags', ''); |
121 | if (!empty($tags)) { | 125 | if (!empty($tags)) { |
diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php index c264180c..2e78d8b2 100644 --- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php | |||
@@ -166,6 +166,24 @@ class WallabagRestControllerTest extends WallabagApiTestCase | |||
166 | $this->assertCount(1, $content['tags']); | 166 | $this->assertCount(1, $content['tags']); |
167 | } | 167 | } |
168 | 168 | ||
169 | public function testPostSameEntry() | ||
170 | { | ||
171 | $this->client->request('POST', '/api/entries.json', array( | ||
172 | 'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', | ||
173 | 'archive' => '1', | ||
174 | )); | ||
175 | |||
176 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
177 | |||
178 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
179 | |||
180 | $this->assertGreaterThan(0, $content['id']); | ||
181 | $this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']); | ||
182 | $this->assertEquals(true, $content['is_archived']); | ||
183 | $this->assertEquals(false, $content['is_starred']); | ||
184 | $this->assertCount(1, $content['tags']); | ||
185 | } | ||
186 | |||
169 | public function testPostArchivedAndStarredEntry() | 187 | public function testPostArchivedAndStarredEntry() |
170 | { | 188 | { |
171 | $this->client->request('POST', '/api/entries.json', array( | 189 | $this->client->request('POST', '/api/entries.json', array( |