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 { ...@@ -42,7 +42,8 @@ class Admin_RecordsController extends ZendAfi_Controller_Action {
$record $record
->setUrlImage('') ->setUrlImage('')
->setUrlVignette('') ->setUrlVignette('')
->save(); ->fetchUrlLocalVignette();
$this->_helper->notify($this->_('Vignette réinitialisée pour "%s"', $record->getTitrePrincipal())); $this->_helper->notify($this->_('Vignette réinitialisée pour "%s"', $record->getTitrePrincipal()));
$this->_redirectToReferer(); $this->_redirectToReferer();
} }
......
...@@ -133,7 +133,10 @@ class ZendAfi_View_Helper_RenderRecord extends ZendAfi_View_Helper_BaseHelper { ...@@ -133,7 +133,10 @@ class ZendAfi_View_Helper_RenderRecord extends ZendAfi_View_Helper_BaseHelper {
? $this->view->Admin_Button((new Class_Entity()) ? $this->view->Admin_Button((new Class_Entity())
->setUrl($this->view->url(['module' => 'admin', ->setUrl($this->view->url(['module' => 'admin',
'controller' => 'records', 'controller' => 'records',
'action' => 'reset-thumbnail'])) 'action' => 'reset-thumbnail',
'id' => $this->notice->getId()],
null,
true))
->setText($this->_('Générer')) ->setText($this->_('Générer'))
->setAttribs(['title' => $this->_('Supprimer et re-générer la vignette de la notice "%s"', ->setAttribs(['title' => $this->_('Supprimer et re-générer la vignette de la notice "%s"',
$this->notice->getTitrePrincipal())])) $this->notice->getTitrePrincipal())]))
......
...@@ -55,10 +55,19 @@ abstract class RecordsControllerTestCase extends Admin_AbstractControllerTestCas ...@@ -55,10 +55,19 @@ abstract class RecordsControllerTestCase extends Admin_AbstractControllerTestCas
} }
class RecordsControllerResetThumbnailTest extends RecordsControllerTestCase { class RecordsControllerResetThumbnailTest extends RecordsControllerTestCase {
public function setUp() { public function setUp() {
parent::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 $this->_notice
->setUrlImage('http://harrypotter.com/poster.jpg') ->setUrlImage('http://harrypotter.com/poster.jpg')
->setUrlVignette('http://harrypotter.com/poster.jpg') ->setUrlVignette('http://harrypotter.com/poster.jpg')
...@@ -71,14 +80,16 @@ class RecordsControllerResetThumbnailTest extends RecordsControllerTestCase { ...@@ -71,14 +80,16 @@ class RecordsControllerResetThumbnailTest extends RecordsControllerTestCase {
/** @test */ /** @test */
public function urlImageShouldBeEmpty() { public function urlImageShouldBeNewUrlFromCacheDotOrg() {
$this->assertEmpty($this->_notice->getUrlImage()); $this->assertEquals('http://cache.org/potter.jpg',
$this->_notice->getUrlImage());
} }
/** @test */ /** @test */
public function urlThumbnailShouldBeEmpty() { public function urlThumbnailShouldBeNewUrlFromCacheDotOrg() {
$this->assertEmpty($this->_notice->getUrlVignette()); $this->assertEquals('http://cache.org/potter_thumb.jpg',
$this->_notice->getUrlVignette());
} }
...@@ -115,7 +126,7 @@ class RecordsControllerResetAlbumThumbnailTest extends RecordsControllerTestCase ...@@ -115,7 +126,7 @@ class RecordsControllerResetAlbumThumbnailTest extends RecordsControllerTestCase
$album->index(); $album->index();
$id = $album->getNoticeId(); $id = $album->getNoticeId();
$this->dispatch('/admin/records/reset-thumbnail/id/12345', true); $this->dispatch('/admin/records/reset-thumbnail/id/' . $id, true);
Class_Notice::clearCache(); Class_Notice::clearCache();
$this->_notice = Class_Notice::find($id); $this->_notice = Class_Notice::find($id);
...@@ -142,7 +153,7 @@ class RecordsControllerResetAlbumThumbnailTest extends RecordsControllerTestCase ...@@ -142,7 +153,7 @@ class RecordsControllerResetAlbumThumbnailTest extends RecordsControllerTestCase
/** @test */ /** @test */
public function responseShouldNotifyRecordUpdated() { 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 ...@@ -777,6 +777,14 @@ class RechercheControllerViewNoticeClefAlphaTest extends RechercheControllerNoti
$this->dispatch('recherche/viewnotice/clef/TESTINGALPHAKEY---101/expressionRecherche/Millenium', true); $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 */ /** @test */
public function retourListeShouldLinkToRechercheSimpleWithHashTagIdNotice() { public function retourListeShouldLinkToRechercheSimpleWithHashTagIdNotice() {
$this->assertXPathContentContains('//div/a[@class="retour"][contains(@href, "/recherche/simple/expressionRecherche/Millenium#345")]', $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