[rspec-devel] [ rspec-Bugs-15282 ] POST, PUT and DELETE incorrectly append params to the request_uri

noreply at rubyforge.org noreply at rubyforge.org
Fri Nov 2 04:07:22 EDT 2007


Bugs item #15282, was opened at 2007-11-02 03:07
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=15282&group_id=797

Category: rails plugin
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Jeff Dean (jefdean)
Assigned to: Nobody (None)
Summary: POST, PUT and DELETE incorrectly append params to the request_uri

Initial Comment:
Given this form:

<pre><code>
<form action="/sessions/baz" method="post">
  <input type="text" name="foo" value="bar" />
  <input type="submit" />
</form>
</code></pre>

And this action:

<pre><code>
 class SessionsController < ApplicationController
  def baz
    render :text => "#{request.request_uri}<br/>#{params.inspect}"
  end
 end
</code></pre>

Submitting the form yields this output:

<pre><code>
/sessions/baz
{"action"=>"baz", "foo"=>"bar", "controller"=>"sessions"}
</code></pre>

This spec:

<pre><code>
describe SessionsController do
 it "should not append params to POST" do
  post :baz, :foo => :bar
  request.request_uri.should == "/sessions/baz"
 end
end
</code></pre>

Fail with this message:

<pre><code>
expected: "/sessions/baz",
     got: "/sessions/baz?foo=bar" (using ==)
</code></pre>

Notice how in the real app, rails properly interprets the request.request_uri, but in rspec_on_rails, the POST parameters are appended to the request_uri like GET paramaters. 

This is a bug because the spec does not correctly represent the behavior of rails.  I came up against this as I was trying to write a redirect that was based on the url of a page that was posted to, i.e.:

User posts form
Site recognizes that user is not logged in
Site redirects to login page, but stores params and request_uri
After login, repost the params to the request_uri

And I couldn't find a way to spec that.

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=15282&group_id=797


More information about the rspec-devel mailing list