@@ -13,6 +13,7 @@ def setup
13
13
ActiveRecord ::Base . connection . schema_cache . clear!
14
14
Session . drop_table! if Session . table_exists?
15
15
@session_klass = Class . new ( Session )
16
+ ActiveRecord ::SessionStore ::Session . serializer = :json
16
17
end
17
18
18
19
def test_data_column_name
@@ -38,7 +39,8 @@ def test_json_serialization
38
39
s = session_klass . create! ( :data => 'world' , :session_id => '7' )
39
40
40
41
sessions = ActiveRecord ::Base . connection . execute ( "SELECT * FROM #{ Session . table_name } " )
41
- assert_equal JSON . generate ( { value : s . data } , quirks_mode : true ) , sessions [ 0 ] [ Session . data_column_name ]
42
+ data = Session . deserialize ( sessions [ 0 ] [ Session . data_column_name ] )
43
+ assert_equal s . data , data
42
44
end
43
45
44
46
def test_hybrid_serialization
@@ -54,7 +56,7 @@ def test_hybrid_serialization
54
56
# Check that first was serialized with Marshal and second as JSON
55
57
sessions = ActiveRecord ::Base . connection . execute ( "SELECT * FROM #{ Session . table_name } " )
56
58
assert_equal ::Base64 . encode64 ( Marshal . dump ( s1 . data ) ) , sessions [ 0 ] [ Session . data_column_name ]
57
- assert_equal JSON . generate ( { value : s2 . data } , quirks_mode : true ) , sessions [ 1 ] [ Session . data_column_name ]
59
+ assert_equal s2 . data , Session . deserialize ( sessions [ 1 ] [ Session . data_column_name ] )
58
60
end
59
61
60
62
def test_hybrid_deserialization
@@ -77,7 +79,7 @@ def test_hybrid_deserialization
77
79
# and reserializes as JSON
78
80
session . save
79
81
sessions = ActiveRecord ::Base . connection . execute ( "SELECT * FROM #{ Session . table_name } " )
80
- assert_equal JSON . generate ( { value : s . data } , quirks_mode : true ) , sessions [ 0 ] [ Session . data_column_name ]
82
+ assert_equal s . data , Session . deserialize ( sessions [ 0 ] [ Session . data_column_name ] )
81
83
end
82
84
83
85
def test_find_by_sess_id_compat
0 commit comments