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

Ticket #5864: fix_actioncontroller_integration_session_process_to_correctly_handle_http_headers.diff

File fix_actioncontroller_integration_session_process_to_correctly_handle_http_headers.diff, 1.8 kB (added by dave.hoover@gmail.com, 2 years ago)
  • test/controller/integration_test.rb

    old new  
     1require File.dirname(__FILE__) + '/../abstract_unit' 
     2require 'action_controller/integration' 
     3 
     4module ActiveRecord 
     5  class Base 
     6    def self.reset_subclasses; end 
     7  end 
     8end 
     9 
     10module ActionController 
     11  class IntegrationTest 
     12    def self.fixture_table_names; []; end 
     13  end 
     14   
     15  class Base 
     16    def self.last_instantiation 
     17      controller = Object.new 
     18      class << controller 
     19        def request;end 
     20        def response;end 
     21      end 
     22      controller 
     23    end 
     24  end 
     25end 
     26 
     27class Dispatcher 
     28  def self.dispatch(cgi, options, output) 
     29    unless cgi.env_table.has_key?('HTTP_REFERER') 
     30      fail('Expected HTTP_REFERER in CGI env but received: ' + cgi.env_table.keys.join(', '))  
     31    end 
     32     
     33    def cgi.stdoutput 
     34      out = Object.new 
     35      def out.string 
     36        "Status: 200\r\n\r\nBODY"       
     37      end 
     38      out 
     39    end 
     40  end 
     41end 
     42 
     43class IntegrationTestTest < ActionController::IntegrationTest 
     44  def test_accept_http_referer_on_redirect_back 
     45    get "/sample/example", {}, {'HTTP_REFERER' => '/sample/index'} 
     46  end 
     47end 
  • lib/action_controller/integration.rb

    old new  
    232232 
    233233          (headers || {}).each do |key, value| 
    234234            key = key.to_s.upcase.gsub(/-/, "_") 
    235             key = "HTTP_#{key}" unless env.has_key?(key) || env =~ /^X|HTTP/ 
     235            key = "HTTP_#{key}" unless env.has_key?(key) || key =~ /^X|HTTP/ 
    236236            env[key] = value 
    237237          end 
    238238