This project is archived and is in readonly mode.
cookies hash in ActionDispatch::TestProcess should be indifferent access
Reported by David Chelimsky | October 6th, 2010 @ 02:29 PM
Consider:
class WelcomeController < ApplicationController
def index
cookies[:foo] = "bar"
cookies["baz"] = "bam"
end
end
class WelcomeControllerTest < ActionController::TestCase
test "index sets :foo cookie (checked with a String key)" do
get "index"
assert_equal "bar", cookies["foo"] # => pass
end
test "index sets \"baz\" cookie (checked with a String key)" do
get "index"
assert_equal "bam", cookies["baz"] # => pass
end
test "index sets :foo cookie (checked with a Symbol key)" do
get "index"
assert_equal "bar", cookies[:foo] # => fail
end
test "index sets \"baz\" cookie (checked with a Symbol key)" do
get "index"
assert_equal "bam", cookies[:baz] # => fail
end
end
The fact that we can set cookies with Symbols or Strings, but test them only with Symbols is confusing, leading to false-negatives when testing for non-nil values and false-positives when testing for nil values.
I'd recommend making converting the cookies hash in ActionDispatch::TestProcess to a HashWithIndifferentAccess. Patch forthcoming.
Comments and changes to this ticket
-
David Trasbo October 10th, 2010 @ 06:28 PM
- State changed from new to open
- Importance changed from to Low
+1
I'd even say that
cookies
not being indifferent access is unexpected behavior.David, are you still planning on making a patch for this? I'd be happy to.
-
Repository November 7th, 2010 @ 07:04 PM
- State changed from open to committed
(from [990f52ebd78df77d73a2187751c6e1bb6d4b6033]) Make cookies hash in ActionDispatch::TestProcess indifferent access [#5761 state:committed]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
https://github.com/rails/rails/commit/990f52ebd78df77d73a2187751c6e...
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>
People watching this ticket
Attachments
Tags
Referenced by
- 5761 cookies hash in ActionDispatch::TestProcess should be indifferent access (from [990f52ebd78df77d73a2187751c6e1bb6d4b6033]) Make co...