Skip to content
  • Andrew White's avatar
    e864ff72
    Add backward compatibility for testing cookies · e864ff72
    Andrew White authored
    This commit restores the ability to assign cookies for testing via
    @request.env['HTTP_COOKIE'] and @request.cookies, e.g:
    
        @request.env['HTTP_COOKIE'] = 'user_name=david'
        get :index
        assert_equal 'david', cookies[:user_name]
    
    and
    
        @request.cookies[:user_name] = 'david'
        get :index
        assert_equal 'david', cookies[:user_name]
    
    Assigning via cookies[] is the preferred method and will take precedence
    over the other two methods. This is so that cookies set in controller
    actions have precedence and are carried over between calls to get, post, etc.
    e864ff72
    Add backward compatibility for testing cookies
    Andrew White authored
    This commit restores the ability to assign cookies for testing via
    @request.env['HTTP_COOKIE'] and @request.cookies, e.g:
    
        @request.env['HTTP_COOKIE'] = 'user_name=david'
        get :index
        assert_equal 'david', cookies[:user_name]
    
    and
    
        @request.cookies[:user_name] = 'david'
        get :index
        assert_equal 'david', cookies[:user_name]
    
    Assigning via cookies[] is the preferred method and will take precedence
    over the other two methods. This is so that cookies set in controller
    actions have precedence and are carried over between calls to get, post, etc.
Loading