$em->flush();
}
- $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'));
+ $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'), '', true);
return $this->redirect($redirectUrl);
}
}
/**
- * @param string $url URL to redirect
- * @param string $fallback Fallback URL if $url is null
+ * @param string $url URL to redirect
+ * @param string $fallback Fallback URL if $url is null
+ * @param bool $ignoreActionMarkAsRead Ignore configured action when mark as read
*
* @return string
*/
- public function to($url, $fallback = '')
+ public function to($url, $fallback = '', $ignoreActionMarkAsRead = false)
{
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
return $url;
}
- if (Config::REDIRECT_TO_HOMEPAGE === $user->getConfig()->getActionMarkAsRead()) {
+ if (!$ignoreActionMarkAsRead &&
+ Config::REDIRECT_TO_HOMEPAGE === $user->getConfig()->getActionMarkAsRead()) {
return $this->router->generate('homepage');
}
->getRepository('WallabagCoreBundle:Tag')
->findOneByEntryAndTagLabel($entry, $this->tagName);
+ // We make a first request to set an history and test redirection after tag deletion
+ $client->request('GET', '/view/'.$entry->getId());
+ $entryUri = $client->getRequest()->getUri();
$client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertEquals($entryUri, $client->getResponse()->getTargetUrl());
$this->assertNotContains($this->tagName, $entry->getTags());
$this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl);
}
+
+ public function testUserForRedirectWithIgnoreActionMarkAsRead()
+ {
+ $this->token->getUser()->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE);
+
+ $redirectUrl = $this->redirect->to('/unread/list', '', true);
+
+ $this->assertEquals('/unread/list', $redirectUrl);
+ }
+
+ public function testUserForRedirectNullWithFallbackWithIgnoreActionMarkAsRead()
+ {
+ $this->token->getUser()->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE);
+
+ $redirectUrl = $this->redirect->to(null, 'fallback', true);
+
+ $this->assertEquals('fallback', $redirectUrl);
+ }
}