Skip to content

Commit a427d05

Browse files
committed
update marshal tests
1 parent 44bcda4 commit a427d05

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

test/db/postgresql/types_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def test_timestamp_with_zone_values_without_rails_time_zone_support
701701
@connection.reconnect!
702702
end if ar_version('3.0')
703703

704-
def test_marshaling
704+
def test_marshal_types
705705
Marshal.dump @first_array
706706
Marshal.dump @first_bit_string
707707
Marshal.dump @first_tsvector

test/simple.rb

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,11 +1264,30 @@ def test_query_cache
12641264
end
12651265
end
12661266

1267-
def test_marshaling
1268-
Marshal.dump DbType.new
1269-
db_type = DbType.create!
1270-
Marshal.dump db_type
1271-
Marshal.dump db_type.reload
1267+
def test_marshal
1268+
expected = DbType.create!(
1269+
:sample_string => 'a string',
1270+
:sample_text => '1234' * 100,
1271+
:sample_integer => 42,
1272+
:sample_float => 10.5,
1273+
:sample_boolean => true,
1274+
:sample_decimal => 0.12345678,
1275+
:sample_time => Time.now,
1276+
:sample_binary => '01' * 512
1277+
)
1278+
expected.reload
1279+
1280+
marshalled = Marshal.dump(expected)
1281+
actual = Marshal.load(marshalled)
1282+
1283+
assert_equal expected.attributes, actual.attributes
1284+
end
1285+
1286+
def test_marshal_new
1287+
marshalled = Marshal.dump(DbType.new)
1288+
actual = Marshal.load(marshalled)
1289+
1290+
assert actual.new_record?, "should be a new record"
12721291
end
12731292

12741293
protected

0 commit comments

Comments
 (0)