Sha256: bb92614436a5aa575a8e5196e6082171fcdfe6947405875399fb6b7575f059ee
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
# -*- encoding : utf-8 -*- require 'test_helper' class RecordMarshalTest < ActiveSupport::TestCase def setup @user = User.create :name => 'csdn', :email => 'test@csdn.com', :options => [1,2] end def test_should_dump_active_record_object dumped = RecordMarshal.dump(@user) assert dumped.is_a?(Array) assert_equal "User", dumped[0] assert_equal @user.attributes, dumped[1] end def test_should_load_active_record_object @user.write_second_level_cache assert_equal @user, User.read_second_level_cache(@user.id) assert_equal Array, User.read_second_level_cache(@user.id).options.class assert_equal Array, User.read_second_level_cache(@user.id).reload.options.class assert_equal User.read_second_level_cache(@user.id).changed?, false assert_equal [1,2], User.read_second_level_cache(@user.id).options assert User.read_second_level_cache(@user.id).persisted? end def test_should_load_nil @user.expire_second_level_cache assert_nil User.read_second_level_cache(@user.id) end def test_should_load_active_record_object_without_association_cache @user.books @user.write_second_level_cache assert_empty User.read_second_level_cache(@user.id).association_cache end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
second_level_cache-2.1.5 | test/record_marshal_test.rb |