This project is archived and is in readonly mode.
params are strings IRL, integers in test
Reported by mikeymicrophone | April 7th, 2010 @ 07:29 PM
If I'm not mistaken, integer parameters from a web server are always delivered to the controller as strings, but the test helpers #get, #post etc allow you to pass in integers. In my experience this leads to a lot of bugs and it might make sense to align the behavior more accurately.
Comments and changes to this ticket
-
David Trasbo April 12th, 2010 @ 10:36 AM
This can be duplicated on edge Rails:
class TestsController < ApplicationController def show render :text => params[:id].class.to_s end end
require 'test_helper' class TestsControllerTest < ActionController::TestCase test "id param is a Fixnum" do get :show, :id => 42 assert_equal 'Fixnum', response.body end end
I definitely think this should be fixed. Since a controller will always receive all parameters as strings in real life, I think all parameters passed from tests should be converted to strings for consistency.
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>