When requesting a permalink to an invalid file redirect
We need to do the redirect to update address bar.
This commit is contained in:
parent
54f79a28f6
commit
cc9b36131c
|
@ -143,15 +143,14 @@ class ViewController extends Controller {
|
||||||
* @param string $dir
|
* @param string $dir
|
||||||
* @param string $view
|
* @param string $view
|
||||||
* @param string $fileid
|
* @param string $fileid
|
||||||
* @return TemplateResponse
|
* @return TemplateResponse|RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function index($dir = '', $view = '', $fileid = null) {
|
public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false) {
|
||||||
$fileNotFound = false;
|
|
||||||
if ($fileid !== null) {
|
if ($fileid !== null) {
|
||||||
try {
|
try {
|
||||||
return $this->showFile($fileid);
|
return $this->showFile($fileid);
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
$fileNotFound = true;
|
return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -348,10 +348,14 @@ class ViewControllerTest extends TestCase {
|
||||||
->with(123)
|
->with(123)
|
||||||
->will($this->returnValue([]));
|
->will($this->returnValue([]));
|
||||||
|
|
||||||
|
$this->urlGenerator->expects($this->once())
|
||||||
|
->method('linkToRoute')
|
||||||
|
->with('files.view.index', ['fileNotFound' => true])
|
||||||
|
->willReturn('redirect.url');
|
||||||
|
|
||||||
$response = $this->viewController->index('MyDir', 'MyView', '123');
|
$response = $this->viewController->index('MyDir', 'MyView', '123');
|
||||||
$this->assertInstanceOf('OCP\AppFramework\Http\TemplateResponse', $response);
|
$this->assertInstanceOf('OCP\AppFramework\Http\RedirectResponse', $response);
|
||||||
$params = $response->getParams();
|
$this->assertEquals('redirect.url', $response->getRedirectURL());
|
||||||
$this->assertEquals(1, $params['fileNotFound']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testShowFileRouteWithTrashedFile() {
|
public function testShowFileRouteWithTrashedFile() {
|
||||||
|
|
Loading…
Reference in New Issue