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

Ticket #5864 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

[PATCH] Fix ActionController::Integration::Session#process to correctly handle HTTP headers

Reported by: dave.hoover@gmail.com Assigned to: David
Priority: normal Milestone: 1.2
Component: ActionPack Version: edge
Severity: normal Keywords:
Cc: bitsweat

Description

Providing HTTP_REFERER to an integration test request would result in HTTP_HTTP_REFERER in the request headers. This prevented integration testing of redirect_to :back in integratino tests like this...

{{{get "/sample/example", {}, {'HTTP_REFERER' => '/sample/index'} assert_redirected_to 'sample/index' }}}

The ActionController::Integration::Session#process method appears to have had a typo in it, which as been fixed by this patch. Tests included.

Attachments

fix_actioncontroller_integration_session_process_to_correctly_handle_http_headers.diff (1.8 kB) - added by dave.hoover@gmail.com on 08/23/06 02:29:20.
fix_actioncontroller_integration_session_process_to_correctly_handle_http_headers.2.diff (0.5 kB) - added by dave.hoover@gmail.com on 08/26/06 05:33:41.
removing the (broken) tests ... this patch is *tiny*

Change History

08/23/06 02:29:20 changed by dave.hoover@gmail.com

  • attachment fix_actioncontroller_integration_session_process_to_correctly_handle_http_headers.diff added.

08/23/06 05:21:26 changed by bitsweat

  • cc set to bitsweat.

Thanks for the patch. The new integration test doesn't pass, though - MissingSourceFile dispatcher.

Please set the Version field as well.

08/23/06 05:21:51 changed by bitsweat

  • status changed from new to closed.
  • resolution set to wontfix.

(Please reopen with updated patch.)

08/23/06 05:58:23 changed by dave.hoover@gmail.com

  • version set to edge.

Doh. Yeah, that test sucked, but it's not clear to me how to write a good test for that code. Maybe I missed them, but are there currently any tests that cover ActionController::Integration::Session? Did you take a look at the actual fix? Does it require tests?

08/26/06 05:33:41 changed by dave.hoover@gmail.com

  • attachment fix_actioncontroller_integration_session_process_to_correctly_handle_http_headers.2.diff added.

removing the (broken) tests ... this patch is *tiny*

08/26/06 06:52:46 changed by bitsweat

  • milestone set to 1.2.

Your test is a good idea - could you fix and include it? Fixing the typo for now. Thanks.

08/26/06 06:54:26 changed by bitsweat

  • resolution changed from wontfix to fixed.

(In [4825]) Typo in integration app session. Closes #5864.

08/26/06 14:31:53 changed by anonymous

I've got a test working, and it runs from the command line, but it breaks in TextMate and in Rake due to the

require 'dispatcher'

in integration.rb, which is loaded into my test via

require 'action_controller/integration'

TextMate simply can't find the dispatcher...

LoadError: no such file to load — dispatcher

Running from rake produces a stranger error...

./test/controller/../../lib/../../activesupport/lib/active_support/dependencies.rb:218:in `load_missing_constant': uninitialized constant ActionWebService::Dispatcher::ActionController::Base (NameError)
        from ./test/controller/../../lib/../../activesupport/lib/active_support/dependencies.rb:296:in `const_missing'
        from ./test/template/deprecated_instance_variables_test.rb:9
        from ./test/controller/../../lib/../../activesupport/lib/active_support/dependencies.rb:324:in `load'
        from /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader.rb:5
        from /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader.rb:5

Both of these errors can be reproduced by creating a *_test.rb file in actionpack/test/controller and putting a single line in it to

require 'action_controller/integration'

Other than that, I have a test ready for ActionController::Integration::Session.