diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-06-04 23:19:17 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-06-04 23:47:03 +0100 |
commit | 253bb6b9260938ed673e2c0059d729cffff4a523 (patch) | |
tree | cf8aa429645a0c73d32e8fe0eecf62a536488bdd /activerecord/test | |
parent | cdce7ff191313bd99a31d26ddca5a5c8be766695 (diff) | |
download | rails-253bb6b9260938ed673e2c0059d729cffff4a523.tar.gz rails-253bb6b9260938ed673e2c0059d729cffff4a523.tar.bz2 rails-253bb6b9260938ed673e2c0059d729cffff4a523.zip |
Refactor Active Record test connection setup. Please see the RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
Diffstat (limited to 'activerecord/test')
164 files changed, 343 insertions, 534 deletions
diff --git a/activerecord/test/.gitignore b/activerecord/test/.gitignore new file mode 100644 index 0000000000..a0ec5967dd --- /dev/null +++ b/activerecord/test/.gitignore @@ -0,0 +1 @@ +/config.yml diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb index 49b2e945c3..295d78284e 100644 --- a/activerecord/test/cases/adapter_test.rb +++ b/activerecord/test/cases/adapter_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) class AdapterTest < ActiveRecord::TestCase def setup diff --git a/activerecord/test/cases/adapters/firebird/connection_test.rb b/activerecord/test/cases/adapters/firebird/connection_test.rb index f57ea686a5..47e8859ac6 100644 --- a/activerecord/test/cases/adapters/firebird/connection_test.rb +++ b/activerecord/test/cases/adapters/firebird/connection_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) class FirebirdConnectionTest < ActiveRecord::TestCase def test_charset_properly_set diff --git a/activerecord/test/cases/adapters/firebird/default_test.rb b/activerecord/test/cases/adapters/firebird/default_test.rb index 713c7e11bf..2d5e45dd74 100644 --- a/activerecord/test/cases/adapters/firebird/default_test.rb +++ b/activerecord/test/cases/adapters/firebird/default_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) require 'models/default' class DefaultTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/adapters/firebird/migration_test.rb b/activerecord/test/cases/adapters/firebird/migration_test.rb index 5c94593765..0fe3d4a858 100644 --- a/activerecord/test/cases/adapters/firebird/migration_test.rb +++ b/activerecord/test/cases/adapters/firebird/migration_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) require 'models/course' class FirebirdMigrationTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/adapters/mysql/active_schema_test.rb b/activerecord/test/cases/adapters/mysql/active_schema_test.rb index 509baacaef..c817b259b4 100644 --- a/activerecord/test/cases/adapters/mysql/active_schema_test.rb +++ b/activerecord/test/cases/adapters/mysql/active_schema_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) class ActiveSchemaTest < ActiveRecord::TestCase def setup diff --git a/activerecord/test/cases/adapters/mysql/connection_test.rb b/activerecord/test/cases/adapters/mysql/connection_test.rb index eee771ecff..703eb5a8bd 100644 --- a/activerecord/test/cases/adapters/mysql/connection_test.rb +++ b/activerecord/test/cases/adapters/mysql/connection_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) class MysqlConnectionTest < ActiveRecord::TestCase def setup diff --git a/activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb b/activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb index 146b77a95c..756115e5c9 100644 --- a/activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb +++ b/activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb @@ -1,6 +1,6 @@ # encoding: utf-8 -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) module ActiveRecord module ConnectionAdapters diff --git a/activerecord/test/cases/adapters/mysql/quoting_test.rb b/activerecord/test/cases/adapters/mysql/quoting_test.rb index 9673e2bb46..7933800440 100644 --- a/activerecord/test/cases/adapters/mysql/quoting_test.rb +++ b/activerecord/test/cases/adapters/mysql/quoting_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) module ActiveRecord module ConnectionAdapters @@ -23,4 +23,3 @@ module ActiveRecord end end end - diff --git a/activerecord/test/cases/adapters/mysql/reserved_word_test.rb b/activerecord/test/cases/adapters/mysql/reserved_word_test.rb index 292c7efebb..2750831b93 100644 --- a/activerecord/test/cases/adapters/mysql/reserved_word_test.rb +++ b/activerecord/test/cases/adapters/mysql/reserved_word_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) class Group < ActiveRecord::Base Group.table_name = 'group' diff --git a/activerecord/test/cases/adapters/mysql/schema_test.rb b/activerecord/test/cases/adapters/mysql/schema_test.rb index a2155d1dd1..8b26d303bf 100644 --- a/activerecord/test/cases/adapters/mysql/schema_test.rb +++ b/activerecord/test/cases/adapters/mysql/schema_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) require 'models/post' require 'models/comment' diff --git a/activerecord/test/cases/adapters/mysql/sp_test.rb b/activerecord/test/cases/adapters/mysql/sp_test.rb index 3ca2917ca4..baa44fab70 100644 --- a/activerecord/test/cases/adapters/mysql/sp_test.rb +++ b/activerecord/test/cases/adapters/mysql/sp_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) require 'models/topic' class StoredProcedureTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/adapters/mysql2/active_schema_test.rb b/activerecord/test/cases/adapters/mysql2/active_schema_test.rb index a83399d0cd..ca716f7016 100644 --- a/activerecord/test/cases/adapters/mysql2/active_schema_test.rb +++ b/activerecord/test/cases/adapters/mysql2/active_schema_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) class ActiveSchemaTest < ActiveRecord::TestCase def setup diff --git a/activerecord/test/cases/adapters/mysql2/bind_parameter_test.rb b/activerecord/test/cases/adapters/mysql2/bind_parameter_test.rb index cd9c1041dc..7bb35d755a 100644 --- a/activerecord/test/cases/adapters/mysql2/bind_parameter_test.rb +++ b/activerecord/test/cases/adapters/mysql2/bind_parameter_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) require 'models/topic' module ActiveRecord diff --git a/activerecord/test/cases/adapters/mysql2/connection_test.rb b/activerecord/test/cases/adapters/mysql2/connection_test.rb index 26091c713b..1c523dad69 100644 --- a/activerecord/test/cases/adapters/mysql2/connection_test.rb +++ b/activerecord/test/cases/adapters/mysql2/connection_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) class MysqlConnectionTest < ActiveRecord::TestCase def setup diff --git a/activerecord/test/cases/adapters/mysql2/reserved_word_test.rb b/activerecord/test/cases/adapters/mysql2/reserved_word_test.rb index 752b864818..9cb30b0fd1 100644 --- a/activerecord/test/cases/adapters/mysql2/reserved_word_test.rb +++ b/activerecord/test/cases/adapters/mysql2/reserved_word_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) class Group < ActiveRecord::Base Group.table_name = 'group' diff --git a/activerecord/test/cases/adapters/mysql2/schema_test.rb b/activerecord/test/cases/adapters/mysql2/schema_test.rb index 858d1da2dd..ec89972360 100644 --- a/activerecord/test/cases/adapters/mysql2/schema_test.rb +++ b/activerecord/test/cases/adapters/mysql2/schema_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) require 'models/post' require 'models/comment' diff --git a/activerecord/test/cases/adapters/oracle/synonym_test.rb b/activerecord/test/cases/adapters/oracle/synonym_test.rb index b9a422a6ca..4cbca6dcb2 100644 --- a/activerecord/test/cases/adapters/oracle/synonym_test.rb +++ b/activerecord/test/cases/adapters/oracle/synonym_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) require 'models/topic' require 'models/subject' diff --git a/activerecord/test/cases/adapters/postgresql/active_schema_test.rb b/activerecord/test/cases/adapters/postgresql/active_schema_test.rb index e4746d4aa3..1802e2be24 100644 --- a/activerecord/test/cases/adapters/postgresql/active_schema_test.rb +++ b/activerecord/test/cases/adapters/postgresql/active_schema_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../../../helper', __FILE__) class PostgresqlActiveSchemaTest < ActiveRecord::TestCase def setup diff --git a/activerecord/test/cases/adapters/postgresql/datatype_test.rb b/activerecord/test/cases/adapters/postgresql/datatype_test.rb index ce08e4c6a7..c383e8b6fb 100644 --- a/activerecord/test/cases/adapters/postgresql/datatype_test.rb +++ b/activerecord/test/cases/adapters/postgresql/datatype_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) class PostgresqlArray < ActiveRecord::Base end diff --git a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb index 7c49236854..14e78ed982 100644 --- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb +++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb @@ -1,5 +1,5 @@ # encoding: utf-8 -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) module ActiveRecord module ConnectionAdapters diff --git a/activerecord/test/cases/adapters/postgresql/quoting_test.rb b/activerecord/test/cases/adapters/postgresql/quoting_test.rb index 172055f15c..e95d10c594 100644 --- a/activerecord/test/cases/adapters/postgresql/quoting_test.rb +++ b/activerecord/test/cases/adapters/postgresql/quoting_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) module ActiveRecord module ConnectionAdapters diff --git a/activerecord/test/cases/adapters/postgresql/schema_authorization_test.rb b/activerecord/test/cases/adapters/postgresql/schema_authorization_test.rb index d5e1838543..8b9c4d337a 100644 --- a/activerecord/test/cases/adapters/postgresql/schema_authorization_test.rb +++ b/activerecord/test/cases/adapters/postgresql/schema_authorization_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) class SchemaThing < ActiveRecord::Base end diff --git a/activerecord/test/cases/adapters/postgresql/schema_test.rb b/activerecord/test/cases/adapters/postgresql/schema_test.rb index a5c3e69af9..6f3dba4168 100644 --- a/activerecord/test/cases/adapters/postgresql/schema_test.rb +++ b/activerecord/test/cases/adapters/postgresql/schema_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) class SchemaTest < ActiveRecord::TestCase self.use_transactional_fixtures = false diff --git a/activerecord/test/cases/adapters/postgresql/timestamp_test.rb b/activerecord/test/cases/adapters/postgresql/timestamp_test.rb index 337f43c421..fb4616dc76 100644 --- a/activerecord/test/cases/adapters/postgresql/timestamp_test.rb +++ b/activerecord/test/cases/adapters/postgresql/timestamp_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../../../helper', __FILE__) require 'models/developer' class TimestampTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/adapters/sqlite3/copy_table_test.rb b/activerecord/test/cases/adapters/sqlite3/copy_table_test.rb index 575b4806c1..899df1d59a 100644 --- a/activerecord/test/cases/adapters/sqlite3/copy_table_test.rb +++ b/activerecord/test/cases/adapters/sqlite3/copy_table_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) class CopyTableTest < ActiveRecord::TestCase fixtures :customers, :companies, :comments diff --git a/activerecord/test/cases/adapters/sqlite3/quoting_test.rb b/activerecord/test/cases/adapters/sqlite3/quoting_test.rb index 0d9db92447..51f01c262d 100644 --- a/activerecord/test/cases/adapters/sqlite3/quoting_test.rb +++ b/activerecord/test/cases/adapters/sqlite3/quoting_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) require 'bigdecimal' require 'yaml' diff --git a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb index 6ff04e3eb3..d58a804815 100644 --- a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +++ b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb @@ -1,5 +1,5 @@ # encoding: utf-8 -require "cases/helper" +require File.expand_path('../../../helper', __FILE__) module ActiveRecord module ConnectionAdapters diff --git a/activerecord/test/cases/aggregations_test.rb b/activerecord/test/cases/aggregations_test.rb index 3e0e6dce2c..d296364d7f 100644 --- a/activerecord/test/cases/aggregations_test.rb +++ b/activerecord/test/cases/aggregations_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/customer' require 'active_support/core_ext/exception' diff --git a/activerecord/test/cases/ar_schema_test.rb b/activerecord/test/cases/ar_schema_test.rb index 588adc38e3..eb4488899f 100644 --- a/activerecord/test/cases/ar_schema_test.rb +++ b/activerecord/test/cases/ar_schema_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) if ActiveRecord::Base.connection.supports_migrations? diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb index 5a900e0605..d7293aa1e3 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/developer' require 'models/project' require 'models/company' diff --git a/activerecord/test/cases/associations/callbacks_test.rb b/activerecord/test/cases/associations/callbacks_test.rb index 2d0d4541b4..387a25b7b1 100644 --- a/activerecord/test/cases/associations/callbacks_test.rb +++ b/activerecord/test/cases/associations/callbacks_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/post' require 'models/author' require 'models/project' diff --git a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb index ff376a68d8..d21afff978 100644 --- a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb +++ b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/post' require 'models/comment' require 'models/author' diff --git a/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb b/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb index d75791cab9..41cf745f91 100644 --- a/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb +++ b/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../../helper', __FILE__) require 'models/post' require 'models/tagging' diff --git a/activerecord/test/cases/associations/eager_load_nested_include_test.rb b/activerecord/test/cases/associations/eager_load_nested_include_test.rb index 2cf9f89c3c..de1f47873f 100644 --- a/activerecord/test/cases/associations/eager_load_nested_include_test.rb +++ b/activerecord/test/cases/associations/eager_load_nested_include_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../../helper', __FILE__) require 'models/post' require 'models/tag' require 'models/author' diff --git a/activerecord/test/cases/associations/eager_singularization_test.rb b/activerecord/test/cases/associations/eager_singularization_test.rb index 07d0b24613..ffb5411a5b 100644 --- a/activerecord/test/cases/associations/eager_singularization_test.rb +++ b/activerecord/test/cases/associations/eager_singularization_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) class Virus < ActiveRecord::Base belongs_to :octopus diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index 325fc58958..945edad48a 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/post' require 'models/tagging' require 'models/tag' diff --git a/activerecord/test/cases/associations/extension_test.rb b/activerecord/test/cases/associations/extension_test.rb index 24830a661a..c0a8f74834 100644 --- a/activerecord/test/cases/associations/extension_test.rb +++ b/activerecord/test/cases/associations/extension_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/post' require 'models/comment' require 'models/project' diff --git a/activerecord/test/cases/associations/habtm_join_table_test.rb b/activerecord/test/cases/associations/habtm_join_table_test.rb index fe2b82f2c1..cc0a6cd6c2 100644 --- a/activerecord/test/cases/associations/habtm_join_table_test.rb +++ b/activerecord/test/cases/associations/habtm_join_table_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../../helper', __FILE__) class MyReader < ActiveRecord::Base has_and_belongs_to_many :my_books diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index e5735988d0..171177ad1d 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/developer' require 'models/project' require 'models/company' @@ -100,7 +100,7 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase assert_equal 'c1', record[0] assert_equal 't1', record[1] end - + def test_proper_usage_of_primary_keys_and_join_table setup_data_for_habtm_case diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 49999630b6..b87a1744c1 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/developer' require 'models/project' require 'models/company' diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index 877148bd5e..476bc637f6 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/post' require 'models/person' require 'models/reference' diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb index 299688d840..9bafe0f57d 100644 --- a/activerecord/test/cases/associations/has_one_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_associations_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/developer' require 'models/project' require 'models/company' diff --git a/activerecord/test/cases/associations/has_one_through_associations_test.rb b/activerecord/test/cases/associations/has_one_through_associations_test.rb index 2503349c08..24576fb580 100644 --- a/activerecord/test/cases/associations/has_one_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_through_associations_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/club' require 'models/member_type' require 'models/member' diff --git a/activerecord/test/cases/associations/identity_map_test.rb b/activerecord/test/cases/associations/identity_map_test.rb index 9b8635774c..0dd6c76efd 100644 --- a/activerecord/test/cases/associations/identity_map_test.rb +++ b/activerecord/test/cases/associations/identity_map_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/author' require 'models/post' diff --git a/activerecord/test/cases/associations/inner_join_association_test.rb b/activerecord/test/cases/associations/inner_join_association_test.rb index e5e9ca6131..1c0fe8368f 100644 --- a/activerecord/test/cases/associations/inner_join_association_test.rb +++ b/activerecord/test/cases/associations/inner_join_association_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/post' require 'models/comment' require 'models/author' diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb index 76282213d8..9e4975566b 100644 --- a/activerecord/test/cases/associations/inverse_associations_test.rb +++ b/activerecord/test/cases/associations/inverse_associations_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/man' require 'models/face' require 'models/interest' diff --git a/activerecord/test/cases/associations/join_model_test.rb b/activerecord/test/cases/associations/join_model_test.rb index b59ce4efeb..c869e6fbc5 100644 --- a/activerecord/test/cases/associations/join_model_test.rb +++ b/activerecord/test/cases/associations/join_model_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'active_support/core_ext/object/inclusion' require 'models/tag' require 'models/tagging' diff --git a/activerecord/test/cases/associations/nested_through_associations_test.rb b/activerecord/test/cases/associations/nested_through_associations_test.rb index dd450a2a8e..b13b8d5e36 100644 --- a/activerecord/test/cases/associations/nested_through_associations_test.rb +++ b/activerecord/test/cases/associations/nested_through_associations_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/author' require 'models/post' require 'models/person' diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb index 49d82ba2df..8bff37907d 100644 --- a/activerecord/test/cases/associations_test.rb +++ b/activerecord/test/cases/associations_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/developer' require 'models/project' require 'models/company' diff --git a/activerecord/test/cases/attribute_methods/read_test.rb b/activerecord/test/cases/attribute_methods/read_test.rb index 3641031d12..bb0dcb2a77 100644 --- a/activerecord/test/cases/attribute_methods/read_test.rb +++ b/activerecord/test/cases/attribute_methods/read_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'active_support/core_ext/object/inclusion' module ActiveRecord diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index b0896fb236..bf6408be0f 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'active_support/core_ext/object/inclusion' require 'models/minimalistic' require 'models/developer' diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index 8f55b7ebe6..b14c458435 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../helper', __FILE__) require 'models/bird' require 'models/company' require 'models/customer' diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 2224097f04..5eb9a825b7 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/post' require 'models/author' require 'models/topic' diff --git a/activerecord/test/cases/batches_test.rb b/activerecord/test/cases/batches_test.rb index 6620464d6a..31e00c998c 100644 --- a/activerecord/test/cases/batches_test.rb +++ b/activerecord/test/cases/batches_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../helper', __FILE__) require 'models/post' class EachTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/binary_test.rb b/activerecord/test/cases/binary_test.rb index 06c14cb108..365c16679e 100644 --- a/activerecord/test/cases/binary_test.rb +++ b/activerecord/test/cases/binary_test.rb @@ -1,5 +1,5 @@ # encoding: utf-8 -require "cases/helper" +require File.expand_path('../helper', __FILE__) # Without using prepared statements, it makes no sense to test # BLOB data with DB2 or Firebird, because the length of a statement diff --git a/activerecord/test/cases/bind_parameter_test.rb b/activerecord/test/cases/bind_parameter_test.rb index 3652255c38..bfd4c2afdf 100644 --- a/activerecord/test/cases/bind_parameter_test.rb +++ b/activerecord/test/cases/bind_parameter_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../helper', __FILE__) require 'models/topic' module ActiveRecord diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 56f6d795b6..cedd5c3d41 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/company' require 'models/topic' require 'models/edge' diff --git a/activerecord/test/cases/callbacks_test.rb b/activerecord/test/cases/callbacks_test.rb index 7f4d25790b..c2b43438fc 100644 --- a/activerecord/test/cases/callbacks_test.rb +++ b/activerecord/test/cases/callbacks_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) class CallbackDeveloper < ActiveRecord::Base set_table_name 'developers' diff --git a/activerecord/test/cases/clone_test.rb b/activerecord/test/cases/clone_test.rb index d91646efca..b25340c205 100644 --- a/activerecord/test/cases/clone_test.rb +++ b/activerecord/test/cases/clone_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/topic' module ActiveRecord diff --git a/activerecord/test/cases/coders/yaml_column_test.rb b/activerecord/test/cases/coders/yaml_column_test.rb index c7dcc21809..55aba713e8 100644 --- a/activerecord/test/cases/coders/yaml_column_test.rb +++ b/activerecord/test/cases/coders/yaml_column_test.rb @@ -1,5 +1,4 @@ - -require "cases/helper" +require File.expand_path('../../helper', __FILE__) module ActiveRecord module Coders diff --git a/activerecord/test/cases/column_alias_test.rb b/activerecord/test/cases/column_alias_test.rb index 40707d9cb2..1b6ac870e4 100644 --- a/activerecord/test/cases/column_alias_test.rb +++ b/activerecord/test/cases/column_alias_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/topic' class TestColumnAlias < ActiveRecord::TestCase diff --git a/activerecord/test/cases/column_definition_test.rb b/activerecord/test/cases/column_definition_test.rb index d1dddd4c2c..4d046eb9ba 100644 --- a/activerecord/test/cases/column_definition_test.rb +++ b/activerecord/test/cases/column_definition_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) module ActiveRecord module ConnectionAdapters diff --git a/activerecord/test/cases/connection_adapters/connection_handler_test.rb b/activerecord/test/cases/connection_adapters/connection_handler_test.rb index abf317768f..0bf33f86cf 100644 --- a/activerecord/test/cases/connection_adapters/connection_handler_test.rb +++ b/activerecord/test/cases/connection_adapters/connection_handler_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) module ActiveRecord module ConnectionAdapters diff --git a/activerecord/test/cases/connection_management_test.rb b/activerecord/test/cases/connection_management_test.rb index 85871aebdf..2b2deb6732 100644 --- a/activerecord/test/cases/connection_management_test.rb +++ b/activerecord/test/cases/connection_management_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) module ActiveRecord module ConnectionAdapters diff --git a/activerecord/test/cases/connection_pool_test.rb b/activerecord/test/cases/connection_pool_test.rb index f92f4e62c5..7aa765dc4f 100644 --- a/activerecord/test/cases/connection_pool_test.rb +++ b/activerecord/test/cases/connection_pool_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) module ActiveRecord module ConnectionAdapters diff --git a/activerecord/test/cases/counter_cache_test.rb b/activerecord/test/cases/counter_cache_test.rb index 3ed96a3ec8..31faef5f0f 100644 --- a/activerecord/test/cases/counter_cache_test.rb +++ b/activerecord/test/cases/counter_cache_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../helper', __FILE__) require 'models/topic' require 'models/car' require 'models/wheel' diff --git a/activerecord/test/cases/custom_locking_test.rb b/activerecord/test/cases/custom_locking_test.rb index d63ecdbcc5..1d4385eac0 100644 --- a/activerecord/test/cases/custom_locking_test.rb +++ b/activerecord/test/cases/custom_locking_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/person' module ActiveRecord diff --git a/activerecord/test/cases/database_statements_test.rb b/activerecord/test/cases/database_statements_test.rb index c689e97d83..8fa2c9ca44 100644 --- a/activerecord/test/cases/database_statements_test.rb +++ b/activerecord/test/cases/database_statements_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) class DatabaseStatementsTest < ActiveRecord::TestCase def setup diff --git a/activerecord/test/cases/date_time_test.rb b/activerecord/test/cases/date_time_test.rb index 3deb0dac99..a9e477bd76 100644 --- a/activerecord/test/cases/date_time_test.rb +++ b/activerecord/test/cases/date_time_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/topic' require 'models/task' diff --git a/activerecord/test/cases/defaults_test.rb b/activerecord/test/cases/defaults_test.rb index b3a281d960..8cf008871b 100644 --- a/activerecord/test/cases/defaults_test.rb +++ b/activerecord/test/cases/defaults_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'active_support/core_ext/object/inclusion' require 'models/default' require 'models/entrant' diff --git a/activerecord/test/cases/deprecated_finder_test.rb b/activerecord/test/cases/deprecated_finder_test.rb index 2afc91b769..1819bfc5ca 100644 --- a/activerecord/test/cases/deprecated_finder_test.rb +++ b/activerecord/test/cases/deprecated_finder_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/entrant' class DeprecatedFinderTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb index b1ce846218..7d58781eca 100644 --- a/activerecord/test/cases/dirty_test.rb +++ b/activerecord/test/cases/dirty_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../helper', __FILE__) require 'models/topic' # For booleans require 'models/pirate' # For timestamps require 'models/parrot' diff --git a/activerecord/test/cases/dup_test.rb b/activerecord/test/cases/dup_test.rb index 0236f9b0a1..9acf5fdd32 100644 --- a/activerecord/test/cases/dup_test.rb +++ b/activerecord/test/cases/dup_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/topic' module ActiveRecord diff --git a/activerecord/test/cases/dynamic_finder_match_test.rb b/activerecord/test/cases/dynamic_finder_match_test.rb index e576870317..693a8e2180 100644 --- a/activerecord/test/cases/dynamic_finder_match_test.rb +++ b/activerecord/test/cases/dynamic_finder_match_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) module ActiveRecord class DynamicFinderMatchTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/finder_respond_to_test.rb b/activerecord/test/cases/finder_respond_to_test.rb index 235805a67c..7952e9a46a 100644 --- a/activerecord/test/cases/finder_respond_to_test.rb +++ b/activerecord/test/cases/finder_respond_to_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/topic' class FinderRespondToTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 4e75eafe3d..3920f306f9 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/post' require 'models/author' require 'models/categorization' diff --git a/activerecord/test/cases/fixtures/file_test.rb b/activerecord/test/cases/fixtures/file_test.rb index 8dbf92ae9a..9ff4455394 100644 --- a/activerecord/test/cases/fixtures/file_test.rb +++ b/activerecord/test/cases/fixtures/file_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'tempfile' module ActiveRecord diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index 306b437fb3..e645a9a47c 100644 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/post' require 'models/binary' require 'models/topic' diff --git a/activerecord/test/cases/habtm_destroy_order_test.rb b/activerecord/test/cases/habtm_destroy_order_test.rb index f2b91d977e..776ed3f517 100644 --- a/activerecord/test/cases/habtm_destroy_order_test.rb +++ b/activerecord/test/cases/habtm_destroy_order_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require "models/lesson" require "models/student" diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index 9644ac1b02..7a214fa75a 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -1,5 +1,8 @@ require File.expand_path('../../../../load_paths', __FILE__) +test = File.expand_path('../..', __FILE__) +$:.unshift(test) unless $:.include?('test') || $:.include?(test) + lib = File.expand_path("#{File.dirname(__FILE__)}/../../lib") $:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) @@ -11,14 +14,13 @@ require 'mocha' require 'active_record' require 'active_support/dependencies' -begin - require 'connection' -rescue LoadError - # If we cannot load connection we assume that driver was not loaded for this test case, so we load sqlite3 as default one. - # This allows for running separate test cases by simply running test file. - connection_type = defined?(JRUBY_VERSION) ? 'jdbc' : 'native' - require "test/connections/#{connection_type}_sqlite3/connection" -end + +require 'support/config' +require 'support/connection' + +ARTest.connect + +# TODO: Move all these random hacks into the ARTest namespace and into the support/ dir # Show backtraces for deprecated behavior for quicker cleanup. ActiveSupport::Deprecation.debug = true diff --git a/activerecord/test/cases/i18n_test.rb b/activerecord/test/cases/i18n_test.rb index 469f513e68..d96dc5fba9 100644 --- a/activerecord/test/cases/i18n_test.rb +++ b/activerecord/test/cases/i18n_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/topic' require 'models/reply' @@ -43,4 +43,3 @@ class ActiveRecordI18nTests < ActiveRecord::TestCase assert_equal 'topic model', Reply.model_name.human end end - diff --git a/activerecord/test/cases/identity_map/middleware_test.rb b/activerecord/test/cases/identity_map/middleware_test.rb index 60dcad4586..047192c244 100644 --- a/activerecord/test/cases/identity_map/middleware_test.rb +++ b/activerecord/test/cases/identity_map/middleware_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) module ActiveRecord module IdentityMap diff --git a/activerecord/test/cases/identity_map_test.rb b/activerecord/test/cases/identity_map_test.rb index a0e16400d2..d814f1cc92 100644 --- a/activerecord/test/cases/identity_map_test.rb +++ b/activerecord/test/cases/identity_map_test.rb @@ -1,5 +1,4 @@ -require "cases/helper" - +require File.expand_path('../helper', __FILE__) require 'models/developer' require 'models/project' require 'models/company' @@ -140,7 +139,7 @@ class IdentityMapTest < ActiveRecord::TestCase assert_not_same(p1, p2) end end - + def test_inherited_with_type_attribute_without_identity_map ActiveRecord::IdentityMap.without do c = comments(:sub_special_comment) diff --git a/activerecord/test/cases/inheritance_test.rb b/activerecord/test/cases/inheritance_test.rb index b5d8314541..5bfc572ea8 100644 --- a/activerecord/test/cases/inheritance_test.rb +++ b/activerecord/test/cases/inheritance_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/company' require 'models/project' require 'models/subscriber' diff --git a/activerecord/test/cases/invalid_date_test.rb b/activerecord/test/cases/invalid_date_test.rb index 2de50b224c..65d326bc12 100644 --- a/activerecord/test/cases/invalid_date_test.rb +++ b/activerecord/test/cases/invalid_date_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../helper', __FILE__) require 'models/topic' class InvalidDateTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/invertible_migration_test.rb b/activerecord/test/cases/invertible_migration_test.rb index afec64750e..d145ff7427 100644 --- a/activerecord/test/cases/invertible_migration_test.rb +++ b/activerecord/test/cases/invertible_migration_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) module ActiveRecord class InvertibleMigrationTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/json_serialization_test.rb b/activerecord/test/cases/json_serialization_test.rb index d9e350abc0..aef7403a09 100644 --- a/activerecord/test/cases/json_serialization_test.rb +++ b/activerecord/test/cases/json_serialization_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/contact' require 'models/post' require 'models/author' diff --git a/activerecord/test/cases/lifecycle_test.rb b/activerecord/test/cases/lifecycle_test.rb index 643e949087..7d47f7e21b 100644 --- a/activerecord/test/cases/lifecycle_test.rb +++ b/activerecord/test/cases/lifecycle_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../helper', __FILE__) require 'models/topic' require 'models/developer' require 'models/reply' diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb index 61baa55027..88861df86a 100644 --- a/activerecord/test/cases/locking_test.rb +++ b/activerecord/test/cases/locking_test.rb @@ -1,5 +1,5 @@ require 'thread' -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/person' require 'models/job' require 'models/reader' diff --git a/activerecord/test/cases/log_subscriber_test.rb b/activerecord/test/cases/log_subscriber_test.rb index c6c6079490..f29ced4526 100644 --- a/activerecord/test/cases/log_subscriber_test.rb +++ b/activerecord/test/cases/log_subscriber_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require "models/developer" require "models/post" require "active_support/log_subscriber/test_helper" diff --git a/activerecord/test/cases/mass_assignment_security_test.rb b/activerecord/test/cases/mass_assignment_security_test.rb index 33737e12a8..a41ce539c7 100644 --- a/activerecord/test/cases/mass_assignment_security_test.rb +++ b/activerecord/test/cases/mass_assignment_security_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/company' require 'models/subscriber' require 'models/keyboard' diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb index a0cb5dbdc5..52e76cb91a 100644 --- a/activerecord/test/cases/method_scoping_test.rb +++ b/activerecord/test/cases/method_scoping_test.rb @@ -2,7 +2,7 @@ # All the tests were already ported to relation_scoping_test.rb when the new # relation scoping API was added. -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/post' require 'models/author' require 'models/developer' diff --git a/activerecord/test/cases/migration/command_recorder_test.rb b/activerecord/test/cases/migration/command_recorder_test.rb index 0f79c99e1a..986dc7173d 100644 --- a/activerecord/test/cases/migration/command_recorder_test.rb +++ b/activerecord/test/cases/migration/command_recorder_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) module ActiveRecord class Migration diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index bf7565a0d0..01f7575653 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'bigdecimal/util' require 'models/person' diff --git a/activerecord/test/cases/mixin_test.rb b/activerecord/test/cases/mixin_test.rb index f927c13979..65101199b8 100644 --- a/activerecord/test/cases/mixin_test.rb +++ b/activerecord/test/cases/mixin_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) class Mixin < ActiveRecord::Base end diff --git a/activerecord/test/cases/modules_test.rb b/activerecord/test/cases/modules_test.rb index a2041af16a..df5e66ea3c 100644 --- a/activerecord/test/cases/modules_test.rb +++ b/activerecord/test/cases/modules_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/company_in_module' require 'models/shop' diff --git a/activerecord/test/cases/multiple_db_test.rb b/activerecord/test/cases/multiple_db_test.rb index bd51388e05..fca832e50b 100644 --- a/activerecord/test/cases/multiple_db_test.rb +++ b/activerecord/test/cases/multiple_db_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/entrant' require 'models/bird' diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index 34188e4915..85bab2c7b5 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'active_support/core_ext/array/random_access' require 'models/post' require 'models/topic' diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb index 6568eb1d18..d94d4768a9 100644 --- a/activerecord/test/cases/nested_attributes_test.rb +++ b/activerecord/test/cases/nested_attributes_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require "models/pirate" require "models/ship" require "models/ship_part" diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb index 57d1441128..00543f7350 100644 --- a/activerecord/test/cases/persistence_test.rb +++ b/activerecord/test/cases/persistence_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/post' require 'models/comment' require 'models/author' diff --git a/activerecord/test/cases/pooled_connections_test.rb b/activerecord/test/cases/pooled_connections_test.rb index 379cf5b44e..0321c5208f 100644 --- a/activerecord/test/cases/pooled_connections_test.rb +++ b/activerecord/test/cases/pooled_connections_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require "models/project" require "timeout" diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb index 05a41d8a0a..e810a155a0 100644 --- a/activerecord/test/cases/primary_keys_test.rb +++ b/activerecord/test/cases/primary_keys_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/topic' require 'models/reply' require 'models/subscriber' diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb index a61180cfaf..b08443b455 100644 --- a/activerecord/test/cases/query_cache_test.rb +++ b/activerecord/test/cases/query_cache_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/topic' require 'models/task' require 'models/category' diff --git a/activerecord/test/cases/quoting_test.rb b/activerecord/test/cases/quoting_test.rb index 80ee74e41e..4cb38118c9 100644 --- a/activerecord/test/cases/quoting_test.rb +++ b/activerecord/test/cases/quoting_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) module ActiveRecord module ConnectionAdapters diff --git a/activerecord/test/cases/readonly_test.rb b/activerecord/test/cases/readonly_test.rb index e21109baae..88168776b1 100644 --- a/activerecord/test/cases/readonly_test.rb +++ b/activerecord/test/cases/readonly_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/post' require 'models/comment' require 'models/developer' diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb index 58c78ab058..c7288baaba 100644 --- a/activerecord/test/cases/reflection_test.rb +++ b/activerecord/test/cases/reflection_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/topic' require 'models/customer' require 'models/company' diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb index a6e08f95d0..5067384fb6 100644 --- a/activerecord/test/cases/relation_scoping_test.rb +++ b/activerecord/test/cases/relation_scoping_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/post' require 'models/author' require 'models/developer' diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb index 12e58bd340..5ad089c875 100644 --- a/activerecord/test/cases/relation_test.rb +++ b/activerecord/test/cases/relation_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/post' require 'models/comment' diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index fc9df8c7a3..ecc68b19d4 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/tag' require 'models/tagging' require 'models/post' diff --git a/activerecord/test/cases/reload_models_test.rb b/activerecord/test/cases/reload_models_test.rb index 0d16a3526f..0ac46a2768 100644 --- a/activerecord/test/cases/reload_models_test.rb +++ b/activerecord/test/cases/reload_models_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/owner' require 'models/pet' diff --git a/activerecord/test/cases/sanitize_test.rb b/activerecord/test/cases/sanitize_test.rb index 817897ceac..7c30bcf4c8 100644 --- a/activerecord/test/cases/sanitize_test.rb +++ b/activerecord/test/cases/sanitize_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/binary' class SanitizeTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb index e8f2f44189..e765fdfe70 100644 --- a/activerecord/test/cases/schema_dumper_test.rb +++ b/activerecord/test/cases/schema_dumper_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'stringio' @@ -230,4 +230,3 @@ class SchemaDumperTest < ActiveRecord::TestCase assert_match %r{t.string[[:space:]]+"id",[[:space:]]+:null => false$}, match[2], "non-primary key id column not preserved" end end - diff --git a/activerecord/test/cases/serialization_test.rb b/activerecord/test/cases/serialization_test.rb index 677d659f39..9c976f4999 100644 --- a/activerecord/test/cases/serialization_test.rb +++ b/activerecord/test/cases/serialization_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/contact' require 'models/topic' require 'models/reply' diff --git a/activerecord/test/cases/session_store/session_test.rb b/activerecord/test/cases/session_store/session_test.rb index 669c0b7b4d..fb6f4cfd44 100644 --- a/activerecord/test/cases/session_store/session_test.rb +++ b/activerecord/test/cases/session_store/session_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../../helper', __FILE__) require 'action_dispatch' require 'active_record/session_store' diff --git a/activerecord/test/cases/session_store/sql_bypass.rb b/activerecord/test/cases/session_store/sql_bypass.rb index 7402b2afd6..97ccb1f5c9 100644 --- a/activerecord/test/cases/session_store/sql_bypass.rb +++ b/activerecord/test/cases/session_store/sql_bypass.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../../helper', __FILE__) require 'action_dispatch' require 'active_record/session_store' diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index ceb1452afd..ce6419c0da 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -1,4 +1,4 @@ -require 'cases/helper' +require File.expand_path('../helper', __FILE__) require 'models/developer' require 'models/owner' require 'models/pet' diff --git a/activerecord/test/cases/transaction_callbacks_test.rb b/activerecord/test/cases/transaction_callbacks_test.rb index 85f222bca2..2d88e660b3 100644 --- a/activerecord/test/cases/transaction_callbacks_test.rb +++ b/activerecord/test/cases/transaction_callbacks_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/topic' class TransactionCallbacksTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb index 110a18772f..fa33ffaed3 100644 --- a/activerecord/test/cases/transactions_test.rb +++ b/activerecord/test/cases/transactions_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/topic' require 'models/reply' require 'models/developer' diff --git a/activerecord/test/cases/unconnected_test.rb b/activerecord/test/cases/unconnected_test.rb index f85fb4e5da..a6aaf1eb3d 100644 --- a/activerecord/test/cases/unconnected_test.rb +++ b/activerecord/test/cases/unconnected_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) class TestRecord < ActiveRecord::Base end diff --git a/activerecord/test/cases/validations/association_validation_test.rb b/activerecord/test/cases/validations/association_validation_test.rb index 56e345990f..45290680f9 100644 --- a/activerecord/test/cases/validations/association_validation_test.rb +++ b/activerecord/test/cases/validations/association_validation_test.rb @@ -1,5 +1,5 @@ # encoding: utf-8 -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/topic' require 'models/reply' require 'models/owner' diff --git a/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb b/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb index 628029f8df..922fb5dce7 100644 --- a/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb +++ b/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/topic' class I18nGenerateMessageValidationTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/validations/i18n_validation_test.rb b/activerecord/test/cases/validations/i18n_validation_test.rb index 15b97c02c8..46f0c3c49d 100644 --- a/activerecord/test/cases/validations/i18n_validation_test.rb +++ b/activerecord/test/cases/validations/i18n_validation_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/topic' require 'models/reply' diff --git a/activerecord/test/cases/validations/uniqueness_validation_test.rb b/activerecord/test/cases/validations/uniqueness_validation_test.rb index 0f1b3667cc..218f673451 100644 --- a/activerecord/test/cases/validations/uniqueness_validation_test.rb +++ b/activerecord/test/cases/validations/uniqueness_validation_test.rb @@ -1,5 +1,5 @@ # encoding: utf-8 -require "cases/helper" +require File.expand_path('../../helper', __FILE__) require 'models/topic' require 'models/reply' require 'models/warehouse_thing' diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb index c3e494866b..8764a22d40 100644 --- a/activerecord/test/cases/validations_test.rb +++ b/activerecord/test/cases/validations_test.rb @@ -1,5 +1,5 @@ # encoding: utf-8 -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/topic' require 'models/reply' require 'models/person' diff --git a/activerecord/test/cases/xml_serialization_test.rb b/activerecord/test/cases/xml_serialization_test.rb index 756c8a32eb..c48957e7a7 100644 --- a/activerecord/test/cases/xml_serialization_test.rb +++ b/activerecord/test/cases/xml_serialization_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/contact' require 'models/post' require 'models/author' diff --git a/activerecord/test/cases/yaml_serialization_test.rb b/activerecord/test/cases/yaml_serialization_test.rb index 0b54c309d1..6caa782a97 100644 --- a/activerecord/test/cases/yaml_serialization_test.rb +++ b/activerecord/test/cases/yaml_serialization_test.rb @@ -1,4 +1,4 @@ -require "cases/helper" +require File.expand_path('../helper', __FILE__) require 'models/topic' class YamlSerializationTest < ActiveRecord::TestCase diff --git a/activerecord/test/config.example.yml b/activerecord/test/config.example.yml new file mode 100644 index 0000000000..6ed38db66d --- /dev/null +++ b/activerecord/test/config.example.yml @@ -0,0 +1,136 @@ +default_connection: <%= defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' %> + +connections: + jdbcderby: + arunit: activerecord_unittest + arunit2: activerecord_unittest2 + + jdbch2: + arunit: activerecord_unittest + arunit2: activerecord_unittest2 + + jdbchsqldb: + arunit: activerecord_unittest + arunit2: activerecord_unittest2 + + jdbcmysql: + arunit: + username: rails + encoding: utf8 + arunit2: + username: rails + encoding: utf8 + + jdbcpostgresql: + arunit: + username: <%= ENV['user'] || 'rails' %> + arunit2: + username: <%= ENV['user'] || 'rails' %> + + jdbcsqlite3: + arunit: + database: <%= FIXTURES_ROOT %>/fixture_database.sqlite3 + timeout: 5000 + arunit2: + database: <%= FIXTURES_ROOT %>/fixture_database_2.sqlite3 + timeout: 5000 + + db2: + arunit: + host: localhost + username: arunit + password: arunit + database: arunit + arunit2: + host: localhost + username: arunit + password: arunit + database: arunit2 + + firebird: + arunit: + host: localhost + username: rails + password: rails + charset: UTF8 + arunit2: + host: localhost + username: rails + password: rails + charset: UTF8 + + frontbase: + arunit: + host: localhost + username: rails + session_name: unittest-<%= $$ %> + arunit2: + host: localhost + username: rails + session_name: unittest-<%= $$ %> + + mysql: + arunit: + username: rails + encoding: utf8 + arunit2: + username: rails + encoding: utf8 + + mysql2: + arunit: + username: rails + encoding: utf8 + arunit2: + username: rails + encoding: utf8 + + openbase: + arunit: + username: admin + arunit2: + username: admin + + oracle: + arunit: + adapter: oracle_enhanced + database: <%= ENV['ARUNIT_DB_NAME'] || 'orcl' %> + username: arunit + password: arunit + emulate_oracle_adapter: true + arunit: + adapter: oracle_enhanced + database: <%= ENV['ARUNIT_DB_NAME'] || 'orcl' %> + username: arunit2 + password: arunit2 + emulate_oracle_adapter: true + + postgresql: + arunit: + min_messages: warning + arunit2: + min_messages: warning + + sqlite3: + arunit: + database: <%= FIXTURES_ROOT %>/fixture_database.sqlite3 + timeout: 5000 + arunit2: + database: <%= FIXTURES_ROOT %>/fixture_database_2.sqlite3 + timeout: 5000 + + sqlite3_mem: + arunit: + adapter: sqlite3 + database: ':memory:' + arunit2: + adapter: sqlite3 + database: ':memory:' + + sybase: + arunit: + host: database_ASE + username: sa + arunit2: + host: database_ASE + username: sa diff --git a/activerecord/test/connections/db2.rb b/activerecord/test/connections/db2.rb new file mode 100644 index 0000000000..f43b3fda57 --- /dev/null +++ b/activerecord/test/connections/db2.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'db2' diff --git a/activerecord/test/connections/firebird.rb b/activerecord/test/connections/firebird.rb new file mode 100644 index 0000000000..fa874c0bb3 --- /dev/null +++ b/activerecord/test/connections/firebird.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'firebird' diff --git a/activerecord/test/connections/frontbase.rb b/activerecord/test/connections/frontbase.rb new file mode 100644 index 0000000000..9d1d5597d4 --- /dev/null +++ b/activerecord/test/connections/frontbase.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'frontbase' diff --git a/activerecord/test/connections/jdbc_jdbcderby/connection.rb b/activerecord/test/connections/jdbc_jdbcderby/connection.rb deleted file mode 100644 index 222ef5db38..0000000000 --- a/activerecord/test/connections/jdbc_jdbcderby/connection.rb +++ /dev/null @@ -1,18 +0,0 @@ -print "Using Derby via JRuby, activerecord-jdbc-adapter and activerecord-jdbcderby-adapter\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbcderby', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'jdbcderby', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/activerecord/test/connections/jdbc_jdbch2/connection.rb b/activerecord/test/connections/jdbc_jdbch2/connection.rb deleted file mode 100644 index 9d2875e8e7..0000000000 --- a/activerecord/test/connections/jdbc_jdbch2/connection.rb +++ /dev/null @@ -1,18 +0,0 @@ -print "Using H2 via JRuby, activerecord-jdbc-adapter and activerecord-jdbch2-adapter\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbch2', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'jdbch2', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/activerecord/test/connections/jdbc_jdbchsqldb/connection.rb b/activerecord/test/connections/jdbc_jdbchsqldb/connection.rb deleted file mode 100644 index fa943c2c76..0000000000 --- a/activerecord/test/connections/jdbc_jdbchsqldb/connection.rb +++ /dev/null @@ -1,18 +0,0 @@ -print "Using HSQLDB via JRuby, activerecord-jdbc-adapter and activerecord-jdbchsqldb-adapter\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbchsqldb', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'jdbchsqldb', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/activerecord/test/connections/jdbc_jdbcmysql/connection.rb b/activerecord/test/connections/jdbc_jdbcmysql/connection.rb deleted file mode 100644 index e2517a50eb..0000000000 --- a/activerecord/test/connections/jdbc_jdbcmysql/connection.rb +++ /dev/null @@ -1,26 +0,0 @@ -print "Using MySQL via JRuby, activerecord-jdbc-adapter and activerecord-jdbcmysql-adapter\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -# GRANT ALL PRIVILEGES ON activerecord_unittest.* to 'rails'@'localhost'; -# GRANT ALL PRIVILEGES ON activerecord_unittest2.* to 'rails'@'localhost'; - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbcmysql', - :username => 'rails', - :encoding => 'utf8', - :database => 'activerecord_unittest', - }, - 'arunit2' => { - :adapter => 'jdbcmysql', - :username => 'rails', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' - diff --git a/activerecord/test/connections/jdbc_jdbcpostgresql/connection.rb b/activerecord/test/connections/jdbc_jdbcpostgresql/connection.rb deleted file mode 100644 index 0685da4433..0000000000 --- a/activerecord/test/connections/jdbc_jdbcpostgresql/connection.rb +++ /dev/null @@ -1,26 +0,0 @@ -print "Using Postgrsql via JRuby, activerecord-jdbc-adapter and activerecord-postgresql-adapter\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -# createuser rails --createdb --no-superuser --no-createrole -# createdb -O rails activerecord_unittest -# createdb -O rails activerecord_unittest2 - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbcpostgresql', - :username => ENV['USER'] || 'rails', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'jdbcpostgresql', - :username => ENV['USER'] || 'rails', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' - diff --git a/activerecord/test/connections/jdbc_jdbcsqlite3/connection.rb b/activerecord/test/connections/jdbc_jdbcsqlite3/connection.rb deleted file mode 100644 index 26d4676ff3..0000000000 --- a/activerecord/test/connections/jdbc_jdbcsqlite3/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using SQLite3 via JRuby, activerecord-jdbc-adapter and activerecord-jdbcsqlite3-adapter\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -class SqliteError < StandardError -end - -BASE_DIR = FIXTURES_ROOT -sqlite_test_db = "#{BASE_DIR}/fixture_database.sqlite3" -sqlite_test_db2 = "#{BASE_DIR}/fixture_database_2.sqlite3" - -def make_connection(clazz, db_file) - ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'jdbcsqlite3', :database => db_file, :timeout => 5000 } } - unless File.exist?(db_file) - puts "SQLite3 database not found at #{db_file}. Rebuilding it." - sqlite_command = %Q{sqlite3 "#{db_file}" "create table a (a integer); drop table a;"} - puts "Executing '#{sqlite_command}'" - raise SqliteError.new("Seems that there is no sqlite3 executable available") unless system(sqlite_command) - end - clazz.establish_connection(clazz.name) -end - -make_connection(ActiveRecord::Base, sqlite_test_db) -make_connection(Course, sqlite_test_db2) diff --git a/activerecord/test/connections/jdbcderby.rb b/activerecord/test/connections/jdbcderby.rb new file mode 100644 index 0000000000..1c7b63ccdc --- /dev/null +++ b/activerecord/test/connections/jdbcderby.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'jdbcderby' diff --git a/activerecord/test/connections/jdbch2.rb b/activerecord/test/connections/jdbch2.rb new file mode 100644 index 0000000000..d2fb177ae3 --- /dev/null +++ b/activerecord/test/connections/jdbch2.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'jdbch2' diff --git a/activerecord/test/connections/jdbchsqldb.rb b/activerecord/test/connections/jdbchsqldb.rb new file mode 100644 index 0000000000..22e6d8729e --- /dev/null +++ b/activerecord/test/connections/jdbchsqldb.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'jdbchsqldb' diff --git a/activerecord/test/connections/jdbcmysql.rb b/activerecord/test/connections/jdbcmysql.rb new file mode 100644 index 0000000000..f1aaad93a3 --- /dev/null +++ b/activerecord/test/connections/jdbcmysql.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'jdbcmysql' diff --git a/activerecord/test/connections/jdbcpostgresql.rb b/activerecord/test/connections/jdbcpostgresql.rb new file mode 100644 index 0000000000..6809115f36 --- /dev/null +++ b/activerecord/test/connections/jdbcpostgresql.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'jdbcpostgresql' diff --git a/activerecord/test/connections/jdbcsqlite3.rb b/activerecord/test/connections/jdbcsqlite3.rb new file mode 100644 index 0000000000..9cc872905a --- /dev/null +++ b/activerecord/test/connections/jdbcsqlite3.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'jdbcsqlite3' diff --git a/activerecord/test/connections/mysql.rb b/activerecord/test/connections/mysql.rb new file mode 100644 index 0000000000..2f30603098 --- /dev/null +++ b/activerecord/test/connections/mysql.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'mysql' diff --git a/activerecord/test/connections/mysql2.rb b/activerecord/test/connections/mysql2.rb new file mode 100644 index 0000000000..10aa9171bd --- /dev/null +++ b/activerecord/test/connections/mysql2.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'mysql2' diff --git a/activerecord/test/connections/native_db2/connection.rb b/activerecord/test/connections/native_db2/connection.rb deleted file mode 100644 index 324315d2c8..0000000000 --- a/activerecord/test/connections/native_db2/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using native DB2\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'db2', - :host => 'localhost', - :username => 'arunit', - :password => 'arunit', - :database => 'arunit' - }, - 'arunit2' => { - :adapter => 'db2', - :host => 'localhost', - :username => 'arunit', - :password => 'arunit', - :database => 'arunit2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/activerecord/test/connections/native_firebird/connection.rb b/activerecord/test/connections/native_firebird/connection.rb deleted file mode 100644 index 67a936ca97..0000000000 --- a/activerecord/test/connections/native_firebird/connection.rb +++ /dev/null @@ -1,26 +0,0 @@ -print "Using native Firebird\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'firebird', - :host => 'localhost', - :username => 'rails', - :password => 'rails', - :database => 'activerecord_unittest', - :charset => 'UTF8' - }, - 'arunit2' => { - :adapter => 'firebird', - :host => 'localhost', - :username => 'rails', - :password => 'rails', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/activerecord/test/connections/native_frontbase/connection.rb b/activerecord/test/connections/native_frontbase/connection.rb deleted file mode 100644 index c01d864a8b..0000000000 --- a/activerecord/test/connections/native_frontbase/connection.rb +++ /dev/null @@ -1,27 +0,0 @@ -puts 'Using native Frontbase' -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'frontbase', - :host => 'localhost', - :username => 'rails', - :password => '', - :database => 'activerecord_unittest', - :session_name => "unittest-#{$$}" - }, - 'arunit2' => { - :adapter => 'frontbase', - :host => 'localhost', - :username => 'rails', - :password => '', - :database => 'activerecord_unittest2', - :session_name => "unittest-#{$$}" - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/activerecord/test/connections/native_mysql/connection.rb b/activerecord/test/connections/native_mysql/connection.rb deleted file mode 100644 index 140e06d631..0000000000 --- a/activerecord/test/connections/native_mysql/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using native MySQL\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -# GRANT ALL PRIVILEGES ON activerecord_unittest.* to 'rails'@'localhost'; -# GRANT ALL PRIVILEGES ON activerecord_unittest2.* to 'rails'@'localhost'; - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'mysql', - :username => 'rails', - :encoding => 'utf8', - :database => 'activerecord_unittest', - }, - 'arunit2' => { - :adapter => 'mysql', - :username => 'rails', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/activerecord/test/connections/native_mysql2/connection.rb b/activerecord/test/connections/native_mysql2/connection.rb deleted file mode 100644 index c6f198b1ac..0000000000 --- a/activerecord/test/connections/native_mysql2/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using native Mysql2\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -# GRANT ALL PRIVILEGES ON activerecord_unittest.* to 'rails'@'localhost'; -# GRANT ALL PRIVILEGES ON activerecord_unittest2.* to 'rails'@'localhost'; - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'mysql2', - :username => 'rails', - :encoding => 'utf8', - :database => 'activerecord_unittest', - }, - 'arunit2' => { - :adapter => 'mysql2', - :username => 'rails', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/activerecord/test/connections/native_openbase/connection.rb b/activerecord/test/connections/native_openbase/connection.rb deleted file mode 100644 index 655cb9ca26..0000000000 --- a/activerecord/test/connections/native_openbase/connection.rb +++ /dev/null @@ -1,21 +0,0 @@ -print "Using native OpenBase\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'openbase', - :username => 'admin', - :database => 'activerecord_unittest', - }, - 'arunit2' => { - :adapter => 'openbase', - :username => 'admin', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/activerecord/test/connections/native_oracle/connection.rb b/activerecord/test/connections/native_oracle/connection.rb deleted file mode 100644 index 99f921879c..0000000000 --- a/activerecord/test/connections/native_oracle/connection.rb +++ /dev/null @@ -1,35 +0,0 @@ -# uses oracle_enhanced adapter in ENV['ORACLE_ENHANCED_PATH'] or from github.com/rsim/oracle-enhanced.git -require 'active_record/connection_adapters/oracle_enhanced_adapter' - -# otherwise failed with silence_warnings method missing exception -require 'active_support/core_ext/kernel/reporting' - -print "Using Oracle\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -# Set these to your database connection strings -ENV['ARUNIT_DB_NAME'] ||= 'orcl' - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'oracle_enhanced', - :database => ENV['ARUNIT_DB_NAME'], - :username => 'arunit', - :password => 'arunit', - :emulate_oracle_adapter => true - }, - 'arunit2' => { - :adapter => 'oracle_enhanced', - :database => ENV['ARUNIT_DB_NAME'], - :username => 'arunit2', - :password => 'arunit2', - :emulate_oracle_adapter => true - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' - diff --git a/activerecord/test/connections/native_postgresql/connection.rb b/activerecord/test/connections/native_postgresql/connection.rb deleted file mode 100644 index 3b5ff90003..0000000000 --- a/activerecord/test/connections/native_postgresql/connection.rb +++ /dev/null @@ -1,21 +0,0 @@ -print "Using native PostgreSQL\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'postgresql', - :database => 'activerecord_unittest', - :min_messages => 'warning' - }, - 'arunit2' => { - :adapter => 'postgresql', - :database => 'activerecord_unittest2', - :min_messages => 'warning' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/activerecord/test/connections/native_sqlite3/connection.rb b/activerecord/test/connections/native_sqlite3/connection.rb deleted file mode 100644 index c2aff5551f..0000000000 --- a/activerecord/test/connections/native_sqlite3/connection.rb +++ /dev/null @@ -1,16 +0,0 @@ -print "Using native SQLite3\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -BASE_DIR = FIXTURES_ROOT -sqlite_test_db = "#{BASE_DIR}/fixture_database.sqlite3" -sqlite_test_db2 = "#{BASE_DIR}/fixture_database_2.sqlite3" - -def make_connection(clazz, db_file) - ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'sqlite3', :database => db_file, :timeout => 5000 } } - clazz.establish_connection(clazz.name) -end - -make_connection(ActiveRecord::Base, sqlite_test_db) -make_connection(Course, sqlite_test_db2) diff --git a/activerecord/test/connections/native_sqlite3_mem/connection.rb b/activerecord/test/connections/native_sqlite3_mem/connection.rb deleted file mode 100644 index 14e10900d1..0000000000 --- a/activerecord/test/connections/native_sqlite3_mem/connection.rb +++ /dev/null @@ -1,19 +0,0 @@ -# This file connects to an in-memory SQLite3 database, which is a very fast way to run the tests. -# The downside is that disconnect from the database results in the database effectively being -# wiped. For this reason, pooled_connections_test.rb is disabled when using an in-memory database. - -print "Using native SQLite3 (in memory)\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -class SqliteError < StandardError -end - -def make_connection(clazz) - ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'sqlite3', :database => ':memory:' } } - clazz.establish_connection(clazz.name) -end - -make_connection(ActiveRecord::Base) -make_connection(Course) diff --git a/activerecord/test/connections/native_sybase/connection.rb b/activerecord/test/connections/native_sybase/connection.rb deleted file mode 100644 index 3282d26922..0000000000 --- a/activerecord/test/connections/native_sybase/connection.rb +++ /dev/null @@ -1,23 +0,0 @@ -print "Using native Sybase Open Client\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'sybase', - :host => 'database_ASE', - :username => 'sa', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'sybase', - :host => 'database_ASE', - :username => 'sa', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/activerecord/test/connections/openbase.rb b/activerecord/test/connections/openbase.rb new file mode 100644 index 0000000000..bf072579f4 --- /dev/null +++ b/activerecord/test/connections/openbase.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'openbase' diff --git a/activerecord/test/connections/oracle.rb b/activerecord/test/connections/oracle.rb new file mode 100644 index 0000000000..70e92b1424 --- /dev/null +++ b/activerecord/test/connections/oracle.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'oracle' diff --git a/activerecord/test/connections/postgresql.rb b/activerecord/test/connections/postgresql.rb new file mode 100644 index 0000000000..b8bfb6e846 --- /dev/null +++ b/activerecord/test/connections/postgresql.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'postgresql' diff --git a/activerecord/test/connections/sqlite3.rb b/activerecord/test/connections/sqlite3.rb new file mode 100644 index 0000000000..e5c75657a5 --- /dev/null +++ b/activerecord/test/connections/sqlite3.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'sqlite3' diff --git a/activerecord/test/connections/sqlite3_mem.rb b/activerecord/test/connections/sqlite3_mem.rb new file mode 100644 index 0000000000..900a5c7947 --- /dev/null +++ b/activerecord/test/connections/sqlite3_mem.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'sqlite3_mem' diff --git a/activerecord/test/connections/sybase.rb b/activerecord/test/connections/sybase.rb new file mode 100644 index 0000000000..7decdf7f39 --- /dev/null +++ b/activerecord/test/connections/sybase.rb @@ -0,0 +1 @@ +ENV['ARCONN'] = 'sybase' diff --git a/activerecord/test/support/config.rb b/activerecord/test/support/config.rb new file mode 100644 index 0000000000..2760d88d20 --- /dev/null +++ b/activerecord/test/support/config.rb @@ -0,0 +1,39 @@ +require 'yaml' +require 'erubis' +require 'fileutils' + +module ARTest + class << self + def config + @config ||= read_config + end + + private + + def read_config + unless File.exist?(TEST_ROOT + '/config.yml') + FileUtils.cp TEST_ROOT + '/config.example.yml', TEST_ROOT + '/config.yml' + end + + raw = File.read(TEST_ROOT + '/config.yml') + erb = Erubis::Eruby.new(raw) + expand_config(YAML.parse(erb.result(binding)).transform) + end + + def expand_config(config) + config['connections'].each do |adapter, connection| + dbs = [['arunit', 'activerecord_unittest'], ['arunit2', 'activerecord_unittest']] + dbs.each do |name, dbname| + unless connection[name].is_a?(Hash) + connection[name] = { 'database' => connection[name] } + end + + connection[name]['database'] ||= dbname + connection[name]['adapter'] ||= adapter + end + end + + config + end + end +end diff --git a/activerecord/test/support/connection.rb b/activerecord/test/support/connection.rb new file mode 100644 index 0000000000..f4123c694d --- /dev/null +++ b/activerecord/test/support/connection.rb @@ -0,0 +1,13 @@ +require 'logger' +require_dependency 'models/course' + +module ARTest + def self.connect + connection_name = ENV['ARCONN'] || config['default_connection'] + puts "Using #{connection_name}" + ActiveRecord::Base.logger = Logger.new("debug.log") + ActiveRecord::Base.configurations = config['connections'][connection_name] + ActiveRecord::Base.establish_connection 'arunit' + Course.establish_connection 'arunit2' + end +end |