Merge pull request #9972 from chinpei215/2.x-flash-helper

Fix FlashHelper::render() cannot render `default` messages
This commit is contained in:
Mark Story 2017-01-05 09:30:29 -05:00 committed by GitHub
commit f62d2a84ea
2 changed files with 19 additions and 0 deletions

View file

@ -76,6 +76,12 @@ class FlashHelperTest extends CakeTestCase {
'message' => 'Recorded',
'element' => 'flash_classy',
'params' => array()
),
'default' => array(
'key' => 'default',
'message' => 'Default',
'element' => 'default',
'params' => array()
)
)
));
@ -154,4 +160,13 @@ class FlashHelperTest extends CakeTestCase {
$expected = 'this is the plugin element';
$this->assertContains($expected, $result);
}
/**
* Test that the default element fallbacks to the Flash/default element.
*/
public function testFlashFallback() {
$result = $this->Flash->render('default');
$expected = '<div class="message">Default</div>';
$this->assertContains($expected, $result);
}
}

View file

@ -86,6 +86,10 @@ class FlashHelper extends AppHelper {
CakeSession::delete("Message.$key");
$flash['key'] = $key;
if ($flash['element'] === 'default') {
$flash['element'] = 'Flash/default';
}
return $this->_View->element($flash['element'], $flash);
}
}