Sha256: 552a3949ca5cde2567b31b3489002ca83be2ed993e256026e2925c543bd5db23

Contents?: true

Size: 865 Bytes

Versions: 11

Compression:

Stored size: 865 Bytes

Contents

require 'test_helper'

class BaseTest < ActiveSupport::TestCase
  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 0, @user.books_count
    @user.books.create
    assert_nil User.read_second_level_cache(@user.id)
    user = User.find(@user.id)
    assert_equal 1, user.books_count
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
second_level_cache-2.3.3 test/base_test.rb
second_level_cache-2.3.2 test/base_test.rb
second_level_cache-2.3.1 test/base_test.rb
second_level_cache-2.3.0 test/base_test.rb
second_level_cache-2.3.0.beta test/base_test.rb
second_level_cache-2.2.6 test/base_test.rb
second_level_cache-2.2.5 test/base_test.rb
second_level_cache-2.2.4 test/base_test.rb
second_level_cache-2.2.3 test/base_test.rb
second_level_cache-2.2.2 test/base_test.rb
second_level_cache-2.2.1 test/base_test.rb