aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-10-12 11:38:07 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-10-12 11:38:07 -0700
commit98cb754cd7fee6203646947422600fccc6e00818 (patch)
treeb0c91a1e4a21156177528b5e7acbac111827cb1d
parent2681dd81b4c70c26bc29a56bf7c0f31bd17dbf3d (diff)
downloadrails-98cb754cd7fee6203646947422600fccc6e00818.tar.gz
rails-98cb754cd7fee6203646947422600fccc6e00818.tar.bz2
rails-98cb754cd7fee6203646947422600fccc6e00818.zip
test quoting multibyte chars object
-rw-r--r--activerecord/test/cases/quoting_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/quoting_test.rb b/activerecord/test/cases/quoting_test.rb
index cb5191a1f1..08227d4379 100644
--- a/activerecord/test/cases/quoting_test.rb
+++ b/activerecord/test/cases/quoting_test.rb
@@ -164,6 +164,11 @@ module ActiveRecord
assert_equal "'lo\\\\l'", @quoter.quote('lo\l', nil)
end
+ def test_quote_as_mb_chars_no_column
+ string = ActiveSupport::Multibyte::Chars.new('lo\l')
+ assert_equal "'lo\\\\l'", @quoter.quote(string, nil)
+ end
+
def test_quote_string_int_column
assert_equal "1", @quoter.quote('1', FakeColumn.new(:integer))
assert_equal "1", @quoter.quote('1.2', FakeColumn.new(:integer))
@@ -174,6 +179,11 @@ module ActiveRecord
assert_equal "1.2", @quoter.quote('1.2', FakeColumn.new(:float))
end
+ def test_quote_as_mb_chars_binary_column
+ string = ActiveSupport::Multibyte::Chars.new('lo\l')
+ assert_equal "'lo\\\\l'", @quoter.quote(string, FakeColumn.new(:binary))
+ end
+
def test_quote_binary_without_string_to_binary
assert_equal "'lo\\\\l'", @quoter.quote('lo\l', FakeColumn.new(:binary))
end
@@ -186,6 +196,16 @@ module ActiveRecord
}.new(:binary)
assert_equal "'foo'", @quoter.quote('lo\l', col)
end
+
+ def test_quote_as_mb_chars_binary_column_with_string_to_binary
+ col = Class.new(FakeColumn) {
+ def self.string_to_binary(value)
+ 'foo'
+ end
+ }.new(:binary)
+ string = ActiveSupport::Multibyte::Chars.new('lo\l')
+ assert_equal "'foo'", @quoter.quote(string, col)
+ end
end
end
end