aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-03-03 22:55:14 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-03-03 22:55:14 +0000
commite4106a580ec5008f7a84be6f412e5d88d7a160cb (patch)
tree2bfa0a1504e9dfdaf223a99329073287cdddb38e /activesupport/test
parente834be75bcbbece8970abad221f21411c5b93a96 (diff)
downloadrails-e4106a580ec5008f7a84be6f412e5d88d7a160cb.tar.gz
rails-e4106a580ec5008f7a84be6f412e5d88d7a160cb.tar.bz2
rails-e4106a580ec5008f7a84be6f412e5d88d7a160cb.zip
Fixed an exception when using Ajax based requests from Safari because Safari appends a \000 to the post body. Symbols can't have \000 in them so indifferent access would throw an exception in the constructor. Indifferent hashes now use strings internally instead. #746 [Tobias Luetke]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@827 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb26
1 files changed, 20 insertions, 6 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index f5ace81927..d74a32e892 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/hash'
class HashExtTest < Test::Unit::TestCase
def setup
+
@strings = { 'a' => 1, 'b' => 2 }
@symbols = { :a => 1, :b => 2 }
@mixed = { :a => 1, 'b' => 2 }
@@ -31,7 +32,7 @@ class HashExtTest < Test::Unit::TestCase
assert_equal @symbols, @strings.dup.symbolize_keys!
assert_equal @symbols, @mixed.dup.symbolize_keys!
- assert_raises(NoMethodError) { { [] => 1 }.symbolize_keys! }
+ assert_raises(NoMethodError) { { [] => 1 }.symbolize_keys }
end
def test_stringify_keys
@@ -50,11 +51,24 @@ class HashExtTest < Test::Unit::TestCase
@strings = @strings.with_indifferent_access
@symbols = @symbols.with_indifferent_access
@mixed = @mixed.with_indifferent_access
-
- assert_equal @strings[:a], @strings["a"]
- assert_equal @symbols[:a], @symbols["a"]
- assert_equal @strings["b"], @mixed["b"]
- assert_equal @strings[:b], @mixed["b"]
+
+ assert_equal @strings[:a], @strings['a']
+ assert_equal @symbols[:a], @symbols['a']
+ assert_equal @strings['b'], @mixed['b']
+ assert_equal @strings[:b], @mixed['b']
+ end
+
+ def test_indifferent_writing
+ hash = HashWithIndifferentAccess.new
+ hash[:a] = 1
+ hash['b'] = 2
+ hash[3] = 3
+
+ assert_equal hash['a'], 1
+ assert_equal hash['b'], 2
+ assert_equal hash[:a], 1
+ assert_equal hash[:b], 2
+ assert_equal hash[3], 3
end
def test_assert_valid_keys