param_protected icon indicating copy to clipboard operation
param_protected copied to clipboard

Compatibility with rails 3.2.3: cannot use 2 request in one test when param_protected installed

Open alexeymuranov opened this issue 13 years ago • 1 comments

This is a new side effect of param_protected with rails 3.2.3:

rails new test_app
cd test_app
rake db:migrate
rails generate controller Boo index

boo_controller.rb:

class BooController < ApplicationController
  def index
    p params
  end
end

boo_controller_test.rb:

require 'test_helper'

class BooControllerTest < ActionController::TestCase
  test "should get index" do
    get :index, { :a => 1 }
    assert_response :success
    get :index, { :a => 2 }
    assert_response :success
    get :index, { :a => 3 }
    assert_response :success
  end
end

Here is the test output without param_protected gem:

§ rake test:functionals
Run options: 

# Running tests:

{"a"=>"1", "controller"=>"boo", "action"=>"index"}
{"a"=>"2", "controller"=>"boo", "action"=>"index"}
{"a"=>"3", "controller"=>"boo", "action"=>"index"}
.

Finished tests in 0.490426s, 2.0390 tests/s, 6.1171 assertions/s.

1 tests, 3 assertions, 0 failures, 0 errors, 0 skips

Here is the output after adding param_protected gem:

§ rake test:functionals
Run options: 

# Running tests:

{"a"=>"1", "controller"=>"boo", "action"=>"index"}
{"a"=>"1", "controller"=>"boo", "action"=>"index"}
{"a"=>"1", "controller"=>"boo", "action"=>"index"}
.

Finished tests in 0.396299s, 2.5233 tests/s, 7.5700 assertions/s.

1 tests, 3 assertions, 0 failures, 0 errors, 0 skips

This does not happen with rails 3.2.2.

alexeymuranov avatar Apr 01 '12 22:04 alexeymuranov

Shoot, not sure when I'll have time to look into this. Maybe this weekend. Anyone else want to take a stab? :)

-- C

On Sunday, April 1, 2012 at 6:54 PM, Alexey Muranov wrote:

This is a new side effect of param_protected with rails 3.2.3:

rails new test_app
cd test_app
rake db:migrate
rails generate controller Boo index

boo_controller.rb:

class BooController < ApplicationController
def index
p params
end
end

boo_controller_test.rb:

require 'test_helper'

class BooControllerTest < ActionController::TestCase
test "should get index" do
get :index, { :a => 1 }
assert_response :success
get :index, { :a => 2 }
assert_response :success
get :index, { :a => 3 }
assert_response :success
end
end

Here is the test output without param_protected gem:

§ rake test:functionals
Run options:  

# Running tests:

{"a"=>"1", "controller"=>"boo", "action"=>"index"}
{"a"=>"2", "controller"=>"boo", "action"=>"index"}
{"a"=>"3", "controller"=>"boo", "action"=>"index"}
.

Finished tests in 0.490426s, 2.0390 tests/s, 6.1171 assertions/s.

1 tests, 3 assertions, 0 failures, 0 errors, 0 skips

Here is the output after adding param_protected gem:

§ rake test:functionals
Run options:  

# Running tests:

{"a"=>"1", "controller"=>"boo", "action"=>"index"}
{"a"=>"1", "controller"=>"boo", "action"=>"index"}
{"a"=>"1", "controller"=>"boo", "action"=>"index"}
.

Finished tests in 0.396299s, 2.5233 tests/s, 7.5700 assertions/s.

1 tests, 3 assertions, 0 failures, 0 errors, 0 skips

This does not happen with rails 3.2.2.


Reply to this email directly or view it on GitHub: https://github.com/cjbottaro/param_protected/issues/12

cjbottaro avatar Apr 05 '12 16:04 cjbottaro