Sha256: ce6f6bdb33e3dfd2cab174bb79f3a13a44ba6cabc394587cb00614fe37a776a5

Contents?: true

Size: 878 Bytes

Versions: 7

Compression:

Stored size: 878 Bytes

Contents

# -*- encoding : utf-8 -*-
require 'active_record/test_helper'

class RecordMarshalTest < Test::Unit::TestCase
  def setup
    @user = User.create :name => 'csdn', :email => 'test@csdn.com'
  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)
  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

7 entries across 7 versions & 1 rubygems

Version Path
second_level_cache-2.0.0 test/record_marshal_test.rb
second_level_cache-2.0.0.rc1 test/record_marshal_test.rb
second_level_cache-2.0.0.beta test/record_marshal_test.rb
second_level_cache-1.6.2 test/record_marshal_test.rb
second_level_cache-1.6.1 test/record_marshal_test.rb
second_level_cache-1.6.0 test/record_marshal_test.rb
second_level_cache-1.5.1 test/record_marshal_test.rb