This project is archived and is in readonly mode.

#2552 ✓stale
Ryan Sonnek

request_uri in tests include posted parameters

Reported by Ryan Sonnek | April 23rd, 2009 @ 06:33 PM | in 3.x

I'm testing redirection to ssl for a posted form. The redirected url in the app is correct, but in the unit tests, it's including the posted parameters in the query string.

def test_should_not_append_params_to_post
  post :baz, :foo => :bar
  assert_equal "/sessions/baz", @request.request_uri
end

Output: <"/sessions/baz"> expected but was <"/sessions/baz?foo=bar">.

Comments and changes to this ticket

  • Zyclops

    Zyclops May 7th, 2009 @ 05:04 AM

    I'm getting the exact same issue.

    post :save_security_profile, { 'advanced_projects_and_fellowships_access' => [125,126], 'roles' => 1 }

    puts request.request_uri => /admin/save_security_profile?advanced_projects_and_fellowships_access%5B%5D=125&advanced_projects_and_fellowships_access%5B%5D=126&roles=1

    Another person with this issue last year http://www.ruby-forum.com/topic/...

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • David Trasbo

    David Trasbo October 19th, 2010 @ 11:13 AM

    • State changed from “new” to “incomplete”
    • Importance changed from “” to “”

    As for edge Rails, I've been digging around in the source, and it seems request_uri (or REQUEST_URI) is gone altogether, except a request_uri= method in ActionDispatch::TestRequest, but the header is not set by default and there's no convenience method for accessing it.

    The issue still exists on 2-3-stable though:

    $ script/generate controller people index
          exists  app/controllers/
          exists  app/helpers/
          create  app/views/people
          exists  test/functional/
          create  test/unit/helpers/
          create  app/controllers/people_controller.rb
          create  test/functional/people_controller_test.rb
          create  app/helpers/people_helper.rb
          create  test/unit/helpers/people_helper_test.rb
          create  app/views/people/index.html.erb
    

    config/routes.rb:

    ActionController::Routing::Routes.draw do |map|
      map.resources :people
    end
    

    test/functional/people_controller_test.rb:

    require 'test_helper'
    
    class PeopleControllerTest < ActionController::TestCase
      test "request_uri does not include GET params when SSL is on" do
        @request.env['HTTPS'] = 'on'
        get :index, :foo => 'bar'
        assert_equal '/people', @request.request_uri
      end
    end
    

    rake test:functionals outputs the following:

    (in /Users/dtrasbo/Documents/Code/ticket_2552)
    /Users/dtrasbo/.rvm/rubies/ruby-1.9.2-p0/bin/ruby -I"lib:test" "/Users/dtrasbo/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/functional/people_controller_test.rb" 
    Loaded suite /Users/dtrasbo/.rvm/gems/ruby-1.9.2-p0@global/gems/rake-0.8.7/lib/rake/rake_test_loader
    Started
    F
    Finished in 0.085008 seconds.
    
      1) Failure:
    test_request_uri_does_not_include_GET_params_when_SSL_is_on(PeopleControllerTest) [test/functional/people_controller_test.rb:7]:
    <"/people"> expected but was
    <"/people?foo=bar">.
    
    1 tests, 1 assertions, 1 failures, 0 errors, 0 skips
    
    Test run options: --seed 62202
    rake aborted!
    Command failed with status (1): [/Users/dtrasbo/.rvm/rubies/ruby-1.9.2-p0/b...]
    
    (See full trace by running task with --trace)
    

    Please provide a patch (https://rails.lighthouseapp.com/projects/8994/sending-patches) with a fix and/or a failing test.

  • Jeff Kreeftmeijer
  • Santiago Pastorino

    Santiago Pastorino February 9th, 2011 @ 12:32 AM

    • State changed from “incomplete” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 9th, 2011 @ 12:32 AM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages