Sha256: 166f1a07f7a49387dd3f77cafeabd347be0c0c37399ba9a01e2706f8e990a616

Contents?: true

Size: 671 Bytes

Versions: 2

Compression:

Stored size: 671 Bytes

Contents

# frozen_string_literal: true

require "test_helper"

class BelongsToAssociationTest < ActiveSupport::TestCase
  def setup
    @user = User.create name: "csdn", email: "test@csdn.com"
  end

  def test_should_get_cache_when_use_belongs_to_association
    book = @user.books.create

    @user.write_second_level_cache

    assert_no_queries do
      assert_equal @user, book.user
    end
  end

  def test_should_write_belongs_to_association_cache
    book = @user.books.create
    @user.expire_second_level_cache
    assert_nil User.read_second_level_cache(@user.id)
    assert_equal @user, book.user
    # assert_not_nil User.read_second_level_cache(@user.id)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
second_level_cache-2.7.1 test/belongs_to_association_test.rb
second_level_cache-2.7.0 test/belongs_to_association_test.rb