File tree Expand file tree Collapse file tree 4 files changed +24
-3
lines changed
activeweb-testing/src/test
activeweb/src/main/java/org/javalite/activeweb Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -72,4 +72,13 @@ public void flashByName(){
72
72
}
73
73
74
74
75
+
76
+ @ POST
77
+ public void save3 (){
78
+ flash ();
79
+ respond ("ok" ); // we do not check this output
80
+ }
81
+
82
+ public void anonymous (){
83
+ }
75
84
}
Original file line number Diff line number Diff line change @@ -84,7 +84,6 @@ public void shouldRenderFlashWithNestedPartial(){
84
84
a (responseContent ()).shouldBeEqual ("<div class=\" warning\" >hi, there!</div>" );
85
85
}
86
86
87
-
88
87
@ Test
89
88
public void shouldRenderFlashByName (){
90
89
controller ("flashing" ).integrateViews ().post ("save1" );
@@ -96,10 +95,17 @@ public void shouldRenderFlashByName(){
96
95
controller ("flashing" ).integrateViews ().post ("save2" );
97
96
controller ("flashing" ).integrateViews ().get ("flash_by_name" );
98
97
99
- System .out .println (responseContent ());
100
98
a (responseContent ()).shouldContain ("This is an error: hi" );
101
99
controller ("flashing" ).integrateViews ().get ("flash_by_name" );
102
100
a (blank (responseContent ())).shouldBeTrue ();
103
101
}
104
102
103
+ @ Test
104
+ public void shouldRenderAnonymousFlash (){
105
+ controller ("flashing" ).integrateViews ().post ("save3" );
106
+ controller ("flashing" ).integrateViews ().get ("anonymous" );
107
+ a (responseContent ()).shouldContain ("Hello, anonymous flash!" );
108
+ controller ("flashing" ).integrateViews ().get ("anonymous" );
109
+ a (responseContent ()).shouldNotContain ("Hello, anonymous flash!" );
110
+ }
105
111
}
Original file line number Diff line number Diff line change
1
+ <@flash >Hello, anonymous flash!</@flash >
Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ protected void view(Object ... values){
123
123
* @param values values to flash.
124
124
*/
125
125
protected void flash (Map values ){
126
+ checkFlasher ();
126
127
for (Object key :values .keySet () ){
127
128
flash (key .toString (), values .get (key ));
128
129
}
@@ -169,10 +170,14 @@ protected void flash(String name){
169
170
*/
170
171
@ SuppressWarnings ("unchecked" )
171
172
protected void flash (String name , Object value ) {
173
+ checkFlasher ();
174
+ ((Map ) session ().get ("flasher" )).put (name , value );
175
+ }
176
+
177
+ private void checkFlasher (){
172
178
if (session ().get ("flasher" ) == null ) {
173
179
session ().put ("flasher" , new HashMap ());
174
180
}
175
- ((Map ) session ().get ("flasher" )).put (name , value );
176
181
}
177
182
178
183
public class HttpBuilder {
You can’t perform that action at this time.
0 commit comments