Ticket #2291: component_flash_fix_2.2322.diff
| File component_flash_fix_2.2322.diff, 3.4 kB (added by divoxx, 3 years ago) |
|---|
-
actionpack/test/controller/request_test.rb
old new 52 52 assert_nil @request.domain 53 53 end 54 54 55 def test_component_call 56 assert !@request.component_call? 57 58 @request.env['HTTP_X_REQUESTED_WITH'] = 'NotComponent' 59 assert !@request.component_call? 60 61 @request.env['HTTP_X_REQUESTED_WITH'] = 'ComponentCall' 62 assert @request.component_call? 63 end 64 55 65 def test_subdomains 56 66 @request.host = "www.rubyonrails.org" 57 67 assert_equal %w( www ), @request.subdomains -
actionpack/lib/action_controller/components.rb
old new 52 52 53 53 def request_for_component(options) 54 54 request_for_component = @request.dup 55 request_for_component.env['HTTP_X_REQUESTED_WITH'] = 'ComponentCall' 55 56 request_for_component.send( 56 57 :instance_variable_set, :@parameters, 57 58 (options[:params] || {}).merge({ "controller" => options[:controller], "action" => options[:action], "id" => options[:id] }).with_indifferent_access -
actionpack/lib/action_controller/request.rb
old new 86 86 end 87 87 alias xhr? :xml_http_request? 88 88 89 # Returns true if the request's "X-Requested-With" header constains 'ComponentCall' 90 def component_call? 91 not /ComponentCall/i.match(env['HTTP_X_REQUESTED_WITH']).nil? 92 end 93 89 94 # Determine originating IP address. REMOTE_ADDR is the standard 90 95 # but will fail if the user is behind a proxy. HTTP_CLIENT_IP and/or 91 96 # HTTP_X_FORWARDED_FOR are set by proxies so check for these before -
actionpack/lib/action_controller/base.rb
old new 270 270 # has been rendered through response.body -- useful for <tt>after_filter</tt>s that wants to manipulate the output, 271 271 # such as a OutputCompressionFilter. 272 272 attr_accessor :response 273 273 274 274 # Holds a hash of objects in the session. Accessed like <tt>session[:person]</tt> to get the object tied to the "person" 275 275 # key. The session will hold any type of object as values, but the key should be a string. 276 276 attr_accessor :session -
actionpack/lib/action_controller/flash.rb
old new 143 143 144 144 # marks flash entries as used and expose the flash to the view 145 145 def fire_flash 146 return if @request.component_call? 146 147 flash.discard 147 148 @assigns["flash"] = flash 148 149 end 149 150 150 151 # deletes the flash entries that were not marked for keeping 151 152 def sweep_flash 153 return if @request.component_call? 152 154 flash.sweep 153 155 end 154 156 end