Commit 881091d6 authored by Laurent's avatar Laurent
Browse files

hotline #98887 fix record page generate thumbnail button when record id has changed

parent 61482221
Pipeline #8686 passed with stage
in 44 minutes and 36 seconds
- ticket #98887 : Correction du bouton "générer la vignette" sur la page notice lorsque l'id notice est obsolète
\ No newline at end of file
......@@ -42,7 +42,8 @@ class Admin_RecordsController extends ZendAfi_Controller_Action {
$record
->setUrlImage('')
->setUrlVignette('')
->save();
->fetchUrlLocalVignette();
$this->_helper->notify($this->_('Vignette réinitialisée pour "%s"', $record->getTitrePrincipal()));
$this->_redirectToReferer();
}
......
......@@ -133,7 +133,10 @@ class ZendAfi_View_Helper_RenderRecord extends ZendAfi_View_Helper_BaseHelper {
? $this->view->Admin_Button((new Class_Entity())
->setUrl($this->view->url(['module' => 'admin',
'controller' => 'records',
'action' => 'reset-thumbnail']))
'action' => 'reset-thumbnail',
'id' => $this->notice->getId()],
null,
true))
->setText($this->_('Générer'))
->setAttribs(['title' => $this->_('Supprimer et re-générer la vignette de la notice "%s"',
$this->notice->getTitrePrincipal())]))
......
......@@ -55,10 +55,19 @@ abstract class RecordsControllerTestCase extends Admin_AbstractControllerTestCas
}
class RecordsControllerResetThumbnailTest extends RecordsControllerTestCase {
public function setUp() {
parent::setUp();
$this->_http_client
->whenCalled('open_url')
->answers(json_encode(['vignette' => 'http://cache.org/potter_thumb.jpg',
'image' => 'http://cache.org/potter.jpg',
'statut_recherche' => 2]));
$this->_notice
->setUrlImage('http://harrypotter.com/poster.jpg')
->setUrlVignette('http://harrypotter.com/poster.jpg')
......@@ -71,14 +80,16 @@ class RecordsControllerResetThumbnailTest extends RecordsControllerTestCase {
/** @test */
public function urlImageShouldBeEmpty() {
$this->assertEmpty($this->_notice->getUrlImage());
public function urlImageShouldBeNewUrlFromCacheDotOrg() {
$this->assertEquals('http://cache.org/potter.jpg',
$this->_notice->getUrlImage());
}
/** @test */
public function urlThumbnailShouldBeEmpty() {
$this->assertEmpty($this->_notice->getUrlVignette());
public function urlThumbnailShouldBeNewUrlFromCacheDotOrg() {
$this->assertEquals('http://cache.org/potter_thumb.jpg',
$this->_notice->getUrlVignette());
}
......@@ -115,7 +126,7 @@ class RecordsControllerResetAlbumThumbnailTest extends RecordsControllerTestCase
$album->index();
$id = $album->getNoticeId();
$this->dispatch('/admin/records/reset-thumbnail/id/12345', true);
$this->dispatch('/admin/records/reset-thumbnail/id/' . $id, true);
Class_Notice::clearCache();
$this->_notice = Class_Notice::find($id);
......@@ -142,7 +153,7 @@ class RecordsControllerResetAlbumThumbnailTest extends RecordsControllerTestCase
/** @test */
public function responseShouldNotifyRecordUpdated() {
$this->assertFlashMessengerContentContains('Vignette réinitialisée pour "Harry Potter"');
$this->assertFlashMessengerContentContains('Vignette réinitialisée pour "Potter"');
}
}
......
......@@ -777,6 +777,14 @@ class RechercheControllerViewNoticeClefAlphaTest extends RechercheControllerNoti
$this->dispatch('recherche/viewnotice/clef/TESTINGALPHAKEY---101/expressionRecherche/Millenium', true);
}
/** @test */
public function resetThumbnailButtonShouldContainsId345() {
$this->assertXPath('//button[contains(@onclick, "admin/records/reset-thumbnail/id/345")]',
$this->response->getBody());
}
/** @test */
public function retourListeShouldLinkToRechercheSimpleWithHashTagIdNotice() {
$this->assertXPathContentContains('//div/a[@class="retour"][contains(@href, "/recherche/simple/expressionRecherche/Millenium#345")]',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment