Sha256: cbbef82119913d56c94e2e4a1878210329bf6eea67d1cc3ff1453d63f7d03cf3

Contents?: true

Size: 940 Bytes

Versions: 2

Compression:

Stored size: 940 Bytes

Contents

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

class ActiveRecord::BaseTest < Minitest::Test
  def setup
    @user = User.create :name => 'csdn', :email => 'test@csdn.com'
  end

  def test_should_update_cache_when_update_attributes
    @user.update_attributes :name => 'change'
    assert_equal @user.name, User.read_second_level_cache(@user.id).name
  end

  def test_should_update_cache_when_update_attribute
    @user.update_attribute :name, 'change'
    assert_equal @user.name, User.read_second_level_cache(@user.id).name
  end

  def test_should_expire_cache_when_destroy
    @user.destroy
    assert_nil User.read_second_level_cache(@user.id)
  end

  def test_should_expire_cache_when_update_counters
    assert_equal @user.books_count, 0
    @user.books.create
    assert_nil User.read_second_level_cache(@user.id)
    user = User.find(@user.id)
    assert_equal user.books_count, @user.books_count + 1
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
second_level_cache-2.1.0.rc2 test/active_record/base_test.rb
second_level_cache-2.1.0.rc1 test/active_record/base_test.rb