Browse Source

flash message bugfix

Stefan D 11 years ago
parent
commit
a513796fc3

+ 2 - 1
Controller/Component/AjaxComponent.php

@@ -79,6 +79,7 @@ class AjaxComponent extends Component {
 			$_message = $this->Session->read($this->settings['flashKey']);
 			$this->Session->delete($this->settings['flashKey']);
 			$this->Controller->set(compact('_message'));
+			//$this->Controller->set('_serialize', array('_message'));
 		}
 	}
 
@@ -116,7 +117,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']));