aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/binary_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/binary_test.rb')
-rw-r--r--activerecord/test/cases/binary_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/binary_test.rb b/activerecord/test/cases/binary_test.rb
index 8545ba97cc..06c14cb108 100644
--- a/activerecord/test/cases/binary_test.rb
+++ b/activerecord/test/cases/binary_test.rb
@@ -1,3 +1,4 @@
+# encoding: utf-8
require "cases/helper"
# Without using prepared statements, it makes no sense to test
@@ -9,6 +10,24 @@ unless current_adapter?(:SybaseAdapter, :DB2Adapter, :FirebirdAdapter)
class BinaryTest < ActiveRecord::TestCase
FIXTURES = %w(flowers.jpg example.log)
+ def test_mixed_encoding
+ str = "\x80"
+ str.force_encoding('ASCII-8BIT') if str.respond_to?(:force_encoding)
+
+ binary = Binary.new :name => 'いただきます!', :data => str
+ binary.save!
+ binary.reload
+ assert_equal str, binary.data
+
+ name = binary.name
+
+ # Mysql adapter doesn't properly encode things, so we have to do it
+ if current_adapter?(:MysqlAdapter)
+ name.force_encoding('UTF-8') if name.respond_to?(:force_encoding)
+ end
+ assert_equal 'いただきます!', name
+ end
+
def test_load_save
Binary.delete_all