Sha256: 80696bcc348aa972975216804b7151a63f657144a59423fa6ccecc918db03a1a

Contents?: true

Size: 847 Bytes

Versions: 12

Compression:

Stored size: 847 Bytes

Contents

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

class SingleTableInheritanceTest < ActiveSupport::TestCase
  def test_superclass_find__caches_superclass_record
    animal = Animal.create
    assert_no_queries do
      assert_equal animal, Animal.find(animal.id)
    end
  end

  def test_superclass_find__caches_subclass_record
    dog = Dog.create
    assert_no_queries do
      assert_equal dog, Animal.find(dog.id)
    end
  end

  def test_subclass_find__caches_subclass_record
    dog = Dog.create
    dog_id = dog.id
    assert_no_queries do
      newdog = Dog.find(dog_id)
      assert_equal dog, newdog
    end
  end

  def test_subclass_find__doesnt_find_superclass_record
    animal = Animal.create
    assert_queries(:any) do
      assert_raises ActiveRecord::RecordNotFound do
        Dog.find(animal.id)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
second_level_cache-2.1.16 test/single_table_inheritance_test.rb
second_level_cache-2.1.15 test/single_table_inheritance_test.rb
second_level_cache-2.1.14 test/single_table_inheritance_test.rb
second_level_cache-2.1.13 test/single_table_inheritance_test.rb
second_level_cache-2.1.10 test/single_table_inheritance_test.rb
second_level_cache-2.1.9 test/single_table_inheritance_test.rb
second_level_cache-2.1.8 test/single_table_inheritance_test.rb
second_level_cache-2.1.7 test/single_table_inheritance_test.rb
second_level_cache-2.1.6 test/single_table_inheritance_test.rb
second_level_cache-2.1.5 test/single_table_inheritance_test.rb
second_level_cache-2.1.2 test/single_table_inheritance_test.rb
second_level_cache-2.1.1 test/single_table_inheritance_test.rb