Sha256: ef11f6632c80e736b3507978c3de29e7da456944a7bdf92865a13bba47ab9cdd

Contents?: true

Size: 710 Bytes

Versions: 13

Compression:

Stored size: 710 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
    book.send(:clear_association_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

13 entries across 13 versions & 1 rubygems

Version Path
second_level_cache-2.6.4 test/belongs_to_association_test.rb
second_level_cache-2.6.3 test/belongs_to_association_test.rb
second_level_cache-2.6.2 test/belongs_to_association_test.rb
second_level_cache-2.6.1 test/belongs_to_association_test.rb
second_level_cache-2.6.0 test/belongs_to_association_test.rb
second_level_cache-2.5.3 test/belongs_to_association_test.rb
second_level_cache-2.5.2 test/belongs_to_association_test.rb
second_level_cache-2.5.0 test/belongs_to_association_test.rb
second_level_cache-2.4.4 test/belongs_to_association_test.rb
second_level_cache-2.4.3 test/belongs_to_association_test.rb
second_level_cache-2.4.2 test/belongs_to_association_test.rb
second_level_cache-2.4.1 test/belongs_to_association_test.rb
second_level_cache-2.4.0 test/belongs_to_association_test.rb