Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 2747

Show
Ignore:
Timestamp:
10/26/05 13:14:10 (3 years ago)
Author:
david
Message:

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]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r2737 r2747  
     1*SVN* 
     2 
     3* Added a reader for flash.now, so it's possible to do stuff like flash.now[:alert] ||= 'New if not set' #2422 [Caio Chassot] 
     4 
     5 
    16*1.10.2* (October 26th, 2005) 
    27 
  • trunk/actionpack/lib/action_controller/flash.rb

    r2722 r2747  
    4040        @flash.discard(k) 
    4141        v 
     42      end 
     43       
     44      def [](k) 
     45        @flash[k] 
    4246      end 
    4347    end 
  • trunk/actionpack/test/controller/flash_test.rb

    r1915 r2747  
    1010    def set_flash_now 
    1111      flash.now["that"] = "hello" 
     12      flash.now["foo"] ||= "bar" 
     13      flash.now["foo"] ||= "err" 
     14      @flashy = flash.now["that"] 
    1215      @flash_copy = {}.update flash 
    1316      render :inline => "hello" 
     
    7679    response = process_request 
    7780    assert_equal "hello", response.template.assigns["flash_copy"]["that"] 
     81    assert_equal "bar"  , response.template.assigns["flash_copy"]["foo"] 
     82    assert_equal "hello", response.template.assigns["flashy"] 
    7883 
    7984    @request.action = "attempt_to_use_flash_now" 
    8085    first_response = process_request 
    8186    assert_nil first_response.template.assigns["flash_copy"]["that"] 
     87    assert_nil first_response.template.assigns["flash_copy"]["foo"] 
    8288    assert_nil first_response.template.assigns["flashy"] 
    8389  end