Permalink
Browse files

Move tests to cases

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8660 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 105a27f commit 42b39ae3f2991692672364d7e09b1e4002e66261 @jeremy jeremy committed Jan 18, 2008
Showing with 513 additions and 515 deletions.
  1. +1 −1 activerecord/test/{ → cases}/aaa_create_tables_test.rb
  2. +1 −1 activerecord/test/{ → cases}/active_schema_test_mysql.rb
  3. 0 activerecord/test/{ → cases}/adapter_test.rb
  4. +95 −95 activerecord/test/{ → cases}/adapter_test_sqlserver.rb
  5. +15 −15 activerecord/test/{ → cases}/aggregations_test.rb
  6. +2 −2 activerecord/test/{ → cases}/ar_schema_test.rb
  7. +6 −7 activerecord/test/{ → cases}/associations/callbacks_test.rb
  8. +10 −10 activerecord/test/{ → cases}/associations/cascaded_eager_loading_test.rb
  9. +3 −3 activerecord/test/{ → cases}/associations/eager_singularization_test.rb
  10. +38 −38 activerecord/test/{ → cases}/associations/eager_test.rb
  11. +6 −6 activerecord/test/{ → cases}/associations/extension_test.rb
  12. +5 −5 activerecord/test/{ → cases}/associations/inner_join_association_test.rb
  13. +15 −15 activerecord/test/{ → cases}/associations/join_model_test.rb
  14. +15 −15 activerecord/test/{ → cases}/associations_test.rb
  15. +6 −6 activerecord/test/{ → cases}/attribute_methods_test.rb
  16. +124 −124 activerecord/test/{ → cases}/base_test.rb
  17. 0 activerecord/test/{ → cases}/binary_test.rb
  18. +20 −20 activerecord/test/{ → cases}/calculations_test.rb
  19. +5 −5 activerecord/test/{ → cases}/callbacks_test.rb
  20. +1 −1 activerecord/test/{ → cases}/class_inheritable_attributes_test.rb
  21. 0 activerecord/test/{ → cases}/column_alias_test.rb
  22. 0 activerecord/test/{ → cases}/connection_test_firebird.rb
  23. 0 activerecord/test/{ → cases}/connection_test_mysql.rb
  24. +11 −11 activerecord/test/{ → cases}/copy_table_test_sqlite.rb
  25. +2 −2 activerecord/test/{ → cases}/datatype_test_postgresql.rb
  26. +1 −1 activerecord/test/{ → cases}/date_time_test.rb
  27. 0 activerecord/test/{ → cases}/default_test_firebird.rb
  28. 0 activerecord/test/{ → cases}/defaults_test.rb
  29. 0 activerecord/test/{ → cases}/deprecated_finder_test.rb
  30. +7 −7 activerecord/test/{ → cases}/finder_test.rb
  31. +3 −3 activerecord/test/{ → cases}/fixtures_test.rb
  32. +11 −11 activerecord/test/{ → cases}/inheritance_test.rb
  33. 0 activerecord/test/{ → cases}/json_serialization_test.rb
  34. +3 −3 activerecord/test/{ → cases}/lifecycle_test.rb
  35. +3 −3 activerecord/test/{ → cases}/locking_test.rb
  36. +24 −24 activerecord/test/{ → cases}/method_scoping_test.rb
  37. +31 −32 activerecord/test/{ → cases}/migration_test.rb
  38. 0 activerecord/test/{ → cases}/migration_test_firebird.rb
  39. +4 −4 activerecord/test/{ → cases}/mixin_test.rb
  40. +3 −3 activerecord/test/{ → cases}/modules_test.rb
  41. 0 activerecord/test/{ → cases}/multiple_db_test.rb
  42. +2 −2 activerecord/test/{ → cases}/pk_test.rb
  43. 0 activerecord/test/{ → cases}/query_cache_test.rb
  44. +3 −3 activerecord/test/{ → cases}/readonly_test.rb
  45. +3 −3 activerecord/test/{ → cases}/reflection_test.rb
  46. +1 −1 activerecord/test/{ → cases}/reserved_word_test_mysql.rb
  47. +1 −1 activerecord/test/{ → cases}/schema_authorization_test_postgresql.rb
  48. +14 −14 activerecord/test/{ → cases}/schema_dumper_test.rb
  49. 0 activerecord/test/{ → cases}/schema_test_postgresql.rb
  50. +3 −3 activerecord/test/{ → cases}/serialization_test.rb
  51. +1 −1 activerecord/test/{ → cases}/synonym_test_oracle.rb
  52. 0 activerecord/test/{ → cases}/table_name_test_sqlserver.rb
  53. +3 −3 activerecord/test/{ → cases}/threaded_connections_test.rb
  54. 0 activerecord/test/{ → cases}/transactions_test.rb
  55. 0 activerecord/test/{ → cases}/unconnected_test.rb
  56. 0 activerecord/test/{ → cases}/validations_test.rb
  57. 0 activerecord/test/{ → cases}/xml_serialization_test.rb
  58. +1 −1 activerecord/test/connections/native_db2/connection.rb
  59. +1 −1 activerecord/test/connections/native_firebird/connection.rb
  60. +1 −1 activerecord/test/connections/native_frontbase/connection.rb
  61. +1 −1 activerecord/test/connections/native_mysql/connection.rb
  62. +1 −1 activerecord/test/connections/native_openbase/connection.rb
  63. +1 −1 activerecord/test/connections/native_oracle/connection.rb
  64. +1 −1 activerecord/test/connections/native_postgresql/connection.rb
  65. +1 −1 activerecord/test/connections/native_sqlite/connection.rb
  66. +1 −1 activerecord/test/connections/native_sqlite3/connection.rb
  67. +1 −1 activerecord/test/connections/native_sqlite3/in_memory_connection.rb
  68. +1 −1 activerecord/test/connections/native_sybase/connection.rb
@@ -21,7 +21,7 @@ def test_load_schema
end
assert true
end
-
+
def test_drop_and_create_courses_table
if Course.connection.supports_migrations?
eval(File.read("#{File.dirname(__FILE__)}/fixtures/db_definitions/schema2.rb"))
@@ -38,7 +38,7 @@ def test_add_column_with_limit
def test_drop_table_with_specific_database
assert_equal "DROP TABLE `otherdb`.`people`", drop_table('otherdb.people')
end
-
+
private
def method_missing(method_symbol, *arguments)
ActiveRecord::Base.connection.send(method_symbol, *arguments)
@@ -1,95 +1,95 @@
-require 'abstract_unit'
-require 'fixtures/default'
-require 'fixtures/post'
-require 'fixtures/task'
-
-class SqlServerAdapterTest < ActiveSupport::TestCase
- class TableWithRealColumn < ActiveRecord::Base; end
-
- fixtures :posts, :tasks
-
- def setup
- @connection = ActiveRecord::Base.connection
- end
-
- def teardown
- @connection.execute("SET LANGUAGE us_english") rescue nil
- end
-
- def test_real_column_has_float_type
- assert_equal :float, TableWithRealColumn.columns_hash["real_number"].type
- end
-
- # SQL Server 2000 has a bug where some unambiguous date formats are not
- # correctly identified if the session language is set to german
- def test_date_insertion_when_language_is_german
- @connection.execute("SET LANGUAGE deutsch")
-
- assert_nothing_raised do
- Task.create(:starting => Time.utc(2000, 1, 31, 5, 42, 0), :ending => Date.new(2006, 12, 31))
- end
- end
-
- def test_indexes_with_descending_order
- # Make sure we have an index with descending order
- @connection.execute "CREATE INDEX idx_credit_limit ON accounts (credit_limit DESC)" rescue nil
- assert_equal ["credit_limit"], @connection.indexes('accounts').first.columns
- ensure
- @connection.execute "DROP INDEX accounts.idx_credit_limit"
- end
-
- def test_execute_without_block_closes_statement
- assert_all_statements_used_are_closed do
- @connection.execute("SELECT 1")
- end
- end
-
- def test_execute_with_block_closes_statement
- assert_all_statements_used_are_closed do
- @connection.execute("SELECT 1") do |sth|
- assert !sth.finished?, "Statement should still be alive within block"
- end
- end
- end
-
- def test_insert_with_identity_closes_statement
- assert_all_statements_used_are_closed do
- @connection.insert("INSERT INTO accounts ([id], [firm_id],[credit_limit]) values (999, 1, 50)")
- end
- end
-
- def test_insert_without_identity_closes_statement
- assert_all_statements_used_are_closed do
- @connection.insert("INSERT INTO accounts ([firm_id],[credit_limit]) values (1, 50)")
- end
- end
-
- def test_active_closes_statement
- assert_all_statements_used_are_closed do
- @connection.active?
- end
- end
-
- def assert_all_statements_used_are_closed(&block)
- existing_handles = []
- ObjectSpace.each_object(DBI::StatementHandle) {|handle| existing_handles << handle}
- GC.disable
-
- yield
-
- used_handles = []
- ObjectSpace.each_object(DBI::StatementHandle) {|handle| used_handles << handle unless existing_handles.include? handle}
-
- assert_block "No statements were used within given block" do
- used_handles.size > 0
- end
-
- ObjectSpace.each_object(DBI::StatementHandle) do |handle|
- assert_block "Statement should have been closed within given block" do
- handle.finished?
- end
- end
- ensure
- GC.enable
- end
-end
+require 'abstract_unit'
+require 'fixtures/default'
+require 'fixtures/post'
+require 'fixtures/task'
+
+class SqlServerAdapterTest < ActiveSupport::TestCase
+ class TableWithRealColumn < ActiveRecord::Base; end
+
+ fixtures :posts, :tasks
+
+ def setup
+ @connection = ActiveRecord::Base.connection
+ end
+
+ def teardown
+ @connection.execute("SET LANGUAGE us_english") rescue nil
+ end
+
+ def test_real_column_has_float_type
+ assert_equal :float, TableWithRealColumn.columns_hash["real_number"].type
+ end
+
+ # SQL Server 2000 has a bug where some unambiguous date formats are not
+ # correctly identified if the session language is set to german
+ def test_date_insertion_when_language_is_german
+ @connection.execute("SET LANGUAGE deutsch")
+
+ assert_nothing_raised do
+ Task.create(:starting => Time.utc(2000, 1, 31, 5, 42, 0), :ending => Date.new(2006, 12, 31))
+ end
+ end
+
+ def test_indexes_with_descending_order
+ # Make sure we have an index with descending order
+ @connection.execute "CREATE INDEX idx_credit_limit ON accounts (credit_limit DESC)" rescue nil
+ assert_equal ["credit_limit"], @connection.indexes('accounts').first.columns
+ ensure
+ @connection.execute "DROP INDEX accounts.idx_credit_limit"
+ end
+
+ def test_execute_without_block_closes_statement
+ assert_all_statements_used_are_closed do
+ @connection.execute("SELECT 1")
+ end
+ end
+
+ def test_execute_with_block_closes_statement
+ assert_all_statements_used_are_closed do
+ @connection.execute("SELECT 1") do |sth|
+ assert !sth.finished?, "Statement should still be alive within block"
+ end
+ end
+ end
+
+ def test_insert_with_identity_closes_statement
+ assert_all_statements_used_are_closed do
+ @connection.insert("INSERT INTO accounts ([id], [firm_id],[credit_limit]) values (999, 1, 50)")
+ end
+ end
+
+ def test_insert_without_identity_closes_statement
+ assert_all_statements_used_are_closed do
+ @connection.insert("INSERT INTO accounts ([firm_id],[credit_limit]) values (1, 50)")
+ end
+ end
+
+ def test_active_closes_statement
+ assert_all_statements_used_are_closed do
+ @connection.active?
+ end
+ end
+
+ def assert_all_statements_used_are_closed(&block)
+ existing_handles = []
+ ObjectSpace.each_object(DBI::StatementHandle) {|handle| existing_handles << handle}
+ GC.disable
+
+ yield
+
+ used_handles = []
+ ObjectSpace.each_object(DBI::StatementHandle) {|handle| used_handles << handle unless existing_handles.include? handle}
+
+ assert_block "No statements were used within given block" do
+ used_handles.size > 0
+ end
+
+ ObjectSpace.each_object(DBI::StatementHandle) do |handle|
+ assert_block "Statement should have been closed within given block" do
+ handle.finished?
+ end
+ end
+ ensure
+ GC.enable
+ end
+end
@@ -1,5 +1,5 @@
require 'abstract_unit'
-require 'fixtures/customer'
+require 'models/customer'
class AggregationsTest < ActiveSupport::TestCase
fixtures :customers
@@ -9,36 +9,36 @@ def test_find_single_value_object
assert_kind_of Money, customers(:david).balance
assert_equal 300, customers(:david).balance.exchange_to("DKK").amount
end
-
+
def test_find_multiple_value_object
assert_equal customers(:david).address_street, customers(:david).address.street
assert(
customers(:david).address.close_to?(Address.new("Different Street", customers(:david).address_city, customers(:david).address_country))
)
end
-
+
def test_change_single_value_object
customers(:david).balance = Money.new(100)
customers(:david).save
assert_equal 100, customers(:david).reload.balance.amount
end
-
+
def test_immutable_value_objects
customers(:david).balance = Money.new(100)
assert_raise(ActiveSupport::FrozenObjectError) { customers(:david).balance.instance_eval { @amount = 20 } }
- end
-
+ end
+
def test_inferred_mapping
assert_equal "35.544623640962634", customers(:david).gps_location.latitude
assert_equal "-105.9309951055148", customers(:david).gps_location.longitude
-
+
customers(:david).gps_location = GpsLocation.new("39x-110")
assert_equal "39", customers(:david).gps_location.latitude
assert_equal "-110", customers(:david).gps_location.longitude
-
+
customers(:david).save
-
+
customers(:david).reload
assert_equal "39", customers(:david).gps_location.latitude
@@ -53,7 +53,7 @@ def test_reloaded_instance_refreshes_aggregations
customers(:david).reload
assert_equal '24x113', customers(:david)['gps_location']
- assert_equal GpsLocation.new('24x113'), customers(:david).gps_location
+ assert_equal GpsLocation.new('24x113'), customers(:david).gps_location
end
def test_gps_equality
@@ -63,32 +63,32 @@ def test_gps_equality
def test_gps_inequality
assert GpsLocation.new('39x110') != GpsLocation.new('39x111')
end
-
+
def test_allow_nil_gps_is_nil
assert_equal nil, customers(:zaphod).gps_location
end
-
+
def test_allow_nil_gps_set_to_nil
customers(:david).gps_location = nil
customers(:david).save
customers(:david).reload
assert_equal nil, customers(:david).gps_location
end
-
+
def test_allow_nil_set_address_attributes_to_nil
customers(:zaphod).address = nil
assert_equal nil, customers(:zaphod).attributes[:address_street]
assert_equal nil, customers(:zaphod).attributes[:address_city]
assert_equal nil, customers(:zaphod).attributes[:address_country]
end
-
+
def test_allow_nil_address_set_to_nil
customers(:zaphod).address = nil
customers(:zaphod).save
customers(:zaphod).reload
assert_equal nil, customers(:zaphod).address
end
-
+
def test_nil_raises_error_when_allow_nil_is_false
assert_raise(NoMethodError) { customers(:david).balance = nil }
end
@@ -1,7 +1,7 @@
require 'abstract_unit'
-require "#{File.dirname(__FILE__)}/../lib/active_record/schema"
+require 'active_record/schema'
-if ActiveRecord::Base.connection.supports_migrations?
+if ActiveRecord::Base.connection.supports_migrations?
class ActiveRecordSchemaTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
@@ -1,10 +1,10 @@
require 'abstract_unit'
-require 'fixtures/post'
-require 'fixtures/comment'
-require 'fixtures/author'
-require 'fixtures/category'
-require 'fixtures/project'
-require 'fixtures/developer'
+require 'models/post'
+require 'models/comment'
+require 'models/author'
+require 'models/category'
+require 'models/project'
+require 'models/developer'
class AssociationCallbacksTest < ActiveSupport::TestCase
fixtures :posts, :authors, :projects, :developers
@@ -144,4 +144,3 @@ def test_dont_add_if_before_callback_raises_exception
assert !@david.unchangable_posts.include?(@authorless)
end
end
-
@@ -1,12 +1,12 @@
require 'abstract_unit'
-require 'fixtures/post'
-require 'fixtures/comment'
-require 'fixtures/author'
-require 'fixtures/category'
-require 'fixtures/categorization'
-require 'fixtures/company'
-require 'fixtures/topic'
-require 'fixtures/reply'
+require 'models/post'
+require 'models/comment'
+require 'models/author'
+require 'models/category'
+require 'models/categorization'
+require 'models/company'
+require 'models/topic'
+require 'models/reply'
class CascadedEagerLoadingTest < ActiveSupport::TestCase
fixtures :authors, :mixins, :companies, :posts, :topics
@@ -93,8 +93,8 @@ def test_eager_association_loading_of_stis_with_multiple_references
end
end
-require 'fixtures/vertex'
-require 'fixtures/edge'
+require 'models/vertex'
+require 'models/edge'
class CascadedEagerLoadingTest < ActiveSupport::TestCase
fixtures :edges, :vertices
@@ -85,7 +85,7 @@ def setup
@have_tables = false
end
end
-
+
def teardown
ActiveRecord::Base.connection.drop_table :viri
ActiveRecord::Base.connection.drop_table :octopi
@@ -99,7 +99,7 @@ def teardown
ActiveRecord::Base.connection.drop_table :dresses
ActiveRecord::Base.connection.drop_table :compresses
end
-
+
def test_eager_no_extra_singularization_belongs_to
return unless @have_tables
assert_nothing_raised do
@@ -135,7 +135,7 @@ def test_eager_no_extra_singularization_has_many_through_belongs_to
Crisis.find(:all, :include => :successes)
end
end
-
+
def test_eager_no_extra_singularization_has_many_through_has_many
return unless @have_tables
assert_nothing_raised do
Oops, something went wrong.

0 comments on commit 42b39ae

Please sign in to comment.