diff options
Diffstat (limited to 'activerecord/test/cases/connection_adapters')
7 files changed, 193 insertions, 193 deletions
diff --git a/activerecord/test/cases/connection_adapters/adapter_leasing_test.rb b/activerecord/test/cases/connection_adapters/adapter_leasing_test.rb index c7ca428ab7..64189381cb 100644 --- a/activerecord/test/cases/connection_adapters/adapter_leasing_test.rb +++ b/activerecord/test/cases/connection_adapters/adapter_leasing_test.rb @@ -17,23 +17,23 @@ module ActiveRecord end def test_in_use? - assert_not @adapter.in_use?, 'adapter is not in use' - assert @adapter.lease, 'lease adapter' - assert @adapter.in_use?, 'adapter is in use' + assert_not @adapter.in_use?, "adapter is not in use" + assert @adapter.lease, "lease adapter" + assert @adapter.in_use?, "adapter is in use" end def test_lease_twice - assert @adapter.lease, 'should lease adapter' + assert @adapter.lease, "should lease adapter" assert_raises(ActiveRecordError) do @adapter.lease end end def test_expire_mutates_in_use - assert @adapter.lease, 'lease adapter' - assert @adapter.in_use?, 'adapter is in use' + assert @adapter.lease, "lease adapter" + assert @adapter.in_use?, "adapter is in use" @adapter.expire - assert_not @adapter.in_use?, 'adapter is in use' + assert_not @adapter.in_use?, "adapter is in use" end def test_close diff --git a/activerecord/test/cases/connection_adapters/connection_handler_test.rb b/activerecord/test/cases/connection_adapters/connection_handler_test.rb index a019cc6490..d5d16e7568 100644 --- a/activerecord/test/cases/connection_adapters/connection_handler_test.rb +++ b/activerecord/test/cases/connection_adapters/connection_handler_test.rb @@ -6,18 +6,18 @@ module ActiveRecord def setup @handler = ConnectionHandler.new @spec_name = "primary" - @pool = @handler.establish_connection(ActiveRecord::Base.configurations['arunit']) + @pool = @handler.establish_connection(ActiveRecord::Base.configurations["arunit"]) end def test_establish_connection_uses_spec_name - config = {"readonly" => {"adapter" => 'sqlite3'}} + config = { "readonly" => { "adapter" => "sqlite3" } } resolver = ConnectionAdapters::ConnectionSpecification::Resolver.new(config) spec = resolver.spec(:readonly) @handler.establish_connection(spec.to_hash) - assert_not_nil @handler.retrieve_connection_pool('readonly') + assert_not_nil @handler.retrieve_connection_pool("readonly") ensure - @handler.remove_connection('readonly') + @handler.remove_connection("readonly") end def test_retrieve_connection @@ -68,7 +68,7 @@ module ActiveRecord def test_retrieve_connection_pool_copies_schema_cache_from_ancestor_pool @pool.schema_cache = @pool.connection.schema_cache - @pool.schema_cache.add('posts') + @pool.schema_cache.add("posts") rd, wr = IO.pipe rd.binmode @@ -90,7 +90,7 @@ module ActiveRecord end def test_a_class_using_custom_pool_and_switching_back_to_primary - klass2 = Class.new(Base) { def self.name; 'klass2'; end } + klass2 = Class.new(Base) { def self.name; "klass2"; end } assert_equal klass2.connection.object_id, ActiveRecord::Base.connection.object_id @@ -113,7 +113,7 @@ module ActiveRecord end def test_remove_connection_should_not_remove_parent - klass2 = Class.new(Base) { def self.name; 'klass2'; end } + klass2 = Class.new(Base) { def self.name; "klass2"; end } klass2.remove_connection refute_nil ActiveRecord::Base.connection.object_id assert_equal klass2.connection.object_id, ActiveRecord::Base.connection.object_id diff --git a/activerecord/test/cases/connection_adapters/connection_specification_test.rb b/activerecord/test/cases/connection_adapters/connection_specification_test.rb index d204fce59f..10a3521c79 100644 --- a/activerecord/test/cases/connection_adapters/connection_specification_test.rb +++ b/activerecord/test/cases/connection_adapters/connection_specification_test.rb @@ -4,7 +4,7 @@ module ActiveRecord module ConnectionAdapters class ConnectionSpecificationTest < ActiveRecord::TestCase def test_dup_deep_copy_config - spec = ConnectionSpecification.new("primary", { :a => :b }, "bar") + spec = ConnectionSpecification.new("primary", { a: :b }, "bar") assert_not_equal(spec.config.object_id, spec.dup.config.object_id) end end diff --git a/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb b/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb index f25b85e8a7..4bb5c4f2e2 100644 --- a/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb +++ b/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb @@ -24,7 +24,7 @@ module ActiveRecord end def test_resolver_with_database_uri_and_current_env_symbol_key - ENV['DATABASE_URL'] = "postgres://localhost/foo" + ENV["DATABASE_URL"] = "postgres://localhost/foo" config = { "not_production" => { "adapter" => "not_postgres", "database" => "not_foo" } } actual = resolve_spec(:default_env, config) expected = { "adapter"=>"postgresql", "database"=>"foo", "host"=>"localhost", "name"=>"default_env" } @@ -32,8 +32,8 @@ module ActiveRecord end def test_resolver_with_database_uri_and_current_env_symbol_key_and_rails_env - ENV['DATABASE_URL'] = "postgres://localhost/foo" - ENV['RAILS_ENV'] = "foo" + ENV["DATABASE_URL"] = "postgres://localhost/foo" + ENV["RAILS_ENV"] = "foo" config = { "not_production" => { "adapter" => "not_postgres", "database" => "not_foo" } } actual = resolve_spec(:foo, config) @@ -42,8 +42,8 @@ module ActiveRecord end def test_resolver_with_database_uri_and_current_env_symbol_key_and_rack_env - ENV['DATABASE_URL'] = "postgres://localhost/foo" - ENV['RACK_ENV'] = "foo" + ENV["DATABASE_URL"] = "postgres://localhost/foo" + ENV["RACK_ENV"] = "foo" config = { "not_production" => { "adapter" => "not_postgres", "database" => "not_foo" } } actual = resolve_spec(:foo, config) @@ -52,7 +52,7 @@ module ActiveRecord end def test_resolver_with_database_uri_and_known_key - ENV['DATABASE_URL'] = "postgres://localhost/foo" + ENV["DATABASE_URL"] = "postgres://localhost/foo" config = { "production" => { "adapter" => "not_postgres", "database" => "not_foo", "host" => "localhost" } } actual = resolve_spec(:production, config) expected = { "adapter"=>"not_postgres", "database"=>"not_foo", "host"=>"localhost", "name"=>"production" } @@ -60,7 +60,7 @@ module ActiveRecord end def test_resolver_with_database_uri_and_unknown_symbol_key - ENV['DATABASE_URL'] = "postgres://localhost/foo" + ENV["DATABASE_URL"] = "postgres://localhost/foo" config = { "not_production" => { "adapter" => "not_postgres", "database" => "not_foo" } } assert_raises AdapterNotSpecified do resolve_spec(:production, config) @@ -68,7 +68,7 @@ module ActiveRecord end def test_resolver_with_database_uri_and_supplied_url - ENV['DATABASE_URL'] = "not-postgres://not-localhost/not_foo" + ENV["DATABASE_URL"] = "not-postgres://not-localhost/not_foo" config = { "production" => { "adapter" => "also_not_postgres", "database" => "also_not_foo" } } actual = resolve_spec("postgres://localhost/foo", config) expected = { "adapter"=>"postgresql", "database"=>"foo", "host"=>"localhost" } @@ -82,7 +82,7 @@ module ActiveRecord end def test_environment_does_not_exist_in_config_url_does_exist - ENV['DATABASE_URL'] = "postgres://localhost/foo" + ENV["DATABASE_URL"] = "postgres://localhost/foo" config = { "not_default_env" => { "adapter" => "not_postgres", "database" => "not_foo" } } actual = resolve_config(config) expect_prod = { "adapter"=>"postgresql", "database"=>"foo", "host"=>"localhost" } @@ -90,7 +90,7 @@ module ActiveRecord end def test_url_with_hyphenated_scheme - ENV['DATABASE_URL'] = "ibm-db://localhost/foo" + ENV["DATABASE_URL"] = "ibm-db://localhost/foo" config = { "default_env" => { "adapter" => "not_postgres", "database" => "not_foo", "host" => "localhost" } } actual = resolve_spec(:default_env, config) expected = { "adapter"=>"ibm_db", "database"=>"foo", "host"=>"localhost", "name"=>"default_env" } @@ -134,7 +134,7 @@ module ActiveRecord end def test_blank_with_database_url - ENV['DATABASE_URL'] = "postgres://localhost/foo" + ENV["DATABASE_URL"] = "postgres://localhost/foo" config = {} actual = resolve_config(config) @@ -152,8 +152,8 @@ module ActiveRecord end def test_blank_with_database_url_with_rails_env - ENV['RAILS_ENV'] = "not_production" - ENV['DATABASE_URL'] = "postgres://localhost/foo" + ENV["RAILS_ENV"] = "not_production" + ENV["DATABASE_URL"] = "postgres://localhost/foo" config = {} actual = resolve_config(config) @@ -174,8 +174,8 @@ module ActiveRecord end def test_blank_with_database_url_with_rack_env - ENV['RACK_ENV'] = "not_production" - ENV['DATABASE_URL'] = "postgres://localhost/foo" + ENV["RACK_ENV"] = "not_production" + ENV["DATABASE_URL"] = "postgres://localhost/foo" config = {} actual = resolve_config(config) @@ -196,7 +196,7 @@ module ActiveRecord end def test_database_url_with_ipv6_host_and_port - ENV['DATABASE_URL'] = "postgres://[::1]:5454/foo" + ENV["DATABASE_URL"] = "postgres://[::1]:5454/foo" config = {} actual = resolve_config(config) @@ -208,7 +208,7 @@ module ActiveRecord end def test_url_sub_key_with_database_url - ENV['DATABASE_URL'] = "NOT-POSTGRES://localhost/NOT_FOO" + ENV["DATABASE_URL"] = "NOT-POSTGRES://localhost/NOT_FOO" config = { "default_env" => { "url" => "postgres://localhost/foo" } } actual = resolve_config(config) @@ -222,9 +222,9 @@ module ActiveRecord end def test_merge_no_conflicts_with_database_url - ENV['DATABASE_URL'] = "postgres://localhost/foo" + ENV["DATABASE_URL"] = "postgres://localhost/foo" - config = {"default_env" => { "pool" => "5" } } + config = { "default_env" => { "pool" => "5" } } actual = resolve_config(config) expected = { "default_env" => { "adapter" => "postgresql", @@ -237,9 +237,9 @@ module ActiveRecord end def test_merge_conflicts_with_database_url - ENV['DATABASE_URL'] = "postgres://localhost/foo" + ENV["DATABASE_URL"] = "postgres://localhost/foo" - config = {"default_env" => { "adapter" => "NOT-POSTGRES", "database" => "NOT-FOO", "pool" => "5" } } + config = { "default_env" => { "adapter" => "NOT-POSTGRES", "database" => "NOT-FOO", "pool" => "5" } } actual = resolve_config(config) expected = { "default_env" => { "adapter" => "postgresql", diff --git a/activerecord/test/cases/connection_adapters/mysql_type_lookup_test.rb b/activerecord/test/cases/connection_adapters/mysql_type_lookup_test.rb index f2b1d9e4e7..3657b8340d 100644 --- a/activerecord/test/cases/connection_adapters/mysql_type_lookup_test.rb +++ b/activerecord/test/cases/connection_adapters/mysql_type_lookup_test.rb @@ -1,69 +1,69 @@ require "cases/helper" if current_adapter?(:Mysql2Adapter) -module ActiveRecord - module ConnectionAdapters - class MysqlTypeLookupTest < ActiveRecord::TestCase - setup do - @connection = ActiveRecord::Base.connection - end + module ActiveRecord + module ConnectionAdapters + class MysqlTypeLookupTest < ActiveRecord::TestCase + setup do + @connection = ActiveRecord::Base.connection + end - def test_boolean_types - emulate_booleans(true) do - assert_lookup_type :boolean, 'tinyint(1)' - assert_lookup_type :boolean, 'TINYINT(1)' + def test_boolean_types + emulate_booleans(true) do + assert_lookup_type :boolean, "tinyint(1)" + assert_lookup_type :boolean, "TINYINT(1)" + end end - end - def test_string_types - assert_lookup_type :string, "enum('one', 'two', 'three')" - assert_lookup_type :string, "ENUM('one', 'two', 'three')" - assert_lookup_type :string, "set('one', 'two', 'three')" - assert_lookup_type :string, "SET('one', 'two', 'three')" - end + def test_string_types + assert_lookup_type :string, "enum('one', 'two', 'three')" + assert_lookup_type :string, "ENUM('one', 'two', 'three')" + assert_lookup_type :string, "set('one', 'two', 'three')" + assert_lookup_type :string, "SET('one', 'two', 'three')" + end - def test_set_type_with_value_matching_other_type - assert_lookup_type :string, "SET('unicode', '8bit', 'none', 'time')" - end + def test_set_type_with_value_matching_other_type + assert_lookup_type :string, "SET('unicode', '8bit', 'none', 'time')" + end - def test_enum_type_with_value_matching_other_type - assert_lookup_type :string, "ENUM('unicode', '8bit', 'none')" - end + def test_enum_type_with_value_matching_other_type + assert_lookup_type :string, "ENUM('unicode', '8bit', 'none')" + end - def test_binary_types - assert_lookup_type :binary, 'bit' - assert_lookup_type :binary, 'BIT' - end + def test_binary_types + assert_lookup_type :binary, "bit" + assert_lookup_type :binary, "BIT" + end - def test_integer_types - emulate_booleans(false) do - assert_lookup_type :integer, 'tinyint(1)' - assert_lookup_type :integer, 'TINYINT(1)' - assert_lookup_type :integer, 'year' - assert_lookup_type :integer, 'YEAR' + def test_integer_types + emulate_booleans(false) do + assert_lookup_type :integer, "tinyint(1)" + assert_lookup_type :integer, "TINYINT(1)" + assert_lookup_type :integer, "year" + assert_lookup_type :integer, "YEAR" + end end - end - private + private - def assert_lookup_type(type, lookup) - cast_type = @connection.type_map.lookup(lookup) - assert_equal type, cast_type.type - end + def assert_lookup_type(type, lookup) + cast_type = @connection.type_map.lookup(lookup) + assert_equal type, cast_type.type + end - def emulate_booleans(value) - old_emulate_booleans = @connection.emulate_booleans - change_emulate_booleans(value) - yield - ensure - change_emulate_booleans(old_emulate_booleans) - end + def emulate_booleans(value) + old_emulate_booleans = @connection.emulate_booleans + change_emulate_booleans(value) + yield + ensure + change_emulate_booleans(old_emulate_booleans) + end - def change_emulate_booleans(value) - @connection.emulate_booleans = value - @connection.clear_cache! + def change_emulate_booleans(value) + @connection.emulate_booleans = value + @connection.clear_cache! + end end end end 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 db832fe55d..d4459603af 100644 --- a/activerecord/test/cases/connection_adapters/schema_cache_test.rb +++ b/activerecord/test/cases/connection_adapters/schema_cache_test.rb @@ -9,28 +9,28 @@ module ActiveRecord end def test_primary_key - assert_equal 'id', @cache.primary_keys('posts') + assert_equal "id", @cache.primary_keys("posts") end def test_primary_key_for_non_existent_table - assert_nil @cache.primary_keys('omgponies') + assert_nil @cache.primary_keys("omgponies") end def test_caches_columns - columns = @cache.columns('posts') - assert_equal columns, @cache.columns('posts') + 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') + 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.data_sources('posts') - @cache.primary_keys('posts') + @cache.columns("posts") + @cache.columns_hash("posts") + @cache.data_sources("posts") + @cache.primary_keys("posts") @cache.clear! @@ -38,23 +38,23 @@ module ActiveRecord end def test_dump_and_load - @cache.columns('posts') - @cache.columns_hash('posts') - @cache.data_sources('posts') - @cache.primary_keys('posts') + @cache.columns("posts") + @cache.columns_hash("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.data_sources('posts') - assert_equal 'id', @cache.primary_keys('posts') + 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 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') } + assert_deprecated { assert @cache.table_exists?("posts") } + assert_deprecated { assert @cache.tables("posts") } + assert_deprecated { @cache.clear_table_cache!("posts") } end end end diff --git a/activerecord/test/cases/connection_adapters/type_lookup_test.rb b/activerecord/test/cases/connection_adapters/type_lookup_test.rb index 3acbafbff4..e2e5445a4e 100644 --- a/activerecord/test/cases/connection_adapters/type_lookup_test.rb +++ b/activerecord/test/cases/connection_adapters/type_lookup_test.rb @@ -1,110 +1,110 @@ require "cases/helper" unless current_adapter?(:PostgreSQLAdapter) # PostgreSQL does not use type strings for lookup -module ActiveRecord - module ConnectionAdapters - class TypeLookupTest < ActiveRecord::TestCase - setup do - @connection = ActiveRecord::Base.connection - end + module ActiveRecord + module ConnectionAdapters + class TypeLookupTest < ActiveRecord::TestCase + setup do + @connection = ActiveRecord::Base.connection + end - def test_boolean_types - assert_lookup_type :boolean, 'boolean' - assert_lookup_type :boolean, 'BOOLEAN' - end + def test_boolean_types + assert_lookup_type :boolean, "boolean" + assert_lookup_type :boolean, "BOOLEAN" + end - def test_string_types - assert_lookup_type :string, 'char' - assert_lookup_type :string, 'varchar' - assert_lookup_type :string, 'VARCHAR' - assert_lookup_type :string, 'varchar(255)' - assert_lookup_type :string, 'character varying' - end + def test_string_types + assert_lookup_type :string, "char" + assert_lookup_type :string, "varchar" + assert_lookup_type :string, "VARCHAR" + assert_lookup_type :string, "varchar(255)" + assert_lookup_type :string, "character varying" + end - def test_binary_types - assert_lookup_type :binary, 'binary' - assert_lookup_type :binary, 'BINARY' - assert_lookup_type :binary, 'blob' - assert_lookup_type :binary, 'BLOB' - end + def test_binary_types + assert_lookup_type :binary, "binary" + assert_lookup_type :binary, "BINARY" + assert_lookup_type :binary, "blob" + assert_lookup_type :binary, "BLOB" + end - def test_text_types - assert_lookup_type :text, 'text' - assert_lookup_type :text, 'TEXT' - assert_lookup_type :text, 'clob' - assert_lookup_type :text, 'CLOB' - end + def test_text_types + assert_lookup_type :text, "text" + assert_lookup_type :text, "TEXT" + assert_lookup_type :text, "clob" + assert_lookup_type :text, "CLOB" + end - def test_date_types - assert_lookup_type :date, 'date' - assert_lookup_type :date, 'DATE' - end + def test_date_types + assert_lookup_type :date, "date" + assert_lookup_type :date, "DATE" + end - def test_time_types - assert_lookup_type :time, 'time' - assert_lookup_type :time, 'TIME' - end + def test_time_types + assert_lookup_type :time, "time" + assert_lookup_type :time, "TIME" + end - def test_datetime_types - assert_lookup_type :datetime, 'datetime' - assert_lookup_type :datetime, 'DATETIME' - assert_lookup_type :datetime, 'timestamp' - assert_lookup_type :datetime, 'TIMESTAMP' - end + def test_datetime_types + assert_lookup_type :datetime, "datetime" + assert_lookup_type :datetime, "DATETIME" + assert_lookup_type :datetime, "timestamp" + assert_lookup_type :datetime, "TIMESTAMP" + end - def test_decimal_types - assert_lookup_type :decimal, 'decimal' - assert_lookup_type :decimal, 'decimal(2,8)' - assert_lookup_type :decimal, 'DECIMAL' - assert_lookup_type :decimal, 'numeric' - assert_lookup_type :decimal, 'numeric(2,8)' - assert_lookup_type :decimal, 'NUMERIC' - assert_lookup_type :decimal, 'number' - assert_lookup_type :decimal, 'number(2,8)' - assert_lookup_type :decimal, 'NUMBER' - end + def test_decimal_types + assert_lookup_type :decimal, "decimal" + assert_lookup_type :decimal, "decimal(2,8)" + assert_lookup_type :decimal, "DECIMAL" + assert_lookup_type :decimal, "numeric" + assert_lookup_type :decimal, "numeric(2,8)" + assert_lookup_type :decimal, "NUMERIC" + assert_lookup_type :decimal, "number" + assert_lookup_type :decimal, "number(2,8)" + assert_lookup_type :decimal, "NUMBER" + end - def test_float_types - assert_lookup_type :float, 'float' - assert_lookup_type :float, 'FLOAT' - assert_lookup_type :float, 'double' - assert_lookup_type :float, 'DOUBLE' - end + def test_float_types + assert_lookup_type :float, "float" + assert_lookup_type :float, "FLOAT" + assert_lookup_type :float, "double" + assert_lookup_type :float, "DOUBLE" + end - def test_integer_types - assert_lookup_type :integer, 'integer' - assert_lookup_type :integer, 'INTEGER' - assert_lookup_type :integer, 'tinyint' - assert_lookup_type :integer, 'smallint' - assert_lookup_type :integer, 'bigint' - end + def test_integer_types + assert_lookup_type :integer, "integer" + assert_lookup_type :integer, "INTEGER" + assert_lookup_type :integer, "tinyint" + assert_lookup_type :integer, "smallint" + assert_lookup_type :integer, "bigint" + end - def test_bigint_limit - cast_type = @connection.type_map.lookup("bigint") - if current_adapter?(:OracleAdapter) - assert_equal 19, cast_type.limit - else - assert_equal 8, cast_type.limit + def test_bigint_limit + cast_type = @connection.type_map.lookup("bigint") + if current_adapter?(:OracleAdapter) + assert_equal 19, cast_type.limit + else + assert_equal 8, cast_type.limit + end end - end - def test_decimal_without_scale - types = %w{decimal(2) decimal(2,0) numeric(2) numeric(2,0) number(2) number(2,0)} - types.each do |type| - cast_type = @connection.type_map.lookup(type) + def test_decimal_without_scale + types = %w{decimal(2) decimal(2,0) numeric(2) numeric(2,0) number(2) number(2,0)} + types.each do |type| + cast_type = @connection.type_map.lookup(type) - assert_equal :decimal, cast_type.type - assert_equal 2, cast_type.cast(2.1) + assert_equal :decimal, cast_type.type + assert_equal 2, cast_type.cast(2.1) + end end - end - private + private - def assert_lookup_type(type, lookup) - cast_type = @connection.type_map.lookup(lookup) - assert_equal type, cast_type.type + def assert_lookup_type(type, lookup) + cast_type = @connection.type_map.lookup(lookup) + assert_equal type, cast_type.type + end end end end end -end |