diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-09-22 22:29:59 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-09-22 22:29:59 +0200 |
commit | 7805fa2b0bdc49d1cc0f8e139739066c0f0b3f6c (patch) | |
tree | 7dbd4dda1c29b8ffdf2d13d9dbe96f490c6351b7 /activerecord/test/cases | |
parent | 3bbc325613583015a1058a1fa77bc87f7af30568 (diff) | |
parent | 152b85f06c7f91b39de0e5da6426feb35a698d05 (diff) | |
download | rails-7805fa2b0bdc49d1cc0f8e139739066c0f0b3f6c.tar.gz rails-7805fa2b0bdc49d1cc0f8e139739066c0f0b3f6c.tar.bz2 rails-7805fa2b0bdc49d1cc0f8e139739066c0f0b3f6c.zip |
Merge pull request #21715 from rails/introduce_data_sources
introduce `conn.data_source_exists?` and `conn.data_sources`.
Diffstat (limited to 'activerecord/test/cases')
4 files changed, 31 insertions, 3 deletions
diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb index 9a111b37cd..62579a4a7a 100644 --- a/activerecord/test/cases/adapter_test.rb +++ b/activerecord/test/cases/adapter_test.rb @@ -36,6 +36,21 @@ module ActiveRecord assert !@connection.table_exists?(nil) end + def test_data_sources + data_sources = @connection.data_sources + assert data_sources.include?("accounts") + assert data_sources.include?("authors") + assert data_sources.include?("tasks") + assert data_sources.include?("topics") + end + + def test_data_source_exists? + assert @connection.data_source_exists?("accounts") + assert @connection.data_source_exists?(:accounts) + assert_not @connection.data_source_exists?("nonexistingtable") + assert_not @connection.data_source_exists?(nil) + end + def test_indexes idx_name = "accounts_idx" diff --git a/activerecord/test/cases/adapters/postgresql/schema_test.rb b/activerecord/test/cases/adapters/postgresql/schema_test.rb index bee612d8d3..f89a394f96 100644 --- a/activerecord/test/cases/adapters/postgresql/schema_test.rb +++ b/activerecord/test/cases/adapters/postgresql/schema_test.rb @@ -5,9 +5,11 @@ require 'support/schema_dumping_helper' module PGSchemaHelper def with_schema_search_path(schema_search_path) @connection.schema_search_path = schema_search_path + @connection.schema_cache.clear! yield if block_given? ensure @connection.schema_search_path = "'$user', public" + @connection.schema_cache.clear! end end diff --git a/activerecord/test/cases/connection_adapters/schema_cache_test.rb b/activerecord/test/cases/connection_adapters/schema_cache_test.rb index c7531f5418..db832fe55d 100644 --- a/activerecord/test/cases/connection_adapters/schema_cache_test.rb +++ b/activerecord/test/cases/connection_adapters/schema_cache_test.rb @@ -29,7 +29,7 @@ module ActiveRecord def test_clearing @cache.columns('posts') @cache.columns_hash('posts') - @cache.tables('posts') + @cache.data_sources('posts') @cache.primary_keys('posts') @cache.clear! @@ -40,17 +40,22 @@ module ActiveRecord def test_dump_and_load @cache.columns('posts') @cache.columns_hash('posts') - @cache.tables('posts') + @cache.data_sources('posts') @cache.primary_keys('posts') @cache = Marshal.load(Marshal.dump(@cache)) assert_equal 11, @cache.columns('posts').size assert_equal 11, @cache.columns_hash('posts').size - assert @cache.tables('posts') + assert @cache.data_sources('posts') assert_equal 'id', @cache.primary_keys('posts') end + def test_table_methods_deprecation + assert_deprecated { assert @cache.table_exists?('posts') } + assert_deprecated { assert @cache.tables('posts') } + assert_deprecated { @cache.clear_table_cache!('posts') } + end end end end diff --git a/activerecord/test/cases/view_test.rb b/activerecord/test/cases/view_test.rb index d7b3e223ed..e80d8bd584 100644 --- a/activerecord/test/cases/view_test.rb +++ b/activerecord/test/cases/view_test.rb @@ -44,9 +44,15 @@ module ViewBehavior def test_table_exists view_name = Ebook.table_name + # TODO: switch this assertion around once we changed #tables to not return views. assert @connection.table_exists?(view_name), "'#{view_name}' table should exist" end + def test_views_ara_valid_data_sources + view_name = Ebook.table_name + assert @connection.data_source_exists?(view_name), "'#{view_name}' should be a data source" + end + def test_column_definitions assert_equal([["id", :integer], ["name", :string], |