Browse Source

Merge pull request #130 from php-engineer/master-ajax-component

flash message bugfix
Mark S. 11 years ago
parent
commit
9c070fe258

+ 1 - 1
Controller/Component/AjaxComponent.php

@@ -116,7 +116,7 @@ class AjaxComponent extends Component {
 
 		$this->Controller->autoRender = true;
 		$this->Controller->set('_redirect', compact('url', 'status', 'exit'));
-		$serializeKeys = array('_redirect');
+		$serializeKeys = array('_redirect', '_message');
 		if (!empty($this->Controller->viewVars['_serialize'])) {
 			$serializeKeys = array_merge($serializeKeys, $this->Controller->viewVars['_serialize']);
 		}

+ 4 - 0
Test/Case/Controller/Component/AjaxComponentTest.php

@@ -173,6 +173,10 @@ class AjaxComponentTest extends CakeTestCase {
 		);
 		$this->assertEquals($expected, $this->Controller->viewVars['_redirect']);
 
+		$this->Controller->set(array('_message' => 'test'));
+		$this->Controller->redirect('/');
+		$this->assertArrayHasKey('_message', $this->Controller->viewVars);
+
 		$this->assertNotEmpty($this->Controller->viewVars);
 		$this->assertNotEmpty($this->Controller->viewVars['_serialize']);
 		$this->assertTrue(in_array('content', $this->Controller->viewVars['_serialize']));