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

Ticket #7372: fix_indifferent_access_for_session_batch_assignment.diff

File fix_indifferent_access_for_session_batch_assignment.diff, 1.7 kB (added by manfred, 2 years ago)
  • test/controller/test_test.rb

    old new  
    1313      session[:symbol] = 'it works' 
    1414      render :text => 'Success' 
    1515    end 
     16     
     17    def set_from_session 
     18      @string = session['string'] 
     19      @symbol = session[:symbol] 
     20      render :nothing => true 
     21    end 
    1622 
    1723    def render_raw_post 
    1824      raise Test::Unit::AssertionFailedError, "#raw_post is blank" if request.raw_post.blank? 
     
    124130    assert_equal 'it works', session['symbol'], "Test session hash should allow indifferent access" 
    125131    assert_equal 'it works', session[:symbol], "Test session hash should allow indifferent access" 
    126132  end 
     133   
     134  def test_process_with_session_defined 
     135    process :set_from_session, {}, {:symbol => 'Symbol', 'string' => 'String'} 
     136    assert_equal 'Symbol', assigns(:symbol) 
     137    assert_equal 'String', assigns(:string) 
     138    assert_equal 'Symbol', session['symbol'] 
     139    assert_equal 'String', session[:string] 
     140  end 
    127141 
    128142  def test_process_with_request_uri_with_no_params 
    129143    process :test_uri 
  • lib/action_controller/test_process.rb

    old new  
    283283 
    284284    def initialize(attributes = nil) 
    285285      @session_id = '' 
    286       @attributes = attributes 
     286      unless attributes.nil? 
     287        attributes.each { |k,v| self[k] = v } 
     288      else 
     289        @attributes = nil 
     290      end 
    287291      @saved_attributes = nil 
    288292    end 
    289293