Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 253bb6b9260938ed673e2c0059d729cffff4a523 1 parent cdce7ff
@jonleighton jonleighton authored
Showing with 360 additions and 571 deletions.
  1. +14 −32 activerecord/RUNNING_UNIT_TESTS
  2. +3 −5 activerecord/Rakefile
  3. +1 −0  activerecord/test/.gitignore
  4. +1 −1  activerecord/test/cases/adapter_test.rb
  5. +1 −1  activerecord/test/cases/adapters/firebird/connection_test.rb
  6. +1 −1  activerecord/test/cases/adapters/firebird/default_test.rb
  7. +1 −1  activerecord/test/cases/adapters/firebird/migration_test.rb
  8. +1 −1  activerecord/test/cases/adapters/mysql/active_schema_test.rb
  9. +1 −1  activerecord/test/cases/adapters/mysql/connection_test.rb
  10. +1 −1  activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb
  11. +1 −2  activerecord/test/cases/adapters/mysql/quoting_test.rb
  12. +1 −1  activerecord/test/cases/adapters/mysql/reserved_word_test.rb
  13. +1 −1  activerecord/test/cases/adapters/mysql/schema_test.rb
  14. +1 −1  activerecord/test/cases/adapters/mysql/sp_test.rb
  15. +1 −1  activerecord/test/cases/adapters/mysql2/active_schema_test.rb
  16. +1 −1  activerecord/test/cases/adapters/mysql2/bind_parameter_test.rb
  17. +1 −1  activerecord/test/cases/adapters/mysql2/connection_test.rb
  18. +1 −1  activerecord/test/cases/adapters/mysql2/reserved_word_test.rb
  19. +1 −1  activerecord/test/cases/adapters/mysql2/schema_test.rb
  20. +1 −1  activerecord/test/cases/adapters/oracle/synonym_test.rb
  21. +1 −1  activerecord/test/cases/adapters/postgresql/active_schema_test.rb
  22. +1 −1  activerecord/test/cases/adapters/postgresql/datatype_test.rb
  23. +1 −1  activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
  24. +1 −1  activerecord/test/cases/adapters/postgresql/quoting_test.rb
  25. +1 −1  activerecord/test/cases/adapters/postgresql/schema_authorization_test.rb
  26. +1 −1  activerecord/test/cases/adapters/postgresql/schema_test.rb
  27. +1 −1  activerecord/test/cases/adapters/postgresql/timestamp_test.rb
  28. +1 −1  activerecord/test/cases/adapters/sqlite3/copy_table_test.rb
  29. +1 −1  activerecord/test/cases/adapters/sqlite3/quoting_test.rb
  30. +1 −1  activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
  31. +1 −1  activerecord/test/cases/aggregations_test.rb
  32. +1 −1  activerecord/test/cases/ar_schema_test.rb
  33. +1 −1  activerecord/test/cases/associations/belongs_to_associations_test.rb
  34. +1 −1  activerecord/test/cases/associations/callbacks_test.rb
  35. +1 −1  activerecord/test/cases/associations/cascaded_eager_loading_test.rb
  36. +1 −1  activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
  37. +1 −1  activerecord/test/cases/associations/eager_load_nested_include_test.rb
  38. +1 −1  activerecord/test/cases/associations/eager_singularization_test.rb
  39. +1 −1  activerecord/test/cases/associations/eager_test.rb
  40. +1 −1  activerecord/test/cases/associations/extension_test.rb
  41. +1 −1  activerecord/test/cases/associations/habtm_join_table_test.rb
  42. +2 −2 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  43. +1 −1  activerecord/test/cases/associations/has_many_associations_test.rb
  44. +1 −1  activerecord/test/cases/associations/has_many_through_associations_test.rb
  45. +1 −1  activerecord/test/cases/associations/has_one_associations_test.rb
  46. +1 −1  activerecord/test/cases/associations/has_one_through_associations_test.rb
  47. +1 −1  activerecord/test/cases/associations/identity_map_test.rb
  48. +1 −1  activerecord/test/cases/associations/inner_join_association_test.rb
  49. +1 −1  activerecord/test/cases/associations/inverse_associations_test.rb
  50. +1 −1  activerecord/test/cases/associations/join_model_test.rb
  51. +1 −1  activerecord/test/cases/associations/nested_through_associations_test.rb
  52. +1 −1  activerecord/test/cases/associations_test.rb
  53. +1 −1  activerecord/test/cases/attribute_methods/read_test.rb
  54. +1 −1  activerecord/test/cases/attribute_methods_test.rb
  55. +1 −1  activerecord/test/cases/autosave_association_test.rb
  56. +1 −1  activerecord/test/cases/base_test.rb
  57. +1 −1  activerecord/test/cases/batches_test.rb
  58. +1 −1  activerecord/test/cases/binary_test.rb
  59. +1 −1  activerecord/test/cases/bind_parameter_test.rb
  60. +1 −1  activerecord/test/cases/calculations_test.rb
  61. +1 −1  activerecord/test/cases/callbacks_test.rb
  62. +1 −1  activerecord/test/cases/clone_test.rb
  63. +1 −2  activerecord/test/cases/coders/yaml_column_test.rb
  64. +1 −1  activerecord/test/cases/column_alias_test.rb
  65. +1 −1  activerecord/test/cases/column_definition_test.rb
  66. +1 −1  activerecord/test/cases/connection_adapters/connection_handler_test.rb
  67. +1 −1  activerecord/test/cases/connection_management_test.rb
  68. +1 −1  activerecord/test/cases/connection_pool_test.rb
  69. +1 −1  activerecord/test/cases/counter_cache_test.rb
  70. +1 −1  activerecord/test/cases/custom_locking_test.rb
  71. +1 −1  activerecord/test/cases/database_statements_test.rb
  72. +1 −1  activerecord/test/cases/date_time_test.rb
  73. +1 −1  activerecord/test/cases/defaults_test.rb
  74. +1 −1  activerecord/test/cases/deprecated_finder_test.rb
  75. +1 −1  activerecord/test/cases/dirty_test.rb
  76. +1 −1  activerecord/test/cases/dup_test.rb
  77. +1 −1  activerecord/test/cases/dynamic_finder_match_test.rb
  78. +1 −1  activerecord/test/cases/finder_respond_to_test.rb
  79. +1 −1  activerecord/test/cases/finder_test.rb
  80. +1 −1  activerecord/test/cases/fixtures/file_test.rb
  81. +1 −1  activerecord/test/cases/fixtures_test.rb
  82. +1 −1  activerecord/test/cases/habtm_destroy_order_test.rb
  83. +10 −8 activerecord/test/cases/helper.rb
  84. +1 −2  activerecord/test/cases/i18n_test.rb
  85. +1 −1  activerecord/test/cases/identity_map/middleware_test.rb
  86. +2 −3 activerecord/test/cases/identity_map_test.rb
  87. +1 −1  activerecord/test/cases/inheritance_test.rb
  88. +1 −1  activerecord/test/cases/invalid_date_test.rb
  89. +1 −1  activerecord/test/cases/invertible_migration_test.rb
  90. +1 −1  activerecord/test/cases/json_serialization_test.rb
  91. +1 −1  activerecord/test/cases/lifecycle_test.rb
  92. +1 −1  activerecord/test/cases/locking_test.rb
  93. +1 −1  activerecord/test/cases/log_subscriber_test.rb
  94. +1 −1  activerecord/test/cases/mass_assignment_security_test.rb
  95. +1 −1  activerecord/test/cases/method_scoping_test.rb
  96. +1 −1  activerecord/test/cases/migration/command_recorder_test.rb
  97. +1 −1  activerecord/test/cases/migration_test.rb
  98. +1 −1  activerecord/test/cases/mixin_test.rb
  99. +1 −1  activerecord/test/cases/modules_test.rb
  100. +1 −1  activerecord/test/cases/multiple_db_test.rb
  101. +1 −1  activerecord/test/cases/named_scope_test.rb
  102. +1 −1  activerecord/test/cases/nested_attributes_test.rb
  103. +1 −1  activerecord/test/cases/persistence_test.rb
  104. +1 −1  activerecord/test/cases/pooled_connections_test.rb
  105. +1 −1  activerecord/test/cases/primary_keys_test.rb
  106. +1 −1  activerecord/test/cases/query_cache_test.rb
  107. +1 −1  activerecord/test/cases/quoting_test.rb
  108. +1 −1  activerecord/test/cases/readonly_test.rb
  109. +1 −1  activerecord/test/cases/reflection_test.rb
  110. +1 −1  activerecord/test/cases/relation_scoping_test.rb
  111. +1 −1  activerecord/test/cases/relation_test.rb
  112. +1 −1  activerecord/test/cases/relations_test.rb
  113. +1 −1  activerecord/test/cases/reload_models_test.rb
  114. +1 −1  activerecord/test/cases/sanitize_test.rb
  115. +1 −2  activerecord/test/cases/schema_dumper_test.rb
  116. +1 −1  activerecord/test/cases/serialization_test.rb
  117. +1 −1  activerecord/test/cases/session_store/session_test.rb
  118. +1 −1  activerecord/test/cases/session_store/sql_bypass.rb
  119. +1 −1  activerecord/test/cases/timestamp_test.rb
  120. +1 −1  activerecord/test/cases/transaction_callbacks_test.rb
  121. +1 −1  activerecord/test/cases/transactions_test.rb
  122. +1 −1  activerecord/test/cases/unconnected_test.rb
  123. +1 −1  activerecord/test/cases/validations/association_validation_test.rb
  124. +1 −1  activerecord/test/cases/validations/i18n_generate_message_validation_test.rb
  125. +1 −1  activerecord/test/cases/validations/i18n_validation_test.rb
  126. +1 −1  activerecord/test/cases/validations/uniqueness_validation_test.rb
  127. +1 −1  activerecord/test/cases/validations_test.rb
  128. +1 −1  activerecord/test/cases/xml_serialization_test.rb
  129. +1 −1  activerecord/test/cases/yaml_serialization_test.rb
  130. +136 −0 activerecord/test/config.example.yml
  131. +1 −0  activerecord/test/connections/db2.rb
  132. +1 −0  activerecord/test/connections/firebird.rb
  133. +1 −0  activerecord/test/connections/frontbase.rb
  134. +0 −18 activerecord/test/connections/jdbc_jdbcderby/connection.rb
  135. +0 −18 activerecord/test/connections/jdbc_jdbch2/connection.rb
  136. +0 −18 activerecord/test/connections/jdbc_jdbchsqldb/connection.rb
  137. +0 −26 activerecord/test/connections/jdbc_jdbcmysql/connection.rb
  138. +0 −26 activerecord/test/connections/jdbc_jdbcpostgresql/connection.rb
  139. +0 −25 activerecord/test/connections/jdbc_jdbcsqlite3/connection.rb
  140. +1 −0  activerecord/test/connections/jdbcderby.rb
  141. +1 −0  activerecord/test/connections/jdbch2.rb
  142. +1 −0  activerecord/test/connections/jdbchsqldb.rb
  143. +1 −0  activerecord/test/connections/jdbcmysql.rb
  144. +1 −0  activerecord/test/connections/jdbcpostgresql.rb
  145. +1 −0  activerecord/test/connections/jdbcsqlite3.rb
  146. +1 −0  activerecord/test/connections/mysql.rb
  147. +1 −0  activerecord/test/connections/mysql2.rb
  148. +0 −25 activerecord/test/connections/native_db2/connection.rb
  149. +0 −26 activerecord/test/connections/native_firebird/connection.rb
  150. +0 −27 activerecord/test/connections/native_frontbase/connection.rb
  151. +0 −25 activerecord/test/connections/native_mysql/connection.rb
  152. +0 −25 activerecord/test/connections/native_mysql2/connection.rb
  153. +0 −21 activerecord/test/connections/native_openbase/connection.rb
  154. +0 −35 activerecord/test/connections/native_oracle/connection.rb
  155. +0 −21 activerecord/test/connections/native_postgresql/connection.rb
  156. +0 −16 activerecord/test/connections/native_sqlite3/connection.rb
  157. +0 −19 activerecord/test/connections/native_sqlite3_mem/connection.rb
  158. +0 −23 activerecord/test/connections/native_sybase/connection.rb
  159. +1 −0  activerecord/test/connections/openbase.rb
  160. +1 −0  activerecord/test/connections/oracle.rb
  161. +1 −0  activerecord/test/connections/postgresql.rb
  162. +1 −0  activerecord/test/connections/sqlite3.rb
  163. +1 −0  activerecord/test/connections/sqlite3_mem.rb
  164. +1 −0  activerecord/test/connections/sybase.rb
  165. +39 −0 activerecord/test/support/config.rb
  166. +13 −0 activerecord/test/support/connection.rb
View
46 activerecord/RUNNING_UNIT_TESTS
@@ -1,43 +1,25 @@
-== Creating the test database
+== Configure databases
-The default names for the test databases are "activerecord_unittest" and
-"activerecord_unittest2". If you want to use another database name, then be sure
-to update the connection adapter setups you want to test within
-test/connections/<your database>/connection.rb.
-When you have the database online, you can import the fixture tables with
-the test/schema/*.sql files.
+Copy test/config.example.yml to test/config.yml and edit as needed. Or just run the tests for
+the first time, which will do the copy automatically and use the default (sqlite3).
-Make sure that you create database objects with the same user that you specified in
-connection.rb otherwise (on Postgres, at least) tests for default values will fail.
+You can build postgres and mysql databases using the build_postgresql and build_mysql rake tasks.
-== Running with Rake
+== Running the tests
-The easiest way to run the unit tests is through Rake. The default task runs
-the entire test suite for all the adapters. You can also run the suite on just
-one adapter by using the tasks test_mysql, test_sqlite3, test_postgresql or any
-of the other test_ tasks. For more information, checkout the full array of rake
-tasks with "rake -T"
+You can run a particular test file from the command line, e.g.
-Rake can be found at http://rake.rubyforge.org
+ $ ruby test/cases/base_test.rb
-== Running by hand
+To run a specific test:
-Unit tests are located in test/cases directory. If you only want to run a single test suite,
-you can do so with:
+ $ ruby test/cases/base_test.rb -n test_something_works
- rake test_mysql TEST=test/cases/base_test.rb
+You can run with a database other than the default you set in test/config.yml, using the ARCONN
+environment variable:
-That'll run the base suite using the MySQL-Ruby adapter. Some tests rely on the schema
-being initialized - you can initialize the schema with:
+ $ ARCONN=postgresql ruby test/cases/base_test.rb
- rake test_mysql TEST=test/cases/aaa_create_tables_test.rb
- rake mysql:build_databases
-
-To setup the testing environment for PostgreSQL use this command:
-
- rake postgresql:build_databases
-
-The incantation for running a particular test looks like this
-
- rake test TEST=test/cases/datatype_test_postgresql.rb TESTOPTS="-n test_timestamp_with_zone_values_without_rails_time_zone_support"
+You can run all the tests for a given database via rake:
+ $ rake test_postgresql
View
8 activerecord/Rakefile
@@ -43,26 +43,24 @@ end
%w( mysql mysql2 postgresql sqlite3 sqlite3_mem firebird db2 oracle sybase openbase frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb ).each do |adapter|
Rake::TestTask.new("test_#{adapter}") { |t|
- connection_path = "test/connections/#{adapter =~ /jdbc/ ? 'jdbc' : 'native'}_#{adapter}"
adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z0-9]+/]
- t.libs << "test" << connection_path
t.test_files = (Dir.glob( "test/cases/**/*_test.rb" ).reject {
|x| x =~ /\/adapters\//
} + Dir.glob("test/cases/adapters/#{adapter_short}/**/*_test.rb")).sort
t.verbose = true
t.warning = true
+ t.ruby_opts = ["-r#{File.expand_path('../', __FILE__)}/test/connections/#{adapter}"]
}
task "isolated_test_#{adapter}" do
- connection_path = "test/connections/#{adapter =~ /jdbc/ ? 'jdbc' : 'native'}_#{adapter}"
adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z0-9]+/]
- puts [adapter, adapter_short, connection_path].inspect
+ puts [adapter, adapter_short].inspect
ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
(Dir["test/cases/**/*_test.rb"].reject {
|x| x =~ /\/adapters\//
} + Dir["test/cases/adapters/#{adapter_short}/**/*_test.rb"]).all? do |file|
- sh(ruby, "-Ilib:test:#{connection_path}", file)
+ sh(ruby, "-Itest", "-r#{File.expand_path('../', __FILE__)}/test/connections/#{adapter}", file)
end or raise "Failures"
end
View
1  activerecord/test/.gitignore
@@ -0,0 +1 @@
+/config.yml
View
2  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
View
2  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
View
2  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
View
2  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
View
2  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
View
2  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
View
2  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
View
3  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 @@ def test_type_cast_false
end
end
end
-
View
2  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'
View
2  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'
View
2  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
View
2  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
View
2  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
View
2  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
View
2  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'
View
2  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'
View
2  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'
View
2  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
View
2  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
View
2  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
View
2  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
View
2  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
View
2  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
View
2  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
View
2  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
View
2  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'
View
2  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
View
2  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'
View
2  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?
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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
View
2  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'
View
2  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'
View
2  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
View
4 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 @@ def test_should_property_quote_string_primary_keys
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
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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
View
2  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'
View
2  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'
View
2  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'
View
2  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
View
2  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
View
2  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
View
2  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'
View
2  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'
View
2  activerecord/test/cases/clone_test.rb
@@ -1,4 +1,4 @@
-require "cases/helper"
+require File.expand_path('../helper', __FILE__)
require 'models/topic'
module ActiveRecord
View
3  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
View
2  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
View
2  activerecord/test/cases/column_definition_test.rb
@@ -1,4 +1,4 @@
-require "cases/helper"
+require File.expand_path('../helper', __FILE__)
module ActiveRecord
module ConnectionAdapters
View
2  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
View
2  activerecord/test/cases/connection_management_test.rb
@@ -1,4 +1,4 @@
-require "cases/helper"
+require File.expand_path('../helper', __FILE__)
module ActiveRecord
module ConnectionAdapters
View
2  activerecord/test/cases/connection_pool_test.rb
@@ -1,4 +1,4 @@
-require "cases/helper"
+require File.expand_path('../helper', __FILE__)
module ActiveRecord
module ConnectionAdapters
View
2  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'
View
2  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
View
2  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
View
2  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'
View
2  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'
View
2  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
View
2  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'
View
2  activerecord/test/cases/dup_test.rb
@@ -1,4 +1,4 @@
-require "cases/helper"
+require File.expand_path('../helper', __FILE__)
require 'models/topic'
module ActiveRecord
View
2  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
View
2  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
View
2  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'
View
2  activerecord/test/cases/fixtures/file_test.rb
@@ -1,4 +1,4 @@
-require "cases/helper"
+require File.expand_path('../../helper', __FILE__)
require 'tempfile'
module ActiveRecord
View
2  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'
View
2  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"
View
18 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 '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
View
3  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 @@ def test_translated_model_names_with_sti_fallback
assert_equal 'topic model', Reply.model_name.human
end
end
-
View
2  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
View
5 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 @@ def test_inherited_without_type_attribute_without_identity_map
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)
View
2  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'
View
2  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
View
2  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
View
2  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'
View
2  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'
View
2  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'
View
2  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"
View
2  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'
View
2  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'
View
2  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
View
2  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'
View
2  activerecord/test/cases/mixin_test.rb
@@ -1,4 +1,4 @@
-require "cases/helper"
+require File.expand_path('../helper', __FILE__)
class Mixin < ActiveRecord::Base
end
View
2  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'
View
2  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'
View
2  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'
View
2  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"
View
2  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'
View
2  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"
View
2  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'
View
2  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'
View
2  activerecord/test/cases/quoting_test.rb
@@ -1,4 +1,4 @@
-require "cases/helper"
+require File.expand_path('../helper', __FILE__)
module ActiveRecord
module ConnectionAdapters
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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
View
3  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 @@ def test_schema_dump_keeps_id_column_when_id_is_false_and_id_column_added
assert_match %r{t.string[[:space:]]+"id",[[:space:]]+:null => false$}, match[2], "non-primary key id column not preserved"
end
end
-
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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
View
2  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'
View
2  activerecord/test/cases/unconnected_test.rb
@@ -1,4 +1,4 @@
-require "cases/helper"
+require File.expand_path('../helper', __FILE__)
class TestRecord < ActiveRecord::Base
end
View
2  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'
View
2  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
View
2  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'
View
2  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'
View
2  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'
View
2  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'
View
2  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
View
136 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
View
1  activerecord/test/connections/db2.rb
@@ -0,0 +1 @@
+ENV['ARCONN'] = 'db2'
View
1  activerecord/test/connections/firebird.rb
@@ -0,0 +1 @@
+ENV['ARCONN'] = 'firebird'
View
1  activerecord/test/connections/frontbase.rb
@@ -0,0 +1 @@
+ENV['ARCONN'] = 'frontbase'
View
18 activerecord/test/connections/jdbc_jdbcderby/connection.rb
@@ -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'
View
18 activerecord/test/connections/jdbc_jdbch2/connection.rb
@@ -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'
View
18 activerecord/test/connections/jdbc_jdbchsqldb/connection.rb
@@ -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'
View
26 activerecord/test/connections/jdbc_jdbcmysql/connection.rb
@@ -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'
-
View
26 activerecord/test/connections/jdbc_jdbcpostgresql/connection.rb
@@ -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'
-
View
25 activerecord/test/connections/jdbc_jdbcsqlite3/connection.rb
@@ -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)
View
1  activerecord/test/connections/jdbcderby.rb
@@ -0,0 +1 @@
+ENV['ARCONN'] = 'jdbcderby'
View
1  activerecord/test/connections/jdbch2.rb
@@ -0,0 +1 @@
+ENV['ARCONN'] = 'jdbch2'
View
1  activerecord/test/connections/jdbchsqldb.rb
@@ -0,0 +1 @@
+ENV['ARCONN'] = 'jdbchsqldb'
View
1  activerecord/test/connections/jdbcmysql.rb
@@ -0,0 +1 @@
+ENV['ARCONN'] = 'jdbcmysql'
View
1  activerecord/test/connections/jdbcpostgresql.rb
@@ -0,0 +1 @@
+ENV['ARCONN'] = 'jdbcpostgresql'
View
1  activerecord/test/connections/jdbcsqlite3.rb
@@ -0,0 +1 @@
+ENV['ARCONN'] = 'jdbcsqlite3'
View
1  activerecord/test/connections/mysql.rb
@@ -0,0 +1 @@
+ENV['ARCONN'] = 'mysql'
View
1  activerecord/test/connections/mysql2.rb
@@ -0,0 +1 @@
+ENV['ARCONN'] = 'mysql2'
View
25 activerecord/test/connections/native_db2/connection.rb
@@ -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'
View
26 activerecord/test/connections/native_firebird/connection.rb
@@ -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'
View
27 activerecord/test/connections/native_frontbase/connection.rb
@@ -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'
View
25 activerecord/test/connections/native_mysql/connection.rb
@@ -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'
View
25 activerecord/test/connections/native_mysql2/connection.rb
@@ -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',