aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorManfred Stienstra <manfred@fngtps.com>2008-09-21 17:30:16 +0200
committerManfred Stienstra <manfred@fngtps.com>2008-09-21 17:30:16 +0200
commit52f8c04e1e0f2e6610e54b00125179ec9dacbcd5 (patch)
tree1eabc363b0c39b05b1afb403e5078203149e9c61 /activerecord
parent809af7f5586cb3f2f913b21be168fbf72d58cbfe (diff)
downloadrails-52f8c04e1e0f2e6610e54b00125179ec9dacbcd5.tar.gz
rails-52f8c04e1e0f2e6610e54b00125179ec9dacbcd5.tar.bz2
rails-52f8c04e1e0f2e6610e54b00125179ec9dacbcd5.zip
Fix a test that assumes .mb_chars to always return an instance of the proxy_class.
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/test/cases/base_test.rb30
1 files changed, 23 insertions, 7 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 1c31b1fa7b..a4fddc2571 100755
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -1438,15 +1438,17 @@ class BasicsTest < ActiveRecord::TestCase
if RUBY_VERSION < '1.9'
def test_quote_chars
- str = 'The Narrator'
- topic = Topic.create(:author_name => str)
- assert_equal str, topic.author_name
+ with_kcode('UTF8') do
+ str = 'The Narrator'
+ topic = Topic.create(:author_name => str)
+ assert_equal str, topic.author_name
- assert_kind_of ActiveSupport::Multibyte.proxy_class, str.mb_chars
- topic = Topic.find_by_author_name(str.mb_chars)
+ assert_kind_of ActiveSupport::Multibyte.proxy_class, str.mb_chars
+ topic = Topic.find_by_author_name(str.mb_chars)
- assert_kind_of Topic, topic
- assert_equal str, topic.author_name, "The right topic should have been found by name even with name passed as Chars"
+ assert_kind_of Topic, topic
+ assert_equal str, topic.author_name, "The right topic should have been found by name even with name passed as Chars"
+ end
end
end
@@ -2039,4 +2041,18 @@ class BasicsTest < ActiveRecord::TestCase
ensure
ActiveRecord::Base.logger = original_logger
end
+
+ private
+ def with_kcode(kcode)
+ if RUBY_VERSION < '1.9'
+ orig_kcode, $KCODE = $KCODE, kcode
+ begin
+ yield
+ ensure
+ $KCODE = orig_kcode
+ end
+ else
+ yield
+ end
+ end
end