diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-06-05 17:14:55 +0900 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-06-05 17:14:55 +0900 |
commit | 20daaf4e2ab30762eeaf023e4870f5a10c34c534 (patch) | |
tree | 9c803c9e695f5fb5ae749951147b89af06a133a6 /activerecord/test/cases/adapters | |
parent | 8799cfa72d071fe6ce78fa7dbbf5dd3c9d763a68 (diff) | |
download | rails-20daaf4e2ab30762eeaf023e4870f5a10c34c534.tar.gz rails-20daaf4e2ab30762eeaf023e4870f5a10c34c534.tar.bz2 rails-20daaf4e2ab30762eeaf023e4870f5a10c34c534.zip |
adding a test for #10830
Diffstat (limited to 'activerecord/test/cases/adapters')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/bytea_test.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/bytea_test.rb b/activerecord/test/cases/adapters/postgresql/bytea_test.rb new file mode 100644 index 0000000000..5ed2d8aba2 --- /dev/null +++ b/activerecord/test/cases/adapters/postgresql/bytea_test.rb @@ -0,0 +1,46 @@ +# encoding: utf-8 + +require "cases/helper" +require 'active_record/base' +require 'active_record/connection_adapters/postgresql_adapter' + +class PostgresqlByteaTest < ActiveRecord::TestCase + class ByteaDataType < ActiveRecord::Base + self.table_name = 'bytea_data_type' + end + + def setup + @connection = ActiveRecord::Base.connection + begin + @connection.transaction do + @connection.create_table('bytea_data_type') do |t| + t.binary 'payload' + t.binary 'serialized' + end + end + end + @column = ByteaDataType.columns.find { |c| c.name == 'payload' } + assert(@column.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLColumn)) + end + + def teardown + @connection.execute 'drop table if exists bytea_data_type' + end + + class Serializer + def load(str); str; end + def dump(str); str; end + end + + def test_serialize + serializer = Serializer.new + klass = Class.new(ByteaDataType) { + serialize :serialized, Serializer.new + } + obj = klass.new + obj.serialized = "hello world" + obj.save! + obj.reload + assert_equal "hello world", obj.serialized + end +end |