Sha256: b6322fd8c60dceb04e3636c222223fb383e8a9d250cbf0e506e3aada4a2dc673

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require "cases/helper"

module ActiveRecord
  module ConnectionAdapters
    class SchemaCacheTest < ActiveRecord::TestCase
      def setup
        connection = ActiveRecord::Base.connection
        @cache     = SchemaCache.new connection
      end

      def test_primary_key
        assert_equal 'id', @cache.primary_keys['posts']
      end

      def test_primary_key_for_non_existent_table
        assert_nil @cache.primary_keys['omgponies']
      end

      def test_caches_columns
        columns = @cache.columns['posts']
        assert_equal columns, @cache.columns['posts']
      end

      def test_caches_columns_hash
        columns_hash = @cache.columns_hash['posts']
        assert_equal columns_hash, @cache.columns_hash['posts']
      end

      def test_clearing
        @cache.columns['posts']
        @cache.columns_hash['posts']
        @cache.tables['posts']
        @cache.primary_keys['posts']

        @cache.clear!

        assert_equal 0, @cache.columns.size
        assert_equal 0, @cache.columns_hash.size
        assert_equal 0, @cache.tables.size
        assert_equal 0, @cache.primary_keys.size
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-nuodb-adapter-2.0.3 test/cases/connection_adapters/schema_cache_test.rb
activerecord-nuodb-adapter-2.0 test/cases/connection_adapters/schema_cache_test.rb