class ActiveRecord::ConnectionAdapters::SchemaCacheTest
Public Instance Methods
setup()
click to toggle source
# File activerecord/test/cases/connection_adapters/schema_cache_test.rb, line 8 def setup connection = ActiveRecord::Base.connection @cache = SchemaCache.new connection end
test_caches_columns()
click to toggle source
# File activerecord/test/cases/connection_adapters/schema_cache_test.rb, line 48 def test_caches_columns columns = @cache.columns("posts") assert_equal columns, @cache.columns("posts") end
test_caches_columns_hash()
click to toggle source
# File activerecord/test/cases/connection_adapters/schema_cache_test.rb, line 53 def test_caches_columns_hash columns_hash = @cache.columns_hash("posts") assert_equal columns_hash, @cache.columns_hash("posts") end
test_clear_data_source_cache()
click to toggle source
# File activerecord/test/cases/connection_adapters/schema_cache_test.rb, line 90 def test_clear_data_source_cache @cache.clear_data_source_cache!("posts") end
test_clearing()
click to toggle source
# File activerecord/test/cases/connection_adapters/schema_cache_test.rb, line 58 def test_clearing @cache.columns("posts") @cache.columns_hash("posts") @cache.data_sources("posts") @cache.primary_keys("posts") @cache.clear! assert_equal 0, @cache.size end
test_data_source_exist()
click to toggle source
# File activerecord/test/cases/connection_adapters/schema_cache_test.rb, line 85 def test_data_source_exist assert @cache.data_source_exists?("posts") assert_not @cache.data_source_exists?("foo") end
test_dump_and_load()
click to toggle source
# File activerecord/test/cases/connection_adapters/schema_cache_test.rb, line 69 def test_dump_and_load @cache.columns("posts") @cache.columns_hash("posts") @cache.data_sources("posts") @cache.primary_keys("posts") @cache = Marshal.load(Marshal.dump(@cache)) assert_no_queries do assert_equal 11, @cache.columns("posts").size assert_equal 11, @cache.columns_hash("posts").size assert @cache.data_sources("posts") assert_equal "id", @cache.primary_keys("posts") end end
test_primary_key()
click to toggle source
# File activerecord/test/cases/connection_adapters/schema_cache_test.rb, line 13 def test_primary_key assert_equal "id", @cache.primary_keys("posts") end
test_primary_key_for_non_existent_table()
click to toggle source
# File activerecord/test/cases/connection_adapters/schema_cache_test.rb, line 44 def test_primary_key_for_non_existent_table assert_nil @cache.primary_keys("omgponies") end
test_yaml_dump_and_load()
click to toggle source
# File activerecord/test/cases/connection_adapters/schema_cache_test.rb, line 17 def test_yaml_dump_and_load @cache.columns("posts") @cache.columns_hash("posts") @cache.data_sources("posts") @cache.primary_keys("posts") new_cache = YAML.load(YAML.dump(@cache)) assert_no_queries do assert_equal 11, new_cache.columns("posts").size assert_equal 11, new_cache.columns_hash("posts").size assert new_cache.data_sources("posts") assert_equal "id", new_cache.primary_keys("posts") end end
test_yaml_loads_5_1_dump()
click to toggle source
# File activerecord/test/cases/connection_adapters/schema_cache_test.rb, line 32 def test_yaml_loads_5_1_dump body = File.open(schema_dump_path).read cache = YAML.load(body) assert_no_queries do assert_equal 11, cache.columns("posts").size assert_equal 11, cache.columns_hash("posts").size assert cache.data_sources("posts") assert_equal "id", cache.primary_keys("posts") end end
Private Instance Methods
schema_dump_path()
click to toggle source
# File activerecord/test/cases/connection_adapters/schema_cache_test.rb, line 96 def schema_dump_path "test/assets/schema_dump_5_1.yml" end