diff options
author | Kir Shatrov <shatrov@me.com> | 2016-11-13 22:18:14 -0500 |
---|---|---|
committer | Kir Shatrov <shatrov@me.com> | 2016-11-27 22:09:58 -0500 |
commit | 4c00c6ed230e6fdc6199dfba43f6da1e741a02aa (patch) | |
tree | 6bbbc866f6c9061bd63ef45d5279c6e14d612654 /activerecord/test/cases/connection_adapters | |
parent | 6d6249b1c1abda4f62fafcc42a7ece570c8da7e9 (diff) | |
download | rails-4c00c6ed230e6fdc6199dfba43f6da1e741a02aa.tar.gz rails-4c00c6ed230e6fdc6199dfba43f6da1e741a02aa.tar.bz2 rails-4c00c6ed230e6fdc6199dfba43f6da1e741a02aa.zip |
Use YAML to serialize schema cache
Diffstat (limited to 'activerecord/test/cases/connection_adapters')
-rw-r--r-- | activerecord/test/cases/connection_adapters/schema_cache_test.rb | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/activerecord/test/cases/connection_adapters/schema_cache_test.rb b/activerecord/test/cases/connection_adapters/schema_cache_test.rb index d4459603af..1b4f80fc67 100644 --- a/activerecord/test/cases/connection_adapters/schema_cache_test.rb +++ b/activerecord/test/cases/connection_adapters/schema_cache_test.rb @@ -12,6 +12,33 @@ module ActiveRecord assert_equal "id", @cache.primary_keys("posts") end + 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 + + 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 + def test_primary_key_for_non_existent_table assert_nil @cache.primary_keys("omgponies") end @@ -45,10 +72,12 @@ module ActiveRecord @cache = Marshal.load(Marshal.dump(@cache)) - 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") + 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 def test_table_methods_deprecation @@ -56,6 +85,12 @@ module ActiveRecord assert_deprecated { assert @cache.tables("posts") } assert_deprecated { @cache.clear_table_cache!("posts") } end + + private + + def schema_dump_path + "test/assets/schema_dump_5_1.yml" + end end end end |