public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Added a reader for flash.now, so it's possible to do stuff like 
flash.now[:alert] ||= 'New if not set' (closes #2422) [Caio Chassot]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2747 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
dhh (author)
Wed Oct 26 06:14:10 -0700 2005
commit  07c494ae24b897bfa1d46f741b9ac14d3b480bc2
tree    82631d2a8dd051662c3c4fbb523414d48009aee5
parent  0d52abfd0ea42ba8f9bac996378087be42b93917
...
 
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
8
0
@@ -1,3 +1,8 @@
0
+*SVN*
0
+
0
+* Added a reader for flash.now, so it's possible to do stuff like flash.now[:alert] ||= 'New if not set' #2422 [Caio Chassot]
0
+
0
+
0
 *1.10.2* (October 26th, 2005)
0
 
0
 * Reset template variables after using render_to_string [skaes@web.de]
...
40
41
42
 
 
 
 
43
44
45
...
40
41
42
43
44
45
46
47
48
49
0
@@ -40,6 +40,10 @@ module ActionController #:nodoc:
0
         @flash.discard(k)
0
         v
0
       end
0
+
0
+ def [](k)
0
+ @flash[k]
0
+ end
0
     end
0
     
0
     class FlashHash < Hash
...
9
10
11
 
 
 
12
13
14
...
75
76
77
 
 
78
79
80
81
 
82
83
84
...
9
10
11
12
13
14
15
16
17
...
78
79
80
81
82
83
84
85
86
87
88
89
90
0
@@ -9,6 +9,9 @@ class FlashTest < Test::Unit::TestCase
0
 
0
     def set_flash_now
0
       flash.now["that"] = "hello"
0
+ flash.now["foo"] ||= "bar"
0
+ flash.now["foo"] ||= "err"
0
+ @flashy = flash.now["that"]
0
       @flash_copy = {}.update flash
0
       render :inline => "hello"
0
     end
0
@@ -75,10 +78,13 @@ class FlashTest < Test::Unit::TestCase
0
     @request.action = "set_flash_now"
0
     response = process_request
0
     assert_equal "hello", response.template.assigns["flash_copy"]["that"]
0
+ assert_equal "bar" , response.template.assigns["flash_copy"]["foo"]
0
+ assert_equal "hello", response.template.assigns["flashy"]
0
 
0
     @request.action = "attempt_to_use_flash_now"
0
     first_response = process_request
0
     assert_nil first_response.template.assigns["flash_copy"]["that"]
0
+ assert_nil first_response.template.assigns["flash_copy"]["foo"]
0
     assert_nil first_response.template.assigns["flashy"]
0
   end
0
   

Comments

    No one has commented yet.