aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/aaa_create_tables_test.rb (renamed from activerecord/test/aaa_create_tables_test.rb)2
-rw-r--r--activerecord/test/cases/active_schema_test_mysql.rb (renamed from activerecord/test/active_schema_test_mysql.rb)2
-rw-r--r--activerecord/test/cases/adapter_test.rb (renamed from activerecord/test/adapter_test.rb)0
-rw-r--r--activerecord/test/cases/adapter_test_sqlserver.rb (renamed from activerecord/test/adapter_test_sqlserver.rb)190
-rw-r--r--activerecord/test/cases/aggregations_test.rb (renamed from activerecord/test/aggregations_test.rb)30
-rw-r--r--activerecord/test/cases/ar_schema_test.rb (renamed from activerecord/test/ar_schema_test.rb)4
-rw-r--r--activerecord/test/cases/associations/callbacks_test.rb (renamed from activerecord/test/associations/callbacks_test.rb)13
-rw-r--r--activerecord/test/cases/associations/cascaded_eager_loading_test.rb (renamed from activerecord/test/associations/cascaded_eager_loading_test.rb)20
-rw-r--r--activerecord/test/cases/associations/eager_singularization_test.rb (renamed from activerecord/test/associations/eager_singularization_test.rb)6
-rw-r--r--activerecord/test/cases/associations/eager_test.rb (renamed from activerecord/test/associations/eager_test.rb)76
-rw-r--r--activerecord/test/cases/associations/extension_test.rb (renamed from activerecord/test/associations/extension_test.rb)12
-rw-r--r--activerecord/test/cases/associations/inner_join_association_test.rb (renamed from activerecord/test/associations/inner_join_association_test.rb)10
-rw-r--r--activerecord/test/cases/associations/join_model_test.rb (renamed from activerecord/test/associations/join_model_test.rb)30
-rwxr-xr-xactiverecord/test/cases/associations_test.rb (renamed from activerecord/test/associations_test.rb)30
-rwxr-xr-xactiverecord/test/cases/attribute_methods_test.rb (renamed from activerecord/test/attribute_methods_test.rb)12
-rwxr-xr-xactiverecord/test/cases/base_test.rb (renamed from activerecord/test/base_test.rb)248
-rw-r--r--activerecord/test/cases/binary_test.rb (renamed from activerecord/test/binary_test.rb)0
-rw-r--r--activerecord/test/cases/calculations_test.rb (renamed from activerecord/test/calculations_test.rb)40
-rw-r--r--activerecord/test/cases/callbacks_test.rb (renamed from activerecord/test/callbacks_test.rb)10
-rw-r--r--activerecord/test/cases/class_inheritable_attributes_test.rb (renamed from activerecord/test/class_inheritable_attributes_test.rb)2
-rw-r--r--activerecord/test/cases/column_alias_test.rb (renamed from activerecord/test/column_alias_test.rb)0
-rw-r--r--activerecord/test/cases/connection_test_firebird.rb (renamed from activerecord/test/connection_test_firebird.rb)0
-rw-r--r--activerecord/test/cases/connection_test_mysql.rb (renamed from activerecord/test/connection_test_mysql.rb)0
-rw-r--r--activerecord/test/cases/copy_table_test_sqlite.rb (renamed from activerecord/test/copy_table_test_sqlite.rb)22
-rw-r--r--activerecord/test/cases/datatype_test_postgresql.rb (renamed from activerecord/test/datatype_test_postgresql.rb)4
-rw-r--r--activerecord/test/cases/date_time_test.rb (renamed from activerecord/test/date_time_test.rb)2
-rw-r--r--activerecord/test/cases/default_test_firebird.rb (renamed from activerecord/test/default_test_firebird.rb)0
-rw-r--r--activerecord/test/cases/defaults_test.rb (renamed from activerecord/test/defaults_test.rb)0
-rwxr-xr-xactiverecord/test/cases/deprecated_finder_test.rb (renamed from activerecord/test/deprecated_finder_test.rb)0
-rw-r--r--activerecord/test/cases/finder_test.rb (renamed from activerecord/test/finder_test.rb)14
-rwxr-xr-xactiverecord/test/cases/fixtures_test.rb (renamed from activerecord/test/fixtures_test.rb)6
-rwxr-xr-xactiverecord/test/cases/inheritance_test.rb (renamed from activerecord/test/inheritance_test.rb)22
-rw-r--r--activerecord/test/cases/json_serialization_test.rb (renamed from activerecord/test/json_serialization_test.rb)0
-rwxr-xr-xactiverecord/test/cases/lifecycle_test.rb (renamed from activerecord/test/lifecycle_test.rb)6
-rw-r--r--activerecord/test/cases/locking_test.rb (renamed from activerecord/test/locking_test.rb)6
-rw-r--r--activerecord/test/cases/method_scoping_test.rb (renamed from activerecord/test/method_scoping_test.rb)48
-rw-r--r--activerecord/test/cases/migration_test.rb (renamed from activerecord/test/migration_test.rb)63
-rw-r--r--activerecord/test/cases/migration_test_firebird.rb (renamed from activerecord/test/migration_test_firebird.rb)0
-rw-r--r--activerecord/test/cases/mixin_test.rb (renamed from activerecord/test/mixin_test.rb)8
-rw-r--r--activerecord/test/cases/modules_test.rb (renamed from activerecord/test/modules_test.rb)6
-rw-r--r--activerecord/test/cases/multiple_db_test.rb (renamed from activerecord/test/multiple_db_test.rb)0
-rw-r--r--activerecord/test/cases/pk_test.rb (renamed from activerecord/test/pk_test.rb)4
-rw-r--r--activerecord/test/cases/query_cache_test.rb (renamed from activerecord/test/query_cache_test.rb)0
-rwxr-xr-xactiverecord/test/cases/readonly_test.rb (renamed from activerecord/test/readonly_test.rb)6
-rw-r--r--activerecord/test/cases/reflection_test.rb (renamed from activerecord/test/reflection_test.rb)6
-rw-r--r--activerecord/test/cases/reserved_word_test_mysql.rb (renamed from activerecord/test/reserved_word_test_mysql.rb)2
-rw-r--r--activerecord/test/cases/schema_authorization_test_postgresql.rb (renamed from activerecord/test/schema_authorization_test_postgresql.rb)2
-rw-r--r--activerecord/test/cases/schema_dumper_test.rb (renamed from activerecord/test/schema_dumper_test.rb)28
-rw-r--r--activerecord/test/cases/schema_test_postgresql.rb (renamed from activerecord/test/schema_test_postgresql.rb)0
-rw-r--r--activerecord/test/cases/serialization_test.rb (renamed from activerecord/test/serialization_test.rb)6
-rw-r--r--activerecord/test/cases/synonym_test_oracle.rb (renamed from activerecord/test/synonym_test_oracle.rb)2
-rw-r--r--activerecord/test/cases/table_name_test_sqlserver.rb (renamed from activerecord/test/table_name_test_sqlserver.rb)0
-rw-r--r--activerecord/test/cases/threaded_connections_test.rb (renamed from activerecord/test/threaded_connections_test.rb)6
-rw-r--r--activerecord/test/cases/transactions_test.rb (renamed from activerecord/test/transactions_test.rb)0
-rwxr-xr-xactiverecord/test/cases/unconnected_test.rb (renamed from activerecord/test/unconnected_test.rb)0
-rwxr-xr-xactiverecord/test/cases/validations_test.rb (renamed from activerecord/test/validations_test.rb)0
-rw-r--r--activerecord/test/cases/xml_serialization_test.rb (renamed from activerecord/test/xml_serialization_test.rb)0
-rw-r--r--activerecord/test/connections/native_db2/connection.rb2
-rw-r--r--activerecord/test/connections/native_firebird/connection.rb2
-rw-r--r--activerecord/test/connections/native_frontbase/connection.rb2
-rw-r--r--activerecord/test/connections/native_mysql/connection.rb2
-rw-r--r--activerecord/test/connections/native_openbase/connection.rb2
-rw-r--r--activerecord/test/connections/native_oracle/connection.rb2
-rw-r--r--activerecord/test/connections/native_postgresql/connection.rb2
-rw-r--r--activerecord/test/connections/native_sqlite/connection.rb2
-rw-r--r--activerecord/test/connections/native_sqlite3/connection.rb2
-rw-r--r--activerecord/test/connections/native_sqlite3/in_memory_connection.rb2
-rw-r--r--activerecord/test/connections/native_sybase/connection.rb2
68 files changed, 513 insertions, 515 deletions
diff --git a/activerecord/test/aaa_create_tables_test.rb b/activerecord/test/cases/aaa_create_tables_test.rb
index f255182952..56c9cabac1 100644
--- a/activerecord/test/aaa_create_tables_test.rb
+++ b/activerecord/test/cases/aaa_create_tables_test.rb
@@ -21,7 +21,7 @@ class AAACreateTablesTest < ActiveSupport::TestCase
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"))
diff --git a/activerecord/test/active_schema_test_mysql.rb b/activerecord/test/cases/active_schema_test_mysql.rb
index 336f74d234..2611153fda 100644
--- a/activerecord/test/active_schema_test_mysql.rb
+++ b/activerecord/test/cases/active_schema_test_mysql.rb
@@ -38,7 +38,7 @@ class ActiveSchemaTest < ActiveSupport::TestCase
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)
diff --git a/activerecord/test/adapter_test.rb b/activerecord/test/cases/adapter_test.rb
index d93a99d7cd..d93a99d7cd 100644
--- a/activerecord/test/adapter_test.rb
+++ b/activerecord/test/cases/adapter_test.rb
diff --git a/activerecord/test/adapter_test_sqlserver.rb b/activerecord/test/cases/adapter_test_sqlserver.rb
index 0556466bbd..494fc98a2f 100644
--- a/activerecord/test/adapter_test_sqlserver.rb
+++ b/activerecord/test/cases/adapter_test_sqlserver.rb
@@ -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
diff --git a/activerecord/test/aggregations_test.rb b/activerecord/test/cases/aggregations_test.rb
index ea041fe955..66fa46b3f0 100644
--- a/activerecord/test/aggregations_test.rb
+++ b/activerecord/test/cases/aggregations_test.rb
@@ -1,5 +1,5 @@
require 'abstract_unit'
-require 'fixtures/customer'
+require 'models/customer'
class AggregationsTest < ActiveSupport::TestCase
fixtures :customers
@@ -9,36 +9,36 @@ class AggregationsTest < ActiveSupport::TestCase
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 @@ class AggregationsTest < ActiveSupport::TestCase
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 @@ class AggregationsTest < ActiveSupport::TestCase
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
diff --git a/activerecord/test/ar_schema_test.rb b/activerecord/test/cases/ar_schema_test.rb
index c3dca54a94..3b290333e9 100644
--- a/activerecord/test/ar_schema_test.rb
+++ b/activerecord/test/cases/ar_schema_test.rb
@@ -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
diff --git a/activerecord/test/associations/callbacks_test.rb b/activerecord/test/cases/associations/callbacks_test.rb
index 29f93788e5..0b510df8d9 100644
--- a/activerecord/test/associations/callbacks_test.rb
+++ b/activerecord/test/cases/associations/callbacks_test.rb
@@ -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 @@ class AssociationCallbacksTest < ActiveSupport::TestCase
assert !@david.unchangable_posts.include?(@authorless)
end
end
-
diff --git a/activerecord/test/associations/cascaded_eager_loading_test.rb b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb
index 9d6dffbd48..0ca0b21084 100644
--- a/activerecord/test/associations/cascaded_eager_loading_test.rb
+++ b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb
@@ -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 @@ class CascadedEagerLoadingTest < ActiveSupport::TestCase
end
end
-require 'fixtures/vertex'
-require 'fixtures/edge'
+require 'models/vertex'
+require 'models/edge'
class CascadedEagerLoadingTest < ActiveSupport::TestCase
fixtures :edges, :vertices
diff --git a/activerecord/test/associations/eager_singularization_test.rb b/activerecord/test/cases/associations/eager_singularization_test.rb
index 2990684afc..c1d89a2484 100644
--- a/activerecord/test/associations/eager_singularization_test.rb
+++ b/activerecord/test/cases/associations/eager_singularization_test.rb
@@ -85,7 +85,7 @@ class EagerSingularizationTest < ActiveSupport::TestCase
@have_tables = false
end
end
-
+
def teardown
ActiveRecord::Base.connection.drop_table :viri
ActiveRecord::Base.connection.drop_table :octopi
@@ -99,7 +99,7 @@ class EagerSingularizationTest < ActiveSupport::TestCase
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 @@ class EagerSingularizationTest < ActiveSupport::TestCase
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
diff --git a/activerecord/test/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index bdadada3f4..0e351816d3 100644
--- a/activerecord/test/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -1,11 +1,11 @@
require 'abstract_unit'
-require 'fixtures/post'
-require 'fixtures/comment'
-require 'fixtures/author'
-require 'fixtures/category'
-require 'fixtures/company'
-require 'fixtures/person'
-require 'fixtures/reader'
+require 'models/post'
+require 'models/comment'
+require 'models/author'
+require 'models/category'
+require 'models/company'
+require 'models/person'
+require 'models/reader'
class EagerAssociationTest < ActiveSupport::TestCase
fixtures :posts, :comments, :authors, :categories, :categories_posts,
@@ -72,7 +72,7 @@ class EagerAssociationTest < ActiveSupport::TestCase
assert titles.include?(posts(:welcome).title)
assert titles.include?(posts(:sti_post_and_comments).title)
end
-
+
def test_eager_association_loading_with_belongs_to_and_limit
comments = Comment.find(:all, :include => :post, :limit => 5, :order => 'comments.id')
assert_equal 5, comments.length
@@ -96,7 +96,7 @@ class EagerAssociationTest < ActiveSupport::TestCase
assert_equal 3, comments.length
assert_equal [6,7,8], comments.collect { |c| c.id }
end
-
+
def test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_conditions_array
comments = Comment.find(:all, :include => :post, :conditions => ['post_id = ?',4], :limit => 3, :offset => 1, :order => 'comments.id')
assert_equal 3, comments.length
@@ -108,13 +108,13 @@ class EagerAssociationTest < ActiveSupport::TestCase
assert_equal 1, posts.length
assert_equal [1], posts.collect { |p| p.id }
end
-
+
def test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_multiple_associations
posts = Post.find(:all, :include => [:author, :very_special_comment], :limit => 1, :offset => 1, :order => 'posts.id')
assert_equal 1, posts.length
assert_equal [2], posts.collect { |p| p.id }
end
-
+
def test_eager_association_loading_with_belongs_to_inferred_foreign_key_from_association_name
author_favorite = AuthorFavorite.find(:first, :include => :favorite_author)
assert_equal authors(:mary), assert_no_queries { author_favorite.favorite_author }
@@ -124,7 +124,7 @@ class EagerAssociationTest < ActiveSupport::TestCase
posts = Post.find(:all, :include => :comments, :joins => "INNER JOIN authors ON posts.author_id = authors.id AND authors.name = 'Mary'", :limit => 1, :order => 'author_id')
assert_equal 1, posts.length
end
-
+
def test_eager_with_has_many_through
posts_with_comments = people(:michael).posts.find(:all, :include => :comments)
posts_with_author = people(:michael).posts.find(:all, :include => :author )
@@ -138,7 +138,7 @@ class EagerAssociationTest < ActiveSupport::TestCase
author = Author.find(:first, :include => :special_post_comments, :order => 'authors.id')
assert_equal [comments(:does_it_hurt)], assert_no_queries { author.special_post_comments }
end
-
+
def test_eager_with_has_many_through_an_sti_join_model_with_conditions_on_both
author = Author.find(:first, :include => :special_nonexistant_post_comments, :order => 'authors.id')
assert_equal [], author.special_nonexistant_post_comments
@@ -173,13 +173,13 @@ class EagerAssociationTest < ActiveSupport::TestCase
posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => [ "posts.body = ?", 'hello' ], :order => "posts.id")
end
assert_equal 2, posts.size
- assert_equal [4,5], posts.collect { |p| p.id }
+ assert_equal [4,5], posts.collect { |p| p.id }
end
def test_eager_with_has_many_and_limit_and_conditions_array_on_the_eagers
posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => [ "authors.name = ?", 'David' ])
assert_equal 2, posts.size
-
+
count = Post.count(:include => [ :author, :comments ], :limit => 2, :conditions => [ "authors.name = ?", 'David' ])
assert_equal count, posts.size
end
@@ -198,7 +198,7 @@ class EagerAssociationTest < ActiveSupport::TestCase
posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => "posts.title = 'magic forest'")
assert_equal 0, posts.size
end
-
+
def test_eager_count_performed_on_a_has_many_association_with_multi_table_conditional
author = authors(:david)
author_posts_without_comments = author.posts.select { |post| post.comments.blank? }
@@ -216,15 +216,15 @@ class EagerAssociationTest < ActiveSupport::TestCase
end
def test_eager_with_has_many_and_limit_and_conditions_on_the_eagers
- posts = authors(:david).posts.find(:all,
- :include => :comments,
+ posts = authors(:david).posts.find(:all,
+ :include => :comments,
:conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment'",
:limit => 2
)
assert_equal 2, posts.size
-
+
count = Post.count(
- :include => [ :comments, :author ],
+ :include => [ :comments, :author ],
:conditions => "authors.name = 'David' AND (comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment')",
:limit => 2
)
@@ -234,15 +234,15 @@ class EagerAssociationTest < ActiveSupport::TestCase
def test_eager_with_has_many_and_limit_and_scoped_conditions_on_the_eagers
posts = nil
Post.with_scope(:find => {
- :include => :comments,
+ :include => :comments,
:conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment'"
}) do
posts = authors(:david).posts.find(:all, :limit => 2)
assert_equal 2, posts.size
end
-
+
Post.with_scope(:find => {
- :include => [ :comments, :author ],
+ :include => [ :comments, :author ],
:conditions => "authors.name = 'David' AND (comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment')"
}) do
count = Post.count(:limit => 2)
@@ -252,15 +252,15 @@ class EagerAssociationTest < ActiveSupport::TestCase
def test_eager_with_has_many_and_limit_and_scoped_and_explicit_conditions_on_the_eagers
Post.with_scope(:find => { :conditions => "1=1" }) do
- posts = authors(:david).posts.find(:all,
- :include => :comments,
+ posts = authors(:david).posts.find(:all,
+ :include => :comments,
:conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment'",
:limit => 2
)
assert_equal 2, posts.size
-
+
count = Post.count(
- :include => [ :comments, :author ],
+ :include => [ :comments, :author ],
:conditions => "authors.name = 'David' AND (comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment')",
:limit => 2
)
@@ -316,7 +316,7 @@ class EagerAssociationTest < ActiveSupport::TestCase
assert_not_nil f.account
assert_equal companies(:first_firm, :reload).account, f.account
end
-
+
def test_eager_with_multi_table_conditional_properly_counts_the_records_when_using_size
author = authors(:david)
posts_with_no_comments = author.posts.select { |post| post.comments.blank? }
@@ -338,16 +338,16 @@ class EagerAssociationTest < ActiveSupport::TestCase
post = Post.find(6, :include=>[ :monkeys, :elephants ])
}
end
-
+
def find_all_ordered(className, include=nil)
className.find(:all, :order=>"#{className.table_name}.#{className.primary_key}", :include=>include)
end
-
+
def test_limited_eager_with_order
assert_equal posts(:thinking, :sti_comments), Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title)', :limit => 2, :offset => 1)
assert_equal posts(:sti_post_and_comments, :sti_comments), Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title) DESC', :limit => 2, :offset => 1)
end
-
+
def test_limited_eager_with_multiple_order_columns
assert_equal posts(:thinking, :sti_comments), Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title), posts.id', :limit => 2, :offset => 1)
assert_equal posts(:sti_post_and_comments, :sti_comments), Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title) DESC, posts.id', :limit => 2, :offset => 1)
@@ -366,8 +366,8 @@ class EagerAssociationTest < ActiveSupport::TestCase
[Author, Category].each do |className|
d1 = find_all_ordered(className)
# test including all post types at once
- d2 = find_all_ordered(className, post_types)
- d1.each_index do |i|
+ d2 = find_all_ordered(className, post_types)
+ d1.each_index do |i|
assert_equal(d1[i], d2[i])
assert_equal_after_sort(d1[i].posts, d2[i].posts)
post_types[1..-1].each do |post_type|
@@ -380,21 +380,21 @@ class EagerAssociationTest < ActiveSupport::TestCase
end
end
end
-
+
def test_eager_with_multiple_associations_with_same_table_has_one
d1 = find_all_ordered(Firm)
d2 = find_all_ordered(Firm, :account)
- d1.each_index do |i|
+ d1.each_index do |i|
assert_equal(d1[i], d2[i])
assert_equal(d1[i].account, d2[i].account)
end
end
-
+
def test_eager_with_multiple_associations_with_same_table_belongs_to
firm_types = [:firm, :firm_with_basic_id, :firm_with_other_name, :firm_with_condition]
d1 = find_all_ordered(Client)
d2 = find_all_ordered(Client, firm_types)
- d1.each_index do |i|
+ d1.each_index do |i|
assert_equal(d1[i], d2[i])
firm_types.each { |type| assert_equal(d1[i].send(type), d2[i].send(type)) }
end
@@ -434,7 +434,7 @@ class EagerAssociationTest < ActiveSupport::TestCase
assert_equal 2, one.comments.size
assert_equal 2, one.categories.size
end
-
+
def test_count_with_include
if current_adapter?(:SQLServerAdapter, :SybaseAdapter)
assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "len(comments.body) > 15")
diff --git a/activerecord/test/associations/extension_test.rb b/activerecord/test/cases/associations/extension_test.rb
index 3749f7ac41..a34f1bf2bf 100644
--- a/activerecord/test/associations/extension_test.rb
+++ b/activerecord/test/cases/associations/extension_test.rb
@@ -1,8 +1,8 @@
require 'abstract_unit'
-require 'fixtures/post'
-require 'fixtures/comment'
-require 'fixtures/project'
-require 'fixtures/developer'
+require 'models/post'
+require 'models/comment'
+require 'models/project'
+require 'models/developer'
class AssociationsExtensionsTest < ActiveSupport::TestCase
fixtures :projects, :developers, :developers_projects, :comments, :posts
@@ -10,7 +10,7 @@ class AssociationsExtensionsTest < ActiveSupport::TestCase
def test_extension_on_has_many
assert_equal comments(:more_greetings), posts(:welcome).comments.find_most_recent
end
-
+
def test_extension_on_habtm
assert_equal projects(:action_controller), developers(:david).projects.find_most_recent
end
@@ -44,4 +44,4 @@ class AssociationsExtensionsTest < ActiveSupport::TestCase
david = Marshal.load(Marshal.dump(david))
assert_equal projects(:action_controller), david.projects_extended_by_name.find_most_recent
end
-end \ No newline at end of file
+end
diff --git a/activerecord/test/associations/inner_join_association_test.rb b/activerecord/test/cases/associations/inner_join_association_test.rb
index 56735afae5..da594e459e 100644
--- a/activerecord/test/associations/inner_join_association_test.rb
+++ b/activerecord/test/cases/associations/inner_join_association_test.rb
@@ -12,18 +12,18 @@ class InnerJoinAssociationTest < ActiveSupport::TestCase
sql = Author.send(:construct_finder_sql, :joins => :posts)
assert_match /INNER JOIN .?posts.? ON .?posts.?.author_id = authors.id/, sql
end
-
+
def test_construct_finder_sql_cascades_inner_joins
sql = Author.send(:construct_finder_sql, :joins => {:posts => :comments})
assert_match /INNER JOIN .?posts.? ON .?posts.?.author_id = authors.id/, sql
assert_match /INNER JOIN .?comments.? ON .?comments.?.post_id = posts.id/, sql
end
-
+
def test_construct_finder_sql_inner_joins_through_associations
sql = Author.send(:construct_finder_sql, :joins => :categorized_posts)
assert_match /INNER JOIN .?categorizations.?.*INNER JOIN .?posts.?/, sql
end
-
+
def test_construct_finder_sql_applies_association_conditions
sql = Author.send(:construct_finder_sql, :joins => :categories_like_general, :conditions => "TERMINATING_MARKER")
assert_match /INNER JOIN .?categories.? ON.*AND.*.?General.?.*TERMINATING_MARKER/, sql
@@ -51,7 +51,7 @@ class InnerJoinAssociationTest < ActiveSupport::TestCase
assert !authors.empty?, "expected authors to be non-empty"
assert authors.all? {|a| a.readonly? }, "expected all authors to be readonly"
end
-
+
def test_find_with_implicit_inner_joins_honors_readonly_with_select
authors = Author.find(:all, :select => 'authors.*', :joins => :posts)
assert !authors.empty?, "expected authors to be non-empty"
@@ -69,7 +69,7 @@ class InnerJoinAssociationTest < ActiveSupport::TestCase
assert !authors.empty?, "expected authors to be non-empty"
assert authors.all? {|a| !a.send(:instance_variable_names).include?("@posts")}, "expected no authors to have the @posts association loaded"
end
-
+
def test_count_honors_implicit_inner_joins
real_count = Author.find(:all).sum{|a| a.posts.count }
assert_equal real_count, Author.count(:joins => :posts), "plain inner join count should match the number of referenced posts records"
diff --git a/activerecord/test/associations/join_model_test.rb b/activerecord/test/cases/associations/join_model_test.rb
index d55faf70c6..c6a1e356a5 100644
--- a/activerecord/test/associations/join_model_test.rb
+++ b/activerecord/test/cases/associations/join_model_test.rb
@@ -32,7 +32,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
assert_equal 2, authors(:mary).categorized_posts.size
assert_equal 1, authors(:mary).unique_categorized_posts.size
end
-
+
def test_has_many_uniq_through_count
author = authors(:mary)
assert !authors(:mary).unique_categorized_posts.loaded?
@@ -41,7 +41,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
assert_queries(1) { assert_equal 0, author.unique_categorized_posts.count(:title, :conditions => "title is NULL") }
assert !authors(:mary).unique_categorized_posts.loaded?
end
-
+
def test_polymorphic_has_many
assert posts(:welcome).taggings.include?(taggings(:welcome_general))
end
@@ -107,7 +107,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
def test_polymorphic_has_many_create_model_with_inheritance_and_custom_base_class
post = SubStiPost.create :title => 'SubStiPost', :body => 'SubStiPost body'
assert_instance_of SubStiPost, post
-
+
tagging = tags(:misc).taggings.create(:taggable => post)
assert_equal "SubStiPost", tagging.taggable_type
end
@@ -123,7 +123,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
def test_polymorphic_has_many_create_model_with_inheritance
post = posts(:thinking)
assert_instance_of SpecialPost, post
-
+
tagging = tags(:misc).taggings.create(:taggable => post)
assert_equal "Post", tagging.taggable_type
end
@@ -151,7 +151,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
assert_equal "Post", tagging.taggable_type
assert_equal old_count+1, posts(:welcome).taggings.count
end
-
+
def test_create_bang_polymorphic_with_has_many_scope
old_count = posts(:welcome).taggings.count
tagging = posts(:welcome).taggings.create!(:tag => tags(:misc))
@@ -241,7 +241,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
assert_equal tagging, post.tagging
end
end
-
+
def test_include_polymorphic_has_one_defined_in_abstract_parent
item = Item.find_by_id(items(:dvd).id, :include => :tagging)
tagging = taggings(:godfather)
@@ -249,7 +249,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
assert_equal tagging, item.tagging
end
end
-
+
def test_include_polymorphic_has_many_through
posts = Post.find(:all, :order => 'posts.id')
posts_with_tags = Post.find(:all, :include => :tags, :order => 'posts.id')
@@ -271,7 +271,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
def test_has_many_find_all
assert_equal [categories(:general)], authors(:david).categories.find(:all)
end
-
+
def test_has_many_find_first
assert_equal categories(:general), authors(:david).categories.find(:first)
end
@@ -279,7 +279,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
def test_has_many_with_hash_conditions
assert_equal categories(:general), authors(:david).categories_like_general.find(:first)
end
-
+
def test_has_many_find_conditions
assert_equal categories(:general), authors(:david).categories.find(:first, :conditions => "categories.name = 'General'")
assert_equal nil, authors(:david).categories.find(:first, :conditions => "categories.name = 'Technology'")
@@ -320,7 +320,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
assert_equal posts(:welcome, :thinking), tags(:general).taggings.find(:all, :include => :taggable)
end
end
-
+
def test_has_many_polymorphic_with_source_type
assert_equal posts(:welcome, :thinking), tags(:general).tagged_posts
end
@@ -385,7 +385,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
assert_equal [1,2,3,5,6,7,8,9,10], author.comments.collect(&:id)
end
end
-
+
def test_eager_load_has_many_through_has_many_with_conditions
post = Post.find(:first, :include => :invalid_tags)
assert_no_queries do
@@ -410,7 +410,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
authors(:david).author_favorites.create :favorite_author => new_author
assert_equal new_author, authors(:david).reload.favorite_authors.first
end
-
+
def test_has_many_through_uses_conditions_specified_on_the_has_many_association
author = Author.find(:first)
assert !author.comments.blank?
@@ -506,7 +506,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
post_thinking.tags << tag
assert_equal(count + 1, post_thinking.tags(true).size)
- assert_nothing_raised { post_thinking.tags.delete(tag) }
+ assert_nothing_raised { post_thinking.tags.delete(tag) }
assert_equal(count, post_thinking.tags.size)
assert_equal(count, post_thinking.tags(true).size)
assert_equal(tags_before.sort, post_thinking.tags.sort)
@@ -522,7 +522,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
post_thinking.tags << doomed << doomed2
assert_equal(count + 2, post_thinking.tags(true).size)
- assert_nothing_raised { post_thinking.tags.delete(doomed, doomed2, quaked) }
+ assert_nothing_raised { post_thinking.tags.delete(doomed, doomed2, quaked) }
assert_equal(count, post_thinking.tags.size)
assert_equal(count, post_thinking.tags(true).size)
assert_equal(tags_before.sort, post_thinking.tags.sort)
@@ -539,7 +539,7 @@ class AssociationsJoinModelTest < ActiveSupport::TestCase
def test_has_many_through_has_many_with_sti
assert_equal [comments(:does_it_hurt)], authors(:david).special_post_comments
end
-
+
def test_uniq_has_many_through_should_retain_order
comment_ids = authors(:david).comments.map(&:id)
assert_equal comment_ids.sort, authors(:david).ordered_uniq_comments.map(&:id)
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/cases/associations_test.rb
index 1749751852..a657da265d 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/cases/associations_test.rb
@@ -26,7 +26,7 @@ class AssociationsTest < ActiveSupport::TestCase
Class.new(ActiveRecord::Base).has_many(:wheels, :name => 'wheels')
end
end
-
+
def test_should_construct_new_finder_sql_after_create
person = Person.new
assert_equal [], person.readers.find(:all)
@@ -72,23 +72,23 @@ class AssociationsTest < ActiveSupport::TestCase
end
end
end
-
+
class AssociationProxyTest < ActiveSupport::TestCase
fixtures :authors, :posts, :categorizations, :categories, :developers, :projects, :developers_projects
-
+
def test_proxy_accessors
welcome = posts(:welcome)
assert_equal welcome, welcome.author.proxy_owner
assert_equal welcome.class.reflect_on_association(:author), welcome.author.proxy_reflection
welcome.author.class # force load target
assert_equal welcome.author, welcome.author.proxy_target
-
+
david = authors(:david)
assert_equal david, david.posts.proxy_owner
assert_equal david.class.reflect_on_association(:posts), david.posts.proxy_reflection
david.posts.first # force load target
assert_equal david.posts, david.posts.proxy_target
-
+
assert_equal david, david.posts_with_extension.testing_proxy_owner
assert_equal david.class.reflect_on_association(:posts_with_extension), david.posts_with_extension.testing_proxy_reflection
david.posts_with_extension.first # force load target
@@ -110,7 +110,7 @@ class AssociationProxyTest < ActiveSupport::TestCase
assert !david.categories.loaded?
assert david.categories.include?(categories(:technology))
end
-
+
def test_push_followed_by_save_does_not_load_target
david = authors(:david)
@@ -685,21 +685,21 @@ class HasManyAssociationsTest < ActiveSupport::TestCase
assert_equal 3, first_firm.plain_clients.length
assert_equal 3, first_firm.plain_clients.size
end
-
+
def test_create_with_bang_on_has_many_when_parent_is_new_raises
- assert_raises(ActiveRecord::RecordNotSaved) do
+ assert_raises(ActiveRecord::RecordNotSaved) do
firm = Firm.new
firm.plain_clients.create! :name=>"Whoever"
end
end
def test_regular_create_on_has_many_when_parent_is_new_raises
- assert_raises(ActiveRecord::RecordNotSaved) do
+ assert_raises(ActiveRecord::RecordNotSaved) do
firm = Firm.new
firm.plain_clients.create :name=>"Whoever"
end
end
-
+
def test_create_with_bang_on_has_many_raises_when_record_not_saved
assert_raises(ActiveRecord::RecordInvalid) do
firm = Firm.find(:first)
@@ -708,8 +708,8 @@ class HasManyAssociationsTest < ActiveSupport::TestCase
end
def test_create_with_bang_on_habtm_when_parent_is_new_raises
- assert_raises(ActiveRecord::RecordNotSaved) do
- Developer.new("name" => "Aredridel").projects.create!
+ assert_raises(ActiveRecord::RecordNotSaved) do
+ Developer.new("name" => "Aredridel").projects.create!
end
end
@@ -790,13 +790,13 @@ class HasManyAssociationsTest < ActiveSupport::TestCase
assert companies(:first_firm).save
assert_equal 3, companies(:first_firm).clients_of_firm(true).size
end
-
+
def test_build_followed_by_save_does_not_load_target
new_client = companies(:first_firm).clients_of_firm.build("name" => "Another Client")
assert companies(:first_firm).save
assert !companies(:first_firm).clients_of_firm.loaded?
end
-
+
def test_build_without_loading_association
first_topic = topics(:first)
Reply.column_names
@@ -1335,7 +1335,7 @@ class BelongsToAssociationsTest < ActiveSupport::TestCase
topic.update_attributes(:title => "37signals")
assert_equal 1, Topic.find(topic.id)[:replies_count]
end
-
+
def test_belongs_to_counter_after_save
topic = Topic.create("title" => "monday night")
topic.replies.create("title" => "re: monday night", "content" => "football")
diff --git a/activerecord/test/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index 8ff52802ac..4a09a4d63e 100755
--- a/activerecord/test/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -48,24 +48,24 @@ class AttributeMethodsTest < ActiveSupport::TestCase
assert_equal ['title', 1, 2, 3], topic.send(meth, 1, 2, 3)
end
end
-
+
def test_should_unserialize_attributes_for_frozen_records
myobj = {:value1 => :value2}
topic = Topic.create("content" => myobj)
topic.freeze
assert_equal myobj, topic.content
end
-
+
def test_kernel_methods_not_implemented_in_activerecord
%w(test name display y).each do |method|
assert_equal false, ActiveRecord::Base.instance_method_already_implemented?(method), "##{method} is defined"
end
end
-
+
def test_primary_key_implemented
assert_equal true, Class.new(ActiveRecord::Base).instance_method_already_implemented?('id')
end
-
+
def test_defined_kernel_methods_implemented_in_model
%w(test name display y).each do |method|
klass = Class.new ActiveRecord::Base
@@ -73,7 +73,7 @@ class AttributeMethodsTest < ActiveSupport::TestCase
assert_equal true, klass.instance_method_already_implemented?(method), "##{method} is not defined"
end
end
-
+
def test_defined_kernel_methods_implemented_in_model_abstract_subclass
%w(test name display y).each do |method|
abstract = Class.new ActiveRecord::Base
@@ -83,7 +83,7 @@ class AttributeMethodsTest < ActiveSupport::TestCase
assert_equal true, klass.instance_method_already_implemented?(method), "##{method} is not defined"
end
end
-
+
def test_raises_dangerous_attribute_error_when_defining_activerecord_method_in_model
%w(save create_or_update).each do |method|
klass = Class.new ActiveRecord::Base
diff --git a/activerecord/test/base_test.rb b/activerecord/test/cases/base_test.rb
index a62a4d16c2..00e563aaee 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -65,8 +65,8 @@ class Task < ActiveRecord::Base
attr_protected :starting
end
-class TopicWithProtectedContentAndAccessibleAuthorName < ActiveRecord::Base
- self.table_name = 'topics'
+class TopicWithProtectedContentAndAccessibleAuthorName < ActiveRecord::Base
+ self.table_name = 'topics'
attr_accessible :author_name
attr_protected :content
end
@@ -78,7 +78,7 @@ class BasicsTest < ActiveSupport::TestCase
assert !NonExistentTable.table_exists?
assert Topic.table_exists?
end
-
+
def test_set_attributes
topic = Topic.find(1)
topic.attributes = { "title" => "Budget", "author_name" => "Jason" }
@@ -92,7 +92,7 @@ class BasicsTest < ActiveSupport::TestCase
test = AutoId.create('value' => '')
assert_nil AutoId.find(test.id).value
end
-
+
def test_set_attributes_with_block
topic = Topic.new do |t|
t.title = "Budget"
@@ -102,7 +102,7 @@ class BasicsTest < ActiveSupport::TestCase
assert_equal("Budget", topic.title)
assert_equal("Jason", topic.author_name)
end
-
+
def test_respond_to?
topic = Topic.find(1)
assert topic.respond_to?("title")
@@ -116,7 +116,7 @@ class BasicsTest < ActiveSupport::TestCase
assert !topic.respond_to?("nothingness")
assert !topic.respond_to?(:nothingness)
end
-
+
def test_array_content
topic = Topic.new
topic.content = %w( one two three )
@@ -131,13 +131,13 @@ class BasicsTest < ActiveSupport::TestCase
topic.save
assert_equal 2, Topic.find(topic.id).content["two"]
-
+
topic.content["three"] = 3
topic.save
assert_equal 3, Topic.find(topic.id).content["three"]
end
-
+
def test_update_array_content
topic = Topic.new
topic.content = %w( one two three )
@@ -146,12 +146,12 @@ class BasicsTest < ActiveSupport::TestCase
assert_equal(%w( one two three four ), topic.content)
topic.save
-
+
topic = Topic.find(topic.id)
topic.content << "five"
assert_equal(%w( one two three four five ), topic.content)
end
-
+
def test_case_sensitive_attributes_hash
# DB2 is not case-sensitive
return true if current_adapter?(:DB2Adapter)
@@ -166,11 +166,11 @@ class BasicsTest < ActiveSupport::TestCase
topic_reloaded = Topic.find(topic.id)
assert_equal("New Topic", topic_reloaded.title)
end
-
+
def test_save!
topic = Topic.new(:title => "New Topic")
assert topic.save!
-
+
reply = Reply.new
assert_raise(ActiveRecord::RecordInvalid) { reply.save! }
end
@@ -211,7 +211,7 @@ class BasicsTest < ActiveSupport::TestCase
topic.attributes= new_topic_values
assert_equal new_topic_values[:title], topic.title
end
-
+
def test_create_many
topics = Topic.create([ { "title" => "first" }, { "title" => "second" }])
assert_equal 2, topics.size
@@ -241,9 +241,9 @@ class BasicsTest < ActiveSupport::TestCase
topicReloaded.title = "Updated topic"
topicReloaded.save
-
+
topicReloadedAgain = Topic.find(topic.id)
-
+
assert_equal("Updated topic", topicReloadedAgain.title)
end
@@ -251,7 +251,7 @@ class BasicsTest < ActiveSupport::TestCase
topic = Topic.new
topic.title = "Still another topic"
topic.save
-
+
topicReloaded = Topic.find(topic.id)
topicReloaded.title = "A New Topic"
topicReloaded.send :write_attribute, 'does_not_exist', 'test'
@@ -262,7 +262,7 @@ class BasicsTest < ActiveSupport::TestCase
minimalistic = minimalistics(:first)
assert_nothing_raised { minimalistic.save }
end
-
+
def test_write_attribute
topic = Topic.new
topic.send(:write_attribute, :title, "Still another topic")
@@ -321,29 +321,29 @@ class BasicsTest < ActiveSupport::TestCase
assert topic.approved?, "approved should be true"
# puts ""
end
-
+
def test_query_attribute_string
[nil, "", " "].each do |value|
assert_equal false, Topic.new(:author_name => value).author_name?
end
-
+
assert_equal true, Topic.new(:author_name => "Name").author_name?
end
-
+
def test_query_attribute_number
[nil, 0, "0"].each do |value|
assert_equal false, Developer.new(:salary => value).salary?
end
-
+
assert_equal true, Developer.new(:salary => 1).salary?
assert_equal true, Developer.new(:salary => "1").salary?
end
-
+
def test_query_attribute_boolean
[nil, "", false, "false", "f", 0].each do |value|
assert_equal false, Topic.new(:approved => value).approved?
end
-
+
[true, "true", "1", 1].each do |value|
assert_equal true, Topic.new(:approved => value).approved?
end
@@ -391,12 +391,12 @@ class BasicsTest < ActiveSupport::TestCase
# Sybase ctlib does not (yet?) support the date type; use datetime instead.
# Oracle treats all dates/times as Time.
assert_kind_of(
- Time, Topic.find(1).last_read,
+ Time, Topic.find(1).last_read,
"The last_read attribute should be of the Time class"
)
else
assert_kind_of(
- Date, Topic.find(1).last_read,
+ Date, Topic.find(1).last_read,
"The last_read attribute should be of the Date class"
)
end
@@ -420,7 +420,7 @@ class BasicsTest < ActiveSupport::TestCase
assert_equal 9900, Topic.find(2).written_on.usec
end
end
-
+
def test_custom_mutator
topic = Topic.find(1)
# This mutator is protected in the class definition
@@ -438,34 +438,34 @@ class BasicsTest < ActiveSupport::TestCase
def test_record_not_found_exception
assert_raises(ActiveRecord::RecordNotFound) { topicReloaded = Topic.find(99999) }
end
-
+
def test_initialize_with_attributes
- topic = Topic.new({
+ topic = Topic.new({
"title" => "initialized from attributes", "written_on" => "2003-12-12 23:23"
})
-
+
assert_equal("initialized from attributes", topic.title)
end
-
+
def test_initialize_with_invalid_attribute
begin
- topic = Topic.new({ "title" => "test",
+ topic = Topic.new({ "title" => "test",
"last_read(1i)" => "2005", "last_read(2i)" => "2", "last_read(3i)" => "31"})
rescue ActiveRecord::MultiparameterAssignmentErrors => ex
assert_equal(1, ex.errors.size)
assert_equal("last_read", ex.errors[0].attribute)
end
end
-
+
def test_load
- topics = Topic.find(:all, :order => 'id')
+ topics = Topic.find(:all, :order => 'id')
assert_equal(2, topics.size)
assert_equal(topics(:first).title, topics.first.title)
end
-
+
def test_load_with_condition
topics = Topic.find(:all, :conditions => "author_name = 'Mary'")
-
+
assert_equal(1, topics.size)
assert_equal(topics(:second).title, topics.first.title)
end
@@ -529,7 +529,7 @@ class BasicsTest < ActiveSupport::TestCase
ActiveRecord::Base.pluralize_table_names = true
classes.each(&:reset_table_name)
end
-
+
def test_destroy_all
assert_equal 2, Topic.count
@@ -552,7 +552,7 @@ class BasicsTest < ActiveSupport::TestCase
assert ! Topic.find(1).approved?
assert Topic.find(2).approved?
end
-
+
def test_increment_counter
Topic.increment_counter("replies_count", 1)
assert_equal 2, Topic.find(1).replies_count
@@ -560,7 +560,7 @@ class BasicsTest < ActiveSupport::TestCase
Topic.increment_counter("replies_count", 1)
assert_equal 3, Topic.find(1).replies_count
end
-
+
def test_decrement_counter
Topic.decrement_counter("replies_count", 2)
assert_equal -1, Topic.find(2).replies_count
@@ -627,7 +627,7 @@ class BasicsTest < ActiveSupport::TestCase
assert_equal "Have a nice day", Topic.find(1).content
assert_equal "bulk updated!", Topic.find(2).content
end
-
+
def test_attribute_present
t = Topic.new
t.title = "hello there!"
@@ -636,13 +636,13 @@ class BasicsTest < ActiveSupport::TestCase
assert t.attribute_present?("written_on")
assert !t.attribute_present?("content")
end
-
+
def test_attribute_keys_on_new_instance
t = Topic.new
assert_equal nil, t.title, "The topics table has a title column, so it should be nil"
assert_raise(NoMethodError) { t.title2 }
end
-
+
def test_class_name
assert_equal "Firm", ActiveRecord::Base.class_name("firms")
assert_equal "Category", ActiveRecord::Base.class_name("categories")
@@ -661,26 +661,26 @@ class BasicsTest < ActiveSupport::TestCase
ActiveRecord::Base.table_name_suffix = ""
assert_equal "Firm", ActiveRecord::Base.class_name( "firms" )
end
-
+
def test_null_fields
assert_nil Topic.find(1).parent_id
assert_nil Topic.create("title" => "Hey you").parent_id
end
-
+
def test_default_values
topic = Topic.new
assert topic.approved?
assert_nil topic.written_on
assert_nil topic.bonus_time
assert_nil topic.last_read
-
+
topic.save
topic = Topic.find(topic.id)
assert topic.approved?
assert_nil topic.last_read
- # Oracle has some funky default handling, so it requires a bit of
+ # Oracle has some funky default handling, so it requires a bit of
# extra testing. See ticket #2788.
if current_adapter?(:OracleAdapter)
test = TestOracleDefault.new
@@ -736,21 +736,21 @@ class BasicsTest < ActiveSupport::TestCase
def test_equality
assert_equal Topic.find(1), Topic.find(2).topic
end
-
+
def test_equality_of_new_records
assert_not_equal Topic.new, Topic.new
end
-
+
def test_hashing
assert_equal [ Topic.find(1) ], [ Topic.find(2).topic ] & [ Topic.find(1) ]
end
-
+
def test_destroy_new_record
client = Client.new
client.destroy
assert client.frozen?
end
-
+
def test_destroy_record_with_associations
client = Client.find(3)
client.destroy
@@ -758,7 +758,7 @@ class BasicsTest < ActiveSupport::TestCase
assert_kind_of Firm, client.firm
assert_raises(ActiveSupport::FrozenObjectError) { client.name = "something else" }
end
-
+
def test_update_attribute
assert !Topic.find(1).approved?
Topic.find(1).update_attribute("approved", true)
@@ -767,12 +767,12 @@ class BasicsTest < ActiveSupport::TestCase
Topic.find(1).update_attribute(:approved, false)
assert !Topic.find(1).approved?
end
-
+
def test_update_attributes
topic = Topic.find(1)
assert !topic.approved?
assert_equal "The First Topic", topic.title
-
+
topic.update_attributes("approved" => true, "title" => "The First Topic Updated")
topic.reload
assert topic.approved?
@@ -783,37 +783,37 @@ class BasicsTest < ActiveSupport::TestCase
assert !topic.approved?
assert_equal "The First Topic", topic.title
end
-
+
def test_update_attributes!
reply = Reply.find(2)
assert_equal "The Second Topic's of the day", reply.title
assert_equal "Have a nice day", reply.content
-
+
reply.update_attributes!("title" => "The Second Topic's of the day updated", "content" => "Have a nice evening")
reply.reload
assert_equal "The Second Topic's of the day updated", reply.title
assert_equal "Have a nice evening", reply.content
-
+
reply.update_attributes!(:title => "The Second Topic's of the day", :content => "Have a nice day")
reply.reload
assert_equal "The Second Topic's of the day", reply.title
assert_equal "Have a nice day", reply.content
-
+
assert_raise(ActiveRecord::RecordInvalid) { reply.update_attributes!(:title => nil, :content => "Have a nice evening") }
end
-
+
def test_mass_assignment_should_raise_exception_if_accessible_and_protected_attribute_writers_are_both_used
topic = TopicWithProtectedContentAndAccessibleAuthorName.new
assert_raises(RuntimeError) { topic.attributes = { "author_name" => "me" } }
assert_raises(RuntimeError) { topic.attributes = { "content" => "stuff" } }
end
-
+
def test_mass_assignment_protection
firm = Firm.new
firm.attributes = { "name" => "Next Angle", "rating" => 5 }
assert_equal 1, firm.rating
end
-
+
def test_mass_assignment_protection_against_class_attribute_writers
[:logger, :configurations, :primary_key_prefix_type, :table_name_prefix, :table_name_suffix, :pluralize_table_names, :colorize_logging,
:default_timezone, :allow_concurrency, :schema_format, :verification_timeout, :lock_optimistically, :record_timestamps].each do |method|
@@ -839,26 +839,26 @@ class BasicsTest < ActiveSupport::TestCase
keyboard = Keyboard.new(:id => 9, :name => 'nice try')
assert_nil keyboard.id
end
-
+
def test_mass_assignment_protection_on_defaults
firm = Firm.new
firm.attributes = { "id" => 5, "type" => "Client" }
assert_nil firm.id
assert_equal "Firm", firm[:type]
end
-
+
def test_mass_assignment_accessible
reply = Reply.new("title" => "hello", "content" => "world", "approved" => true)
reply.save
assert reply.approved?
-
+
reply.approved = false
reply.save
assert !reply.approved?
end
-
+
def test_mass_assignment_protection_inheritance
assert_nil LoosePerson.accessible_attributes
assert_equal Set.new([ 'credit_rating', 'administrator' ]), LoosePerson.protected_attributes
@@ -875,14 +875,14 @@ class BasicsTest < ActiveSupport::TestCase
assert_nil TightDescendant.protected_attributes
assert_equal Set.new([ 'name', 'address', 'phone_number' ]), TightDescendant.accessible_attributes
end
-
+
def test_readonly_attributes
assert_equal Set.new([ 'title' ]), ReadonlyTitlePost.readonly_attributes
-
+
post = ReadonlyTitlePost.create(:title => "cannot change this", :body => "changeable")
post.reload
assert_equal "cannot change this", post.title
-
+
post.update_attributes(:title => "try to change", :body => "changed")
post.reload
assert_equal "cannot change this", post.title
@@ -893,7 +893,7 @@ class BasicsTest < ActiveSupport::TestCase
attributes = { "last_read(1i)" => "2004", "last_read(2i)" => "6", "last_read(3i)" => "24" }
topic = Topic.find(1)
topic.attributes = attributes
- # note that extra #to_date call allows test to pass for Oracle, which
+ # note that extra #to_date call allows test to pass for Oracle, which
# treats dates/times the same
assert_date_from_db Date.new(2004, 6, 24), topic.last_read.to_date
end
@@ -902,7 +902,7 @@ class BasicsTest < ActiveSupport::TestCase
attributes = { "last_read(1i)" => "2004", "last_read(2i)" => "6", "last_read(3i)" => "" }
topic = Topic.find(1)
topic.attributes = attributes
- # note that extra #to_date call allows test to pass for Oracle, which
+ # note that extra #to_date call allows test to pass for Oracle, which
# treats dates/times the same
assert_date_from_db Date.new(2004, 6, 1), topic.last_read.to_date
end
@@ -915,8 +915,8 @@ class BasicsTest < ActiveSupport::TestCase
end
def test_multiparameter_attributes_on_time
- attributes = {
- "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24",
+ attributes = {
+ "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24",
"written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00"
}
topic = Topic.find(1)
@@ -925,8 +925,8 @@ class BasicsTest < ActiveSupport::TestCase
end
def test_multiparameter_attributes_on_time_with_empty_seconds
- attributes = {
- "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24",
+ attributes = {
+ "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24",
"written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => ""
}
topic = Topic.find(1)
@@ -937,12 +937,12 @@ class BasicsTest < ActiveSupport::TestCase
def test_multiparameter_mass_assignment_protector
task = Task.new
time = Time.mktime(2000, 1, 1, 1)
- task.starting = time
+ task.starting = time
attributes = { "starting(1i)" => "2004", "starting(2i)" => "6", "starting(3i)" => "24" }
task.attributes = attributes
assert_equal time, task.starting
end
-
+
def test_multiparameter_assignment_of_aggregation
customer = Customer.new
address = Address.new("The Street", "The City", "The Country")
@@ -984,9 +984,9 @@ class BasicsTest < ActiveSupport::TestCase
b_false = Booleantest.find(false_id)
assert !b_false.value?
b_true = Booleantest.find(true_id)
- assert b_true.value?
+ assert b_true.value?
end
-
+
def test_clone
topic = Topic.find(1)
cloned_topic = nil
@@ -995,15 +995,15 @@ class BasicsTest < ActiveSupport::TestCase
assert cloned_topic.new_record?
# test if the attributes have been cloned
- topic.title = "a"
- cloned_topic.title = "b"
+ topic.title = "a"
+ cloned_topic.title = "b"
assert_equal "a", topic.title
assert_equal "b", cloned_topic.title
# test if the attribute values have been cloned
topic.title = {"a" => "b"}
cloned_topic = topic.clone
- cloned_topic.title["a"] = "c"
+ cloned_topic.title["a"] = "c"
assert_equal "b", topic.title["a"]
#test if attributes set as part of after_initialize are cloned correctly
@@ -1053,11 +1053,11 @@ class BasicsTest < ActiveSupport::TestCase
if current_adapter?(:PostgreSQLAdapter)
def test_default
default = Default.new
-
+
# fixed dates / times
assert_equal Date.new(2004, 1, 1), default.fixed_date
assert_equal Time.local(2004, 1,1,0,0,0,0), default.fixed_time
-
+
# char types
assert_equal 'Y', default.char1
assert_equal 'a varchar field', default.char2
@@ -1080,7 +1080,7 @@ class BasicsTest < ActiveSupport::TestCase
:a_polygon => '((2.0, 3), (5.5, 7.0), (8.5, 11.0))',
:a_circle => '<(5.3, 10.4), 2>'
)
-
+
assert g.save
# Reload and check that we have all the geometric attributes.
@@ -1098,7 +1098,7 @@ class BasicsTest < ActiveSupport::TestCase
assert_equal objs[0].isopen, 't'
# test alternate formats when defining the geometric types
-
+
g = Geometric.new(
:a_point => '5.0, 6.1',
#:a_line => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql
@@ -1113,7 +1113,7 @@ class BasicsTest < ActiveSupport::TestCase
# Reload and check that we have all the geometric attributes.
h = Geometric.find(g.id)
-
+
assert_equal '(5,6.1)', h.a_point
assert_equal '[(2,3),(5.5,7)]', h.a_line_segment
assert_equal '(5.5,7),(2,3)', h.a_box # reordered to store upper right corner then bottom left corner
@@ -1203,10 +1203,10 @@ class BasicsTest < ActiveSupport::TestCase
end
MyObject = Struct.new :attribute1, :attribute2
-
+
def test_serialized_attribute
myobj = MyObject.new('value1', 'value2')
- topic = Topic.create("content" => myobj)
+ topic = Topic.create("content" => myobj)
Topic.serialize("content", MyObject)
assert_equal(myobj, topic.content)
end
@@ -1278,46 +1278,46 @@ class BasicsTest < ActiveSupport::TestCase
def test_increment_attribute
assert_equal 50, accounts(:signals37).credit_limit
accounts(:signals37).increment! :credit_limit
- assert_equal 51, accounts(:signals37, :reload).credit_limit
+ assert_equal 51, accounts(:signals37, :reload).credit_limit
accounts(:signals37).increment(:credit_limit).increment!(:credit_limit)
assert_equal 53, accounts(:signals37, :reload).credit_limit
end
-
+
def test_increment_nil_attribute
assert_nil topics(:first).parent_id
topics(:first).increment! :parent_id
assert_equal 1, topics(:first).parent_id
end
-
+
def test_increment_attribute_by
assert_equal 50, accounts(:signals37).credit_limit
accounts(:signals37).increment! :credit_limit, 5
- assert_equal 55, accounts(:signals37, :reload).credit_limit
+ assert_equal 55, accounts(:signals37, :reload).credit_limit
accounts(:signals37).increment(:credit_limit, 1).increment!(:credit_limit, 3)
assert_equal 59, accounts(:signals37, :reload).credit_limit
end
-
+
def test_decrement_attribute
assert_equal 50, accounts(:signals37).credit_limit
accounts(:signals37).decrement!(:credit_limit)
assert_equal 49, accounts(:signals37, :reload).credit_limit
-
+
accounts(:signals37).decrement(:credit_limit).decrement!(:credit_limit)
assert_equal 47, accounts(:signals37, :reload).credit_limit
end
-
+
def test_decrement_attribute_by
assert_equal 50, accounts(:signals37).credit_limit
accounts(:signals37).decrement! :credit_limit, 5
- assert_equal 45, accounts(:signals37, :reload).credit_limit
+ assert_equal 45, accounts(:signals37, :reload).credit_limit
accounts(:signals37).decrement(:credit_limit, 1).decrement!(:credit_limit, 3)
assert_equal 41, accounts(:signals37, :reload).credit_limit
end
-
+
def test_toggle_attribute
assert !topics(:first).approved?
topics(:first).toggle!(:approved)
@@ -1394,17 +1394,17 @@ class BasicsTest < ActiveSupport::TestCase
def test_count_with_join
res = Post.count_by_sql "SELECT COUNT(*) FROM posts LEFT JOIN comments ON posts.id=comments.post_id WHERE posts.#{QUOTED_TYPE} = 'Post'"
-
+
res2 = Post.count(:conditions => "posts.#{QUOTED_TYPE} = 'Post'", :joins => "LEFT JOIN comments ON posts.id=comments.post_id")
assert_equal res, res2
-
+
res3 = nil
assert_nothing_raised do
res3 = Post.count(:conditions => "posts.#{QUOTED_TYPE} = 'Post'",
:joins => "LEFT JOIN comments ON posts.id=comments.post_id")
end
assert_equal res, res3
-
+
res4 = Post.count_by_sql "SELECT COUNT(p.id) FROM posts p, comments co WHERE p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id"
res5 = nil
assert_nothing_raised do
@@ -1413,7 +1413,7 @@ class BasicsTest < ActiveSupport::TestCase
:select => "p.id")
end
- assert_equal res4, res5
+ assert_equal res4, res5
unless current_adapter?(:SQLite2Adapter, :DeprecatedSQLiteAdapter)
res6 = Post.count_by_sql "SELECT COUNT(DISTINCT p.id) FROM posts p, comments co WHERE p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id"
@@ -1427,15 +1427,15 @@ class BasicsTest < ActiveSupport::TestCase
assert_equal res6, res7
end
end
-
- def test_clear_association_cache_stored
+
+ def test_clear_association_cache_stored
firm = Firm.find(1)
assert_kind_of Firm, firm
firm.clear_association_cache
assert_equal Firm.find(1).clients.collect{ |x| x.name }.sort, firm.clients.collect{ |x| x.name }.sort
end
-
+
def test_clear_association_cache_new_record
firm = Firm.new
client_stored = Client.find(3)
@@ -1463,31 +1463,31 @@ class BasicsTest < ActiveSupport::TestCase
assert !scoped_developers.include?(developers(:david)) # David's salary is less than 90,000
assert_equal 3, scoped_developers.size
end
-
+
def test_scoped_find_limit_offset
scoped_developers = Developer.with_scope(:find => { :limit => 3, :offset => 2 }) do
Developer.find(:all, :order => 'id')
- end
+ end
assert !scoped_developers.include?(developers(:david))
assert !scoped_developers.include?(developers(:jamis))
assert_equal 3, scoped_developers.size
-
+
# Test without scoped find conditions to ensure we get the whole thing
developers = Developer.find(:all, :order => 'id')
assert_equal Developer.count, developers.size
end
- def test_scoped_find_order
- # Test order in scope
+ def test_scoped_find_order
+ # Test order in scope
scoped_developers = Developer.with_scope(:find => { :limit => 1, :order => 'salary DESC' }) do
Developer.find(:all)
- end
+ end
assert_equal 'Jamis', scoped_developers.first.name
assert scoped_developers.include?(developers(:jamis))
# Test scope without order and order in find
scoped_developers = Developer.with_scope(:find => { :limit => 1 }) do
Developer.find(:all, :order => 'salary DESC')
- end
+ end
# Test scope order + find order, find has priority
scoped_developers = Developer.with_scope(:find => { :limit => 3, :order => 'id DESC' }) do
Developer.find(:all, :order => 'salary ASC')
@@ -1634,11 +1634,11 @@ class BasicsTest < ActiveSupport::TestCase
xml = topics(:first).to_xml(:indent => 0, :skip_instruct => true, :except => [:title, :replies_count])
assert_equal "<topic>", xml.first(7)
assert !xml.include?(%(<title>The First Topic</title>))
- assert xml.include?(%(<author-name>David</author-name>))
+ assert xml.include?(%(<author-name>David</author-name>))
xml = topics(:first).to_xml(:indent => 0, :skip_instruct => true, :except => [:title, :author_name, :replies_count])
assert !xml.include?(%(<title>The First Topic</title>))
- assert !xml.include?(%(<author-name>David</author-name>))
+ assert !xml.include?(%(<author-name>David</author-name>))
end
def test_to_xml_including_has_many_association
@@ -1658,7 +1658,7 @@ class BasicsTest < ActiveSupport::TestCase
assert xml.include?(%(<topic-id type="integer">#{topics(:first).topic_id}</topic-id>)), xml
assert xml.include?(%(<topic-id type="integer">#{topics(:second).topic_id}</topic-id>)), xml
end
-
+
def test_array_to_xml_including_has_one_association
xml = [ companies(:first_firm), companies(:rails_core) ].to_xml(:indent => 0, :skip_instruct => true, :include => :account)
assert xml.include?(companies(:first_firm).account.to_xml(:indent => 0, :skip_instruct => true))
@@ -1679,7 +1679,7 @@ class BasicsTest < ActiveSupport::TestCase
xml = companies(:second_client).to_xml(:indent => 0, :skip_instruct => true, :include => :firm)
assert xml.include?("<firm>")
end
-
+
def test_to_xml_including_multiple_associations
xml = companies(:first_firm).to_xml(:indent => 0, :skip_instruct => true, :include => [ :clients, :account ])
assert_equal "<firm>", xml.first(6)
@@ -1689,21 +1689,21 @@ class BasicsTest < ActiveSupport::TestCase
def test_to_xml_including_multiple_associations_with_options
xml = companies(:first_firm).to_xml(
- :indent => 0, :skip_instruct => true,
+ :indent => 0, :skip_instruct => true,
:include => { :clients => { :only => :name } }
)
-
+
assert_equal "<firm>", xml.first(6)
assert xml.include?(%(<client><name>Summit</name></client>))
assert xml.include?(%(<clients type="array"><client>))
end
-
+
def test_to_xml_including_methods
xml = Company.new.to_xml(:methods => :arbitrary_method, :skip_instruct => true)
assert_equal "<company>", xml.first(9)
assert xml.include?(%(<arbitrary-method>I am Jack's profound disappointment</arbitrary-method>))
end
-
+
def test_to_xml_with_block
value = "Rockin' the block"
xml = Company.new.to_xml(:skip_instruct => true) do |xml|
@@ -1712,7 +1712,7 @@ class BasicsTest < ActiveSupport::TestCase
assert_equal "<company>", xml.first(9)
assert xml.include?(%(<arbitrary-element>#{value}</arbitrary-element>))
end
-
+
def test_except_attributes
assert_equal(
%w( author_name type id approved replies_count bonus_time written_on content author_email_address parent_id last_read).sort,
@@ -1724,21 +1724,21 @@ class BasicsTest < ActiveSupport::TestCase
topics(:first).attributes(:except => [ :title, :id, :type, :approved, :author_name ]).keys.sort
)
end
-
+
def test_include_attributes
assert_equal(%w( title ), topics(:first).attributes(:only => :title).keys)
assert_equal(%w( title author_name type id approved ).sort, topics(:first).attributes(:only => [ :title, :id, :type, :approved, :author_name ]).keys.sort)
end
-
+
def test_type_name_with_module_should_handle_beginning
assert_equal 'ActiveRecord::Person', ActiveRecord::Base.send(:type_name_with_module, 'Person')
assert_equal '::Person', ActiveRecord::Base.send(:type_name_with_module, '::Person')
end
-
+
def test_to_param_should_return_string
assert_kind_of String, Client.find(:first).to_param
end
-
+
def test_inspect_class
assert_equal 'ActiveRecord::Base', ActiveRecord::Base.inspect
assert_equal 'LoosePerson(abstract)', LoosePerson.inspect
@@ -1758,7 +1758,7 @@ class BasicsTest < ActiveSupport::TestCase
assert_equal %(#<Topic id: 1>), Topic.find(:first, :select => 'id', :conditions => 'id = 1').inspect
assert_equal %(#<Topic id: 1, title: "The First Topic">), Topic.find(:first, :select => 'id, title', :conditions => 'id = 1').inspect
end
-
+
def test_inspect_class_without_table
assert_equal "NonExistentTable(Table doesn't exist)", NonExistentTable.inspect
end
@@ -1770,7 +1770,7 @@ class BasicsTest < ActiveSupport::TestCase
assert_equal %("#{t.written_on.to_s(:db)}"), t.attribute_for_inspect(:written_on)
assert_equal '"The First Topic Now Has A Title With\nNewlines And M..."', t.attribute_for_inspect(:title)
end
-
+
def test_becomes
assert_kind_of Reply, topics(:first).becomes(Reply)
assert_equal "The First Topic", topics(:first).becomes(Reply).title
diff --git a/activerecord/test/binary_test.rb b/activerecord/test/cases/binary_test.rb
index f89660e4e1..f89660e4e1 100644
--- a/activerecord/test/binary_test.rb
+++ b/activerecord/test/cases/binary_test.rb
diff --git a/activerecord/test/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index bce84478b0..7bee644947 100644
--- a/activerecord/test/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -79,7 +79,7 @@ class CalculationsTest < ActiveSupport::TestCase
end
def test_should_group_by_summed_field_having_condition
- c = Account.sum(:credit_limit, :group => :firm_id,
+ c = Account.sum(:credit_limit, :group => :firm_id,
:having => 'sum(credit_limit) > 50')
assert_nil c[1]
assert_equal 105, c[6]
@@ -92,22 +92,22 @@ class CalculationsTest < ActiveSupport::TestCase
assert_equal 105, c[companies(:rails_core)]
assert_equal 60, c[companies(:first_client)]
end
-
+
def test_should_sum_field_with_conditions
assert_equal 105, Account.sum(:credit_limit, :conditions => 'firm_id = 6')
end
def test_should_group_by_summed_field_with_conditions
- c = Account.sum(:credit_limit, :conditions => 'firm_id > 1',
+ c = Account.sum(:credit_limit, :conditions => 'firm_id > 1',
:group => :firm_id)
assert_nil c[1]
assert_equal 105, c[6]
assert_equal 60, c[2]
end
-
+
def test_should_group_by_summed_field_with_conditions_and_having
- c = Account.sum(:credit_limit, :conditions => 'firm_id > 1',
- :group => :firm_id,
+ c = Account.sum(:credit_limit, :conditions => 'firm_id > 1',
+ :group => :firm_id,
:having => 'sum(credit_limit) > 60')
assert_nil c[1]
assert_equal 105, c[6]
@@ -120,19 +120,19 @@ class CalculationsTest < ActiveSupport::TestCase
assert_equal 105, c[6]
assert_equal 60, c[2]
end
-
+
def test_should_calculate_with_invalid_field
assert_equal 6, Account.calculate(:count, '*')
assert_equal 6, Account.calculate(:count, :all)
end
-
+
def test_should_calculate_grouped_with_invalid_field
c = Account.count(:all, :group => 'accounts.firm_id')
assert_equal 1, c[1]
assert_equal 2, c[6]
assert_equal 1, c[2]
end
-
+
def test_should_calculate_grouped_association_with_invalid_field
c = Account.count(:all, :group => :firm)
assert_equal 1, c[companies(:first_firm)]
@@ -159,11 +159,11 @@ class CalculationsTest < ActiveSupport::TestCase
assert_equal 1, c.first.last
end
end
-
+
def test_should_not_modify_options_when_using_includes
options = {:conditions => 'companies.id > 1', :include => :firm}
options_copy = options.dup
-
+
Account.count(:all, options)
assert_equal options_copy, options
end
@@ -175,7 +175,7 @@ class CalculationsTest < ActiveSupport::TestCase
assert_equal 3, c['CLIENT']
assert_equal 2, c['FIRM']
end
-
+
def test_should_calculate_grouped_by_function_with_table_alias
c = Company.count(:all, :group => "UPPER(companies.#{QUOTED_TYPE})")
assert_equal 2, c[nil]
@@ -183,7 +183,7 @@ class CalculationsTest < ActiveSupport::TestCase
assert_equal 3, c['CLIENT']
assert_equal 2, c['FIRM']
end
-
+
def test_should_not_overshadow_enumerable_sum
assert_equal 6, [1, 2, 3].sum(&:abs)
end
@@ -215,32 +215,32 @@ class CalculationsTest < ActiveSupport::TestCase
# empty options are valid
Company.send(:validate_calculation_options, func)
# these options are valid for all calculations
- [:select, :conditions, :joins, :order, :group, :having, :distinct].each do |opt|
+ [:select, :conditions, :joins, :order, :group, :having, :distinct].each do |opt|
Company.send(:validate_calculation_options, func, opt => true)
end
end
-
+
# :include is only valid on :count
Company.send(:validate_calculation_options, :count, :include => true)
end
-
+
assert_raises(ArgumentError) { Company.send(:validate_calculation_options, :sum, :foo => :bar) }
assert_raises(ArgumentError) { Company.send(:validate_calculation_options, :count, :foo => :bar) }
end
-
+
def test_should_count_selected_field_with_include
assert_equal 6, Account.count(:distinct => true, :include => :firm)
assert_equal 4, Account.count(:distinct => true, :include => :firm, :select => :credit_limit)
end
-
+
def test_count_with_column_parameter
assert_equal 5, Account.count(:firm_id)
end
-
+
def test_count_with_column_and_options_parameter
assert_equal 2, Account.count(:firm_id, :conditions => "credit_limit = 50")
end
-
+
def test_count_with_no_parameters_isnt_deprecated
assert_not_deprecated { Account.count }
end
diff --git a/activerecord/test/callbacks_test.rb b/activerecord/test/cases/callbacks_test.rb
index 5461d8e110..50c5d4ea62 100644
--- a/activerecord/test/callbacks_test.rb
+++ b/activerecord/test/cases/callbacks_test.rb
@@ -56,7 +56,7 @@ class ParentDeveloper < ActiveRecord::Base
end
class ChildDeveloper < ParentDeveloper
-
+
end
class RecursiveCallbackDeveloper < ActiveRecord::Base
@@ -361,7 +361,7 @@ class CallbacksTest < ActiveSupport::TestCase
david = ImmutableDeveloper.find(1)
assert !david.destroy
assert_not_nil ImmutableDeveloper.find_by_id(1)
- end
+ end
def test_zzz_callback_returning_false # must be run last since we modify CallbackDeveloper
david = CallbackDeveloper.find(1)
@@ -384,17 +384,17 @@ class CallbacksTest < ActiveSupport::TestCase
[ :before_validation, :returning_false ]
], david.history
end
-
+
def test_inheritence_of_callbacks
parent = ParentDeveloper.new
assert !parent.after_save_called
parent.save
assert parent.after_save_called
-
+
child = ChildDeveloper.new
assert !child.after_save_called
child.save
assert child.after_save_called
end
-
+
end
diff --git a/activerecord/test/class_inheritable_attributes_test.rb b/activerecord/test/cases/class_inheritable_attributes_test.rb
index 3a29a3befb..4f04f41e76 100644
--- a/activerecord/test/class_inheritable_attributes_test.rb
+++ b/activerecord/test/cases/class_inheritable_attributes_test.rb
@@ -24,7 +24,7 @@ class ClassInheritableAttributesTest < ActiveSupport::TestCase
assert_equal [ :one, :two ], B.read_inheritable_attribute("first")
assert_equal [ :three ], C.read_inheritable_attribute("first")
end
-
+
def test_second_level
assert_equal [ :one, :two, :four ], D.read_inheritable_attribute("first")
assert_equal [ :one, :two ], B.read_inheritable_attribute("first")
diff --git a/activerecord/test/column_alias_test.rb b/activerecord/test/cases/column_alias_test.rb
index da4b66554a..da4b66554a 100644
--- a/activerecord/test/column_alias_test.rb
+++ b/activerecord/test/cases/column_alias_test.rb
diff --git a/activerecord/test/connection_test_firebird.rb b/activerecord/test/cases/connection_test_firebird.rb
index eb0222b66f..eb0222b66f 100644
--- a/activerecord/test/connection_test_firebird.rb
+++ b/activerecord/test/cases/connection_test_firebird.rb
diff --git a/activerecord/test/connection_test_mysql.rb b/activerecord/test/cases/connection_test_mysql.rb
index e49a326d2b..e49a326d2b 100644
--- a/activerecord/test/connection_test_mysql.rb
+++ b/activerecord/test/cases/connection_test_mysql.rb
diff --git a/activerecord/test/copy_table_test_sqlite.rb b/activerecord/test/cases/copy_table_test_sqlite.rb
index f4933d5362..ec58295cd1 100644
--- a/activerecord/test/copy_table_test_sqlite.rb
+++ b/activerecord/test/cases/copy_table_test_sqlite.rb
@@ -2,36 +2,36 @@ require 'abstract_unit'
class CopyTableTest < ActiveSupport::TestCase
fixtures :companies, :comments
-
+
def setup
@connection = ActiveRecord::Base.connection
class << @connection
public :copy_table, :table_structure, :indexes
end
end
-
+
def test_copy_table(from = 'companies', to = 'companies2', options = {})
assert_nothing_raised {copy_table(from, to, options)}
assert_equal row_count(from), row_count(to)
-
+
if block_given?
yield from, to, options
else
assert_equal column_names(from), column_names(to)
end
-
+
@connection.drop_table(to) rescue nil
end
-
+
def test_copy_table_renaming_column
- test_copy_table('companies', 'companies2',
+ test_copy_table('companies', 'companies2',
:rename => {'client_of' => 'fan_of'}) do |from, to, options|
expected = column_values(from, 'client_of')
assert expected.any?, 'only nils in resultset; real values are needed'
assert_equal expected, column_values(to, 'fan_of')
end
end
-
+
def test_copy_table_with_index
test_copy_table('comments', 'comments_with_index') do
@connection.add_index('comments_with_index', ['post_id', 'type'])
@@ -41,11 +41,11 @@ class CopyTableTest < ActiveSupport::TestCase
end
end
end
-
+
def test_copy_table_without_primary_key
test_copy_table('developers_projects', 'programmers_projects')
end
-
+
protected
def copy_table(from, to, options = {})
@connection.copy_table(from, to, {:temporary => true}.merge(options))
@@ -54,7 +54,7 @@ protected
def column_names(table)
@connection.table_structure(table).map {|column| column['name']}
end
-
+
def column_values(table, column)
@connection.select_all("SELECT #{column} FROM #{table} ORDER BY id").map {|row| row[column]}
end
@@ -62,7 +62,7 @@ protected
def table_indexes_without_name(table)
@connection.indexes('comments_with_index').delete(:name)
end
-
+
def row_count(table)
@connection.select_one("SELECT COUNT(*) AS count FROM #{table}")['count']
end
diff --git a/activerecord/test/datatype_test_postgresql.rb b/activerecord/test/cases/datatype_test_postgresql.rb
index cd881bb498..5b882f7a2b 100644
--- a/activerecord/test/datatype_test_postgresql.rb
+++ b/activerecord/test/cases/datatype_test_postgresql.rb
@@ -43,10 +43,10 @@ class PostgresqlDataTypeTest < ActiveSupport::TestCase
@connection.execute("INSERT INTO postgresql_network_addresses (cidr_address, inet_address, mac_address) VALUES('192.168.0/24', '172.16.1.254/32', '01:23:45:67:89:0a')")
@first_network_address = PostgresqlNetworkAddress.find(1)
-
+
@connection.execute("INSERT INTO postgresql_bit_strings (bit_string, bit_string_varying) VALUES (B'00010101', X'15')")
@first_bit_string = PostgresqlBitString.find(1)
-
+
@connection.execute("INSERT INTO postgresql_oids (obj_id) VALUES (1234)")
@first_oid = PostgresqlOid.find(1)
end
diff --git a/activerecord/test/date_time_test.rb b/activerecord/test/cases/date_time_test.rb
index 23b2757d2a..20020b24cc 100644
--- a/activerecord/test/date_time_test.rb
+++ b/activerecord/test/cases/date_time_test.rb
@@ -10,7 +10,7 @@ class DateTimeTest < ActiveSupport::TestCase
task = Task.new
task.starting = now
task.save!
-
+
# check against Time.local_time, since some platforms will return a Time instead of a DateTime
assert_equal Time.local_time(*time_values), Task.find(task.id).starting
end
diff --git a/activerecord/test/default_test_firebird.rb b/activerecord/test/cases/default_test_firebird.rb
index 841027b175..841027b175 100644
--- a/activerecord/test/default_test_firebird.rb
+++ b/activerecord/test/cases/default_test_firebird.rb
diff --git a/activerecord/test/defaults_test.rb b/activerecord/test/cases/defaults_test.rb
index 8a5c8e0530..8a5c8e0530 100644
--- a/activerecord/test/defaults_test.rb
+++ b/activerecord/test/cases/defaults_test.rb
diff --git a/activerecord/test/deprecated_finder_test.rb b/activerecord/test/cases/deprecated_finder_test.rb
index 9c5a74cf02..9c5a74cf02 100755
--- a/activerecord/test/deprecated_finder_test.rb
+++ b/activerecord/test/cases/deprecated_finder_test.rb
diff --git a/activerecord/test/finder_test.rb b/activerecord/test/cases/finder_test.rb
index c0484d9e78..14f494776c 100644
--- a/activerecord/test/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -145,13 +145,13 @@ class FinderTest < ActiveSupport::TestCase
assert topic.attribute_present?("author_name")
assert topic.respond_to?("author_name")
end
-
+
def test_find_on_blank_conditions
[nil, " ", [], {}].each do |blank|
assert_nothing_raised { Topic.find(:first, :conditions => blank) }
end
end
-
+
def test_find_on_blank_bind_conditions
[ [""], ["",{}] ].each do |blank|
assert_nothing_raised { Topic.find(:first, :conditions => blank) }
@@ -337,7 +337,7 @@ class FinderTest < ActiveSupport::TestCase
assert_equal topics(:first), Topic.find_by_title("The First Topic")
assert_nil Topic.find_by_title("The First Topic!")
end
-
+
def test_find_by_one_attribute_caches_dynamic_finder
# ensure this test can run independently of order
class << Topic; self; end.send(:remove_method, :find_by_title) if Topic.respond_to?(:find_by_title)
@@ -482,13 +482,13 @@ class FinderTest < ActiveSupport::TestCase
assert_equal "38signals", sig38.name
assert sig38.new_record?
end
-
+
def test_find_or_initialize_from_one_attribute_should_set_attribute_even_when_protected
c = Company.find_or_initialize_by_name_and_rating("Fortune 1000", 1000)
assert_equal "Fortune 1000", c.name
assert_equal 1000, c.rating
assert c.valid?
- assert c.new_record?
+ assert c.new_record?
end
def test_find_or_create_from_one_attribute_should_set_attribute_even_when_protected
@@ -496,11 +496,11 @@ class FinderTest < ActiveSupport::TestCase
assert_equal "Fortune 1000", c.name
assert_equal 1000, c.rating
assert c.valid?
- assert !c.new_record?
+ assert !c.new_record?
end
def test_dynamic_find_or_initialize_from_one_attribute_caches_method
- class << Company; self; end.send(:remove_method, :find_or_initialize_by_name) if Company.respond_to?(:find_or_initialize_by_name)
+ class << Company; self; end.send(:remove_method, :find_or_initialize_by_name) if Company.respond_to?(:find_or_initialize_by_name)
assert !Company.respond_to?(:find_or_initialize_by_name)
sig38 = Company.find_or_initialize_by_name("38signals")
assert Company.respond_to?(:find_or_initialize_by_name)
diff --git a/activerecord/test/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index d836e456a2..51dbee6af3 100755
--- a/activerecord/test/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -310,11 +310,11 @@ end
class SetupTest < ActiveSupport::TestCase
# fixtures :topics
-
+
def setup
@first = true
end
-
+
def test_nothing
end
end
@@ -324,7 +324,7 @@ class SetupSubclassTest < SetupTest
super
@second = true
end
-
+
def test_subclassing_should_preserve_setups
assert @first
assert @second
diff --git a/activerecord/test/inheritance_test.rb b/activerecord/test/cases/inheritance_test.rb
index 0bba53de43..092503f279 100755
--- a/activerecord/test/inheritance_test.rb
+++ b/activerecord/test/cases/inheritance_test.rb
@@ -33,7 +33,7 @@ class InheritanceTest < ActiveSupport::TestCase
assert Company.find(2).kind_of?(Client), "Summit should be a client"
assert Client.find(2).kind_of?(Client), "Summit should be a client"
end
-
+
def test_alt_inheritance_find
switch_to_alt_inheritance_column
test_inheritance_find
@@ -45,7 +45,7 @@ class InheritanceTest < ActiveSupport::TestCase
assert companies[0].kind_of?(Firm), "37signals should be a firm"
assert companies[1].kind_of?(Client), "Summit should be a client"
end
-
+
def test_alt_inheritance_find_all
switch_to_alt_inheritance_column
test_inheritance_find_all
@@ -56,11 +56,11 @@ class InheritanceTest < ActiveSupport::TestCase
firm = Firm.new
firm.name = "Next Angle"
firm.save
-
+
next_angle = Company.find(firm.id)
assert next_angle.kind_of?(Firm), "Next Angle should be a firm"
end
-
+
def test_alt_inheritance_save
switch_to_alt_inheritance_column
test_inheritance_save
@@ -72,7 +72,7 @@ class InheritanceTest < ActiveSupport::TestCase
assert_equal 2, Firm.count
assert_equal 3, Client.count
end
-
+
def test_alt_inheritance_condition
switch_to_alt_inheritance_column
test_inheritance_condition
@@ -83,7 +83,7 @@ class InheritanceTest < ActiveSupport::TestCase
assert_raises(ActiveRecord::RecordNotFound) { Firm.find(2) }
assert_nothing_raised { Firm.find(1) }
end
-
+
def test_alt_finding_incorrect_type_data
switch_to_alt_inheritance_column
test_finding_incorrect_type_data
@@ -95,7 +95,7 @@ class InheritanceTest < ActiveSupport::TestCase
assert_equal "I am a client", Client.find(:all).first.name
assert_equal "37signals", Firm.find(:all).first.name
end
-
+
def test_alt_update_all_within_inheritance
switch_to_alt_inheritance_column
test_update_all_within_inheritance
@@ -107,7 +107,7 @@ class InheritanceTest < ActiveSupport::TestCase
assert_equal 0, Client.count
assert_equal 2, Firm.count
end
-
+
def test_alt_destroy_all_within_inheritance
switch_to_alt_inheritance_column
test_destroy_all_within_inheritance
@@ -119,7 +119,7 @@ class InheritanceTest < ActiveSupport::TestCase
assert_kind_of Firm, Firm.find(:first, :conditions => "name = '37signals'")
assert_nil Client.find(:first, :conditions => "name = '37signals'")
end
-
+
def test_alt_find_first_within_inheritance
switch_to_alt_inheritance_column
test_find_first_within_inheritance
@@ -141,12 +141,12 @@ class InheritanceTest < ActiveSupport::TestCase
test_complex_inheritance
switch_to_default_inheritance_column
end
-
+
def test_eager_load_belongs_to_something_inherited
account = Account.find(1, :include => :firm)
assert_not_nil account.instance_variable_get("@firm"), "nil proves eager load failed"
end
-
+
def test_alt_eager_loading
switch_to_alt_inheritance_column
test_eager_load_belongs_to_something_inherited
diff --git a/activerecord/test/json_serialization_test.rb b/activerecord/test/cases/json_serialization_test.rb
index 49711f625b..49711f625b 100644
--- a/activerecord/test/json_serialization_test.rb
+++ b/activerecord/test/cases/json_serialization_test.rb
diff --git a/activerecord/test/lifecycle_test.rb b/activerecord/test/cases/lifecycle_test.rb
index 43a798525d..91c6b8cc43 100755
--- a/activerecord/test/lifecycle_test.rb
+++ b/activerecord/test/cases/lifecycle_test.rb
@@ -28,9 +28,9 @@ end
class TopicaObserver < ActiveRecord::Observer
observe :topic
-
+
attr_reader :topic
-
+
def after_find(topic)
@topic = topic
end
@@ -38,7 +38,7 @@ end
class TopicObserver < ActiveRecord::Observer
attr_reader :topic
-
+
def after_find(topic)
@topic = topic
end
diff --git a/activerecord/test/locking_test.rb b/activerecord/test/cases/locking_test.rb
index 95bd517e76..da2b594c5d 100644
--- a/activerecord/test/locking_test.rb
+++ b/activerecord/test/cases/locking_test.rb
@@ -34,7 +34,7 @@ class OptimisticLockingTest < ActiveSupport::TestCase
assert_raises(ActiveRecord::StaleObjectError) { p2.save! }
end
-
+
def test_lock_repeating
p1 = Person.find(1)
p2 = Person.find(1)
@@ -64,7 +64,7 @@ class OptimisticLockingTest < ActiveSupport::TestCase
assert_raises(ActiveRecord::StaleObjectError) { p2.save! }
end
-
+
def test_lock_new_with_nil
p1 = Person.new(:first_name => 'anika')
p1.save!
@@ -72,7 +72,7 @@ class OptimisticLockingTest < ActiveSupport::TestCase
p1.save!
assert_equal 1, p1.lock_version
end
-
+
def test_lock_column_name_existing
t1 = LegacyThing.find(1)
diff --git a/activerecord/test/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb
index 655308f4a2..00304ba5cf 100644
--- a/activerecord/test/method_scoping_test.rb
+++ b/activerecord/test/cases/method_scoping_test.rb
@@ -7,7 +7,7 @@ require 'fixtures/category'
class MethodScopingTest < ActiveSupport::TestCase
fixtures :developers, :projects, :comments, :posts
-
+
def test_set_conditions
Developer.with_scope(:find => { :conditions => 'just a test...' }) do
assert_equal 'just a test...', Developer.send(:current_scoped_methods)[:find][:conditions]
@@ -19,46 +19,46 @@ class MethodScopingTest < ActiveSupport::TestCase
assert_nothing_raised { Developer.find(1) }
end
end
-
+
def test_scoped_find_first
Developer.with_scope(:find => { :conditions => "salary = 100000" }) do
assert_equal Developer.find(10), Developer.find(:first, :order => 'name')
end
end
-
+
def test_scoped_find_combines_conditions
Developer.with_scope(:find => { :conditions => "salary = 9000" }) do
assert_equal developers(:poor_jamis), Developer.find(:first, :conditions => "name = 'Jamis'")
end
end
-
+
def test_scoped_find_sanitizes_conditions
Developer.with_scope(:find => { :conditions => ['salary = ?', 9000] }) do
assert_equal developers(:poor_jamis), Developer.find(:first)
- end
+ end
end
-
+
def test_scoped_find_combines_and_sanitizes_conditions
Developer.with_scope(:find => { :conditions => ['salary = ?', 9000] }) do
assert_equal developers(:poor_jamis), Developer.find(:first, :conditions => ['name = ?', 'Jamis'])
- end
+ end
end
-
+
def test_scoped_find_all
Developer.with_scope(:find => { :conditions => "name = 'David'" }) do
assert_equal [developers(:david)], Developer.find(:all)
- end
+ end
end
-
+
def test_scoped_count
Developer.with_scope(:find => { :conditions => "name = 'David'" }) do
assert_equal 1, Developer.count
- end
+ end
Developer.with_scope(:find => { :conditions => 'salary = 100000' }) do
assert_equal 8, Developer.count
assert_equal 1, Developer.count(:conditions => "name LIKE 'fixture_1%'")
- end
+ end
end
def test_scoped_find_include
@@ -70,7 +70,7 @@ class MethodScopingTest < ActiveSupport::TestCase
assert !scoped_developers.include?(developers(:jamis))
assert_equal 1, scoped_developers.size
end
-
+
def test_scoped_count_include
# with the include, will retrieve only developers for the given project
Developer.with_scope(:find => { :include => :projects }) do
@@ -184,7 +184,7 @@ class NestedScopingTest < ActiveSupport::TestCase
assert_nothing_raised { Developer.find(1) }
assert_equal('David', Developer.find(:first).name)
end
- end
+ end
end
def test_nested_scoped_find_merged_include
@@ -194,31 +194,31 @@ class NestedScopingTest < ActiveSupport::TestCase
assert_equal 1, Developer.instance_eval('current_scoped_methods')[:find][:include].length
assert_equal('David', Developer.find(:first).name)
end
- end
-
+ end
+
# the nested scope doesn't remove the first :include
Developer.with_scope(:find => { :include => :projects, :conditions => "projects.id = 2" }) do
Developer.with_scope(:find => { :include => [] }) do
assert_equal 1, Developer.instance_eval('current_scoped_methods')[:find][:include].length
assert_equal('David', Developer.find(:first).name)
end
- end
-
+ end
+
# mixing array and symbol include's will merge correctly
Developer.with_scope(:find => { :include => [:projects], :conditions => "projects.id = 2" }) do
Developer.with_scope(:find => { :include => :projects }) do
assert_equal 1, Developer.instance_eval('current_scoped_methods')[:find][:include].length
assert_equal('David', Developer.find(:first).name)
end
- end
+ end
end
-
+
def test_nested_scoped_find_replace_include
Developer.with_scope(:find => { :include => :projects }) do
Developer.with_exclusive_scope(:find => { :include => [] }) do
assert_equal 0, Developer.instance_eval('current_scoped_methods')[:find][:include].length
end
- end
+ end
end
def test_three_level_nested_exclusive_scoped_find
@@ -315,11 +315,11 @@ end
class HasManyScopingTest< ActiveSupport::TestCase
fixtures :comments, :posts
-
+
def setup
@welcome = Post.find(1)
end
-
+
def test_forwarding_of_static_methods
assert_equal 'a comment...', Comment.what_are_you
assert_equal 'a comment...', @welcome.comments.what_are_you
@@ -329,7 +329,7 @@ class HasManyScopingTest< ActiveSupport::TestCase
assert_equal 4, Comment.search_by_type('Comment').size
assert_equal 2, @welcome.comments.search_by_type('Comment').size
end
-
+
def test_forwarding_to_dynamic_finders
assert_equal 4, Comment.find_all_by_type('Comment').size
assert_equal 2, @welcome.comments.find_all_by_type('Comment').size
diff --git a/activerecord/test/migration_test.rb b/activerecord/test/cases/migration_test.rb
index f98f094fea..c349f1cb1b 100644
--- a/activerecord/test/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -24,7 +24,7 @@ if ActiveRecord::Base.connection.supports_migrations?
class MigrationTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
-
+
fixtures :people
def setup
@@ -80,7 +80,7 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_nothing_raised { Person.connection.add_index("people", ["key"], :name => "key_idx", :unique => true) }
assert_nothing_raised { Person.connection.remove_index("people", :name => "key_idx", :unique => true) }
end
-
+
# Sybase adapter does not support indexes on :boolean columns
# OpenBase does not have named indexes. You must specify a single column
unless current_adapter?(:SybaseAdapter, :OpenBaseAdapter)
@@ -201,8 +201,8 @@ if ActiveRecord::Base.connection.supports_migrations?
Person.connection.create_table :testings do |t|
t.column :foo, :string
end
-
- con = Person.connection
+
+ con = Person.connection
Person.connection.enable_identity_insert("testings", true) if current_adapter?(:SybaseAdapter)
Person.connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}) values (1, 'hello')"
Person.connection.enable_identity_insert("testings", false) if current_adapter?(:SybaseAdapter)
@@ -306,11 +306,11 @@ if ActiveRecord::Base.connection.supports_migrations?
# Test for 30 significent digits (beyond the 16 of float), 10 of them
# after the decimal place.
-
+
unless current_adapter?(:SQLite3Adapter)
assert_equal BigDecimal.new("0012345678901234567890.0123456789"), bob.wealth
end
-
+
assert_equal true, bob.male?
assert_equal String, bob.first_name.class
@@ -346,7 +346,7 @@ if ActiveRecord::Base.connection.supports_migrations?
ActiveRecord::Migration.add_column :people, :intelligence_quotient, :tinyint
Person.reset_column_information
Person.create :intelligence_quotient => 300
- jonnyg = Person.find(:first)
+ jonnyg = Person.find(:first)
assert_equal 127, jonnyg.intelligence_quotient
jonnyg.destroy
ensure
@@ -439,7 +439,7 @@ if ActiveRecord::Base.connection.supports_migrations?
Person.connection.add_column("people", "first_name", :string) rescue nil
end
end
-
+
def test_rename_column_with_an_index
ActiveRecord::Base.connection.create_table(:hats) do |table|
table.column :hat_name, :string, :limit => 100
@@ -482,7 +482,7 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_nothing_raised do
Topic.connection.change_column "topics", "written_on", :datetime, :null => false
Topic.reset_column_information
-
+
Topic.connection.change_column "topics", "written_on", :datetime, :null => false
Topic.reset_column_information
end
@@ -496,7 +496,7 @@ if ActiveRecord::Base.connection.supports_migrations?
ActiveRecord::Base.connection.rename_table :octopuses, :octopi
# Using explicit id in insert for compatibility across all databases
- con = ActiveRecord::Base.connection
+ con = ActiveRecord::Base.connection
con.enable_identity_insert("octopi", true) if current_adapter?(:SybaseAdapter)
assert_nothing_raised { con.execute "INSERT INTO octopi (#{con.quote_column_name('id')}, #{con.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')" }
con.enable_identity_insert("octopi", false) if current_adapter?(:SybaseAdapter)
@@ -508,9 +508,9 @@ if ActiveRecord::Base.connection.supports_migrations?
ActiveRecord::Base.connection.drop_table :octopi rescue nil
end
end
-
+
def test_change_column_nullability
- Person.delete_all
+ Person.delete_all
Person.connection.add_column "people", "funny", :boolean
Person.reset_column_information
assert Person.columns_hash["funny"].null, "Column 'funny' must initially allow nulls"
@@ -528,11 +528,11 @@ if ActiveRecord::Base.connection.supports_migrations?
t.column :url, :string
end
ActiveRecord::Base.connection.add_index :octopuses, :url
-
+
ActiveRecord::Base.connection.rename_table :octopuses, :octopi
# Using explicit id in insert for compatibility across all databases
- con = ActiveRecord::Base.connection
+ con = ActiveRecord::Base.connection
con.enable_identity_insert("octopi", true) if current_adapter?(:SybaseAdapter)
assert_nothing_raised { con.execute "INSERT INTO octopi (#{con.quote_column_name('id')}, #{con.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')" }
con.enable_identity_insert("octopi", false) if current_adapter?(:SybaseAdapter)
@@ -564,12 +564,12 @@ if ActiveRecord::Base.connection.supports_migrations?
assert new_columns.find { |c| c.name == 'approved' and c.type == :boolean and c.default == false }
assert_nothing_raised { Topic.connection.change_column :topics, :approved, :boolean, :default => true }
end
-
+
def test_change_column_with_nil_default
Person.connection.add_column "people", "contributor", :boolean, :default => true
Person.reset_column_information
assert Person.new.contributor?
-
+
assert_nothing_raised { Person.connection.change_column "people", "contributor", :boolean, :default => nil }
Person.reset_column_information
assert !Person.new.contributor?
@@ -589,7 +589,7 @@ if ActiveRecord::Base.connection.supports_migrations?
ensure
Person.connection.remove_column("people", "administrator") rescue nil
end
-
+
def test_change_column_default
Person.connection.change_column_default "people", "first_name", "Tester"
Person.reset_column_information
@@ -618,8 +618,8 @@ if ActiveRecord::Base.connection.supports_migrations?
assert !Reminder.table_exists?
WeNeedReminders.up
-
- assert Reminder.create("content" => "hello world", "remind_at" => Time.now)
+
+ assert Reminder.create("content" => "hello world", "remind_at" => Time.now)
assert_equal "hello world", Reminder.find(:first).content
WeNeedReminders.down
@@ -852,7 +852,7 @@ if ActiveRecord::Base.connection.supports_migrations?
columns = Person.connection.columns(:binary_testings)
data_column = columns.detect { |c| c.name == "data" }
- if current_adapter?(:MysqlAdapter)
+ if current_adapter?(:MysqlAdapter)
assert_equal '', data_column.default
else
assert_nil data_column.default
@@ -870,12 +870,12 @@ if ActiveRecord::Base.connection.supports_migrations?
def test_migrator_with_missing_version_numbers
ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/fixtures/migrations_with_missing_versions/', 500)
assert !Person.column_methods_hash.include?(:middle_name)
- assert_equal 4, ActiveRecord::Migrator.current_version
-
+ assert_equal 4, ActiveRecord::Migrator.current_version
+
ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/fixtures/migrations_with_missing_versions/', 2)
Person.reset_column_information
assert !Reminder.table_exists?
- assert Person.column_methods_hash.include?(:last_name)
+ assert Person.column_methods_hash.include?(:last_name)
assert_equal 2, ActiveRecord::Migrator.current_version
end
@@ -925,7 +925,7 @@ if ActiveRecord::Base.connection.supports_migrations?
t.references :customer
end
end
-
+
def test_references_column_type_with_polymorphic_adds_type
with_new_table do |t|
t.expects(:column).with('taggable_type', :string, {})
@@ -933,7 +933,7 @@ if ActiveRecord::Base.connection.supports_migrations?
t.references :taggable, :polymorphic => true
end
end
-
+
def test_references_column_type_with_polymorphic_and_options_null_is_false_adds_table_flag
with_new_table do |t|
t.expects(:column).with('taggable_type', :string, {:null => false})
@@ -941,14 +941,14 @@ if ActiveRecord::Base.connection.supports_migrations?
t.references :taggable, :polymorphic => true, :null => false
end
end
-
+
def test_belongs_to_works_like_references
with_new_table do |t|
t.expects(:column).with('customer_id', :integer, {})
t.belongs_to :customer
end
end
-
+
def test_timestamps_creates_updated_at_and_created_at
with_new_table do |t|
t.expects(:column).with(:created_at, :datetime)
@@ -956,7 +956,7 @@ if ActiveRecord::Base.connection.supports_migrations?
t.timestamps
end
end
-
+
def test_integer_creates_integer_column
with_new_table do |t|
t.expects(:column).with(:foo, 'integer', {})
@@ -964,7 +964,7 @@ if ActiveRecord::Base.connection.supports_migrations?
t.integer :foo, :bar
end
end
-
+
def test_string_creates_string_column
with_new_table do |t|
t.expects(:column).with(:foo, 'string', {})
@@ -972,7 +972,7 @@ if ActiveRecord::Base.connection.supports_migrations?
t.string :foo, :bar
end
end
-
+
protected
def with_new_table
Person.connection.create_table :delete_me do |t|
@@ -981,8 +981,7 @@ if ActiveRecord::Base.connection.supports_migrations?
ensure
Person.connection.drop_table :delete_me rescue nil
end
-
+
end # SexyMigrationsTest
end # uses_mocha
end
-
diff --git a/activerecord/test/migration_test_firebird.rb b/activerecord/test/cases/migration_test_firebird.rb
index 5c7dbd7a35..5c7dbd7a35 100644
--- a/activerecord/test/migration_test_firebird.rb
+++ b/activerecord/test/cases/migration_test_firebird.rb
diff --git a/activerecord/test/mixin_test.rb b/activerecord/test/cases/mixin_test.rb
index 1bf8764d7e..0823ffddd6 100644
--- a/activerecord/test/mixin_test.rb
+++ b/activerecord/test/cases/mixin_test.rb
@@ -7,7 +7,7 @@ end
class Time
@@forced_now_time = nil
cattr_accessor :forced_now_time
-
+
class << self
def now_with_forcing
if @@forced_now_time
@@ -23,11 +23,11 @@ end
class TouchTest < ActiveSupport::TestCase
fixtures :mixins
-
+
def setup
Time.forced_now_time = Time.now
end
-
+
def teardown
Time.forced_now_time = nil
end
@@ -36,7 +36,7 @@ class TouchTest < ActiveSupport::TestCase
five_minutes_ago = 5.minutes.ago
Time.forced_now_time = five_minutes_ago
assert_equal five_minutes_ago, Time.now
-
+
Time.forced_now_time = nil
assert_not_equal five_minutes_ago, Time.now
end
diff --git a/activerecord/test/modules_test.rb b/activerecord/test/cases/modules_test.rb
index 7e4d0f10bc..cced0bb895 100644
--- a/activerecord/test/modules_test.rb
+++ b/activerecord/test/cases/modules_test.rb
@@ -15,7 +15,7 @@ class ModulesTest < ActiveSupport::TestCase
project.developers << MyApplication::Business::Developer.create("name" => "John")
assert "John", project.developers.last.name
end
-
+
def test_associations_spanning_cross_modules
account = MyApplication::Billing::Account.find(:first, :order => 'id')
assert_kind_of MyApplication::Business::Firm, account.firm
@@ -24,11 +24,11 @@ class ModulesTest < ActiveSupport::TestCase
assert_kind_of MyApplication::Billing::Nested::Firm, account.nested_qualified_billing_firm
assert_kind_of MyApplication::Billing::Nested::Firm, account.nested_unqualified_billing_firm
end
-
+
def test_find_account_and_include_company
account = MyApplication::Billing::Account.find(1, :include => :firm)
assert_kind_of MyApplication::Business::Firm, account.instance_variable_get('@firm')
assert_kind_of MyApplication::Business::Firm, account.firm
end
-
+
end
diff --git a/activerecord/test/multiple_db_test.rb b/activerecord/test/cases/multiple_db_test.rb
index 5d64a3efaa..5d64a3efaa 100644
--- a/activerecord/test/multiple_db_test.rb
+++ b/activerecord/test/cases/multiple_db_test.rb
diff --git a/activerecord/test/pk_test.rb b/activerecord/test/cases/pk_test.rb
index 9566fc646d..a9e9150f23 100644
--- a/activerecord/test/pk_test.rb
+++ b/activerecord/test/cases/pk_test.rb
@@ -65,7 +65,7 @@ class PrimaryKeysTest < ActiveSupport::TestCase
def test_find_with_more_than_one_string_key
assert_equal 2, Subscriber.find(subscribers(:first).nick, subscribers(:second).nick).length
end
-
+
def test_primary_key_prefix
ActiveRecord::Base.primary_key_prefix_type = :table_name
Topic.reset_primary_key
@@ -79,7 +79,7 @@ class PrimaryKeysTest < ActiveSupport::TestCase
Topic.reset_primary_key
assert_equal "id", Topic.primary_key
end
-
+
def test_delete_should_quote_pkey
assert_nothing_raised { MixedCaseMonkey.delete(1) }
end
diff --git a/activerecord/test/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb
index 242223161c..242223161c 100644
--- a/activerecord/test/query_cache_test.rb
+++ b/activerecord/test/cases/query_cache_test.rb
diff --git a/activerecord/test/readonly_test.rb b/activerecord/test/cases/readonly_test.rb
index 6bac42e468..5674a4b442 100755
--- a/activerecord/test/readonly_test.rb
+++ b/activerecord/test/cases/readonly_test.rb
@@ -71,13 +71,13 @@ class ReadOnlyTest < ActiveSupport::TestCase
end
def test_readonly_scoping
- Post.with_scope(:find => { :conditions => '1=1' }) do
+ Post.with_scope(:find => { :conditions => '1=1' }) do
assert !Post.find(1).readonly?
assert Post.find(1, :readonly => true).readonly?
assert !Post.find(1, :readonly => false).readonly?
end
- Post.with_scope(:find => { :joins => ' ' }) do
+ Post.with_scope(:find => { :joins => ' ' }) do
assert !Post.find(1).readonly?
assert Post.find(1, :readonly => true).readonly?
assert !Post.find(1, :readonly => false).readonly?
@@ -86,7 +86,7 @@ class ReadOnlyTest < ActiveSupport::TestCase
# Oracle barfs on this because the join includes unqualified and
# conflicting column names
unless current_adapter?(:OracleAdapter)
- Post.with_scope(:find => { :joins => ', developers' }) do
+ Post.with_scope(:find => { :joins => ', developers' }) do
assert Post.find(1).readonly?
assert Post.find(1, :readonly => true).readonly?
assert !Post.find(1, :readonly => false).readonly?
diff --git a/activerecord/test/reflection_test.rb b/activerecord/test/cases/reflection_test.rb
index a2dab89732..7790747cea 100644
--- a/activerecord/test/reflection_test.rb
+++ b/activerecord/test/cases/reflection_test.rb
@@ -45,7 +45,7 @@ class ReflectionTest < ActiveSupport::TestCase
assert_equal :string, @first.column_for_attribute("title").type
assert_equal 255, @first.column_for_attribute("title").limit
end
-
+
def test_column_null_not_null
subscriber = Subscriber.find(:first)
assert subscriber.column_for_attribute("name").null
@@ -87,7 +87,7 @@ class ReflectionTest < ActiveSupport::TestCase
assert_equal reflection_for_address, Customer.reflect_on_aggregation(:address)
assert_equal Address, Customer.reflect_on_aggregation(:address).klass
-
+
assert_equal Money, Customer.reflect_on_aggregation(:balance).klass
end
@@ -157,7 +157,7 @@ class ReflectionTest < ActiveSupport::TestCase
:class_name => 'Nested::Firm',
:table_name => 'companies'
end
-
+
def test_reflection_of_all_associations
assert_equal 17, Firm.reflect_on_all_associations.size
assert_equal 15, Firm.reflect_on_all_associations(:has_many).size
diff --git a/activerecord/test/reserved_word_test_mysql.rb b/activerecord/test/cases/reserved_word_test_mysql.rb
index 58398f04e2..0600c9460e 100644
--- a/activerecord/test/reserved_word_test_mysql.rb
+++ b/activerecord/test/cases/reserved_word_test_mysql.rb
@@ -141,7 +141,7 @@ class MysqlReservedWordTest < ActiveSupport::TestCase
assert_nothing_raised { Group.table_exists? }
assert_nothing_raised { Group.columns }
end
-
+
# Calculations
def test_calculations_work_with_reserved_words
assert_nothing_raised { Group.count }
diff --git a/activerecord/test/schema_authorization_test_postgresql.rb b/activerecord/test/cases/schema_authorization_test_postgresql.rb
index 89044deb16..d42611b515 100644
--- a/activerecord/test/schema_authorization_test_postgresql.rb
+++ b/activerecord/test/cases/schema_authorization_test_postgresql.rb
@@ -28,7 +28,7 @@ class SchemaAuthorizationTest < ActiveSupport::TestCase
end
def teardown
- set_session_auth
+ set_session_auth
@connection.execute "RESET search_path"
USERS.each do |u|
@connection.execute "DROP SCHEMA #{u} CASCADE"
diff --git a/activerecord/test/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb
index 390181af8e..2b7226ec3b 100644
--- a/activerecord/test/schema_dumper_test.rb
+++ b/activerecord/test/cases/schema_dumper_test.rb
@@ -11,14 +11,14 @@ if ActiveRecord::Base.connection.respond_to?(:tables)
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
stream.string
end
-
+
def test_schema_dump
output = standard_dump
assert_match %r{create_table "accounts"}, output
assert_match %r{create_table "authors"}, output
assert_no_match %r{create_table "schema_info"}, output
end
-
+
def test_schema_dump_excludes_sqlite_sequence
output = standard_dump
assert_no_match %r{create_table "sqlite_sequence"}, output
@@ -41,7 +41,7 @@ if ActiveRecord::Base.connection.respond_to?(:tables)
column_definition_lines.each do |column_set|
next if column_set.empty?
- lengths = column_set.map do |column|
+ lengths = column_set.map do |column|
if match = column.match(/t\.(?:integer|decimal|float|datetime|timestamp|time|date|text|binary|string|boolean)\s+"/)
match[0].length
end
@@ -50,7 +50,7 @@ if ActiveRecord::Base.connection.respond_to?(:tables)
assert_equal 1, lengths.uniq.length
end
end
-
+
def test_arguments_line_up
column_definition_lines.each do |column_set|
assert_line_up(column_set, /:default => /)
@@ -58,15 +58,15 @@ if ActiveRecord::Base.connection.respond_to?(:tables)
assert_line_up(column_set, /:null => /)
end
end
-
+
def test_no_dump_errors
output = standard_dump
assert_no_match %r{\# Could not dump table}, output
end
-
+
def test_schema_dump_includes_not_null_columns
stream = StringIO.new
-
+
ActiveRecord::SchemaDumper.ignore_tables = [/^[^r]/]
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
output = stream.string
@@ -75,8 +75,8 @@ if ActiveRecord::Base.connection.respond_to?(:tables)
def test_schema_dump_with_string_ignored_table
stream = StringIO.new
-
- ActiveRecord::SchemaDumper.ignore_tables = ['accounts']
+
+ ActiveRecord::SchemaDumper.ignore_tables = ['accounts']
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
output = stream.string
assert_no_match %r{create_table "accounts"}, output
@@ -87,8 +87,8 @@ if ActiveRecord::Base.connection.respond_to?(:tables)
def test_schema_dump_with_regexp_ignored_table
stream = StringIO.new
-
- ActiveRecord::SchemaDumper.ignore_tables = [/^account/]
+
+ ActiveRecord::SchemaDumper.ignore_tables = [/^account/]
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
output = stream.string
assert_no_match %r{create_table "accounts"}, output
@@ -98,8 +98,8 @@ if ActiveRecord::Base.connection.respond_to?(:tables)
def test_schema_dump_illegal_ignored_table_value
- stream = StringIO.new
- ActiveRecord::SchemaDumper.ignore_tables = [5]
+ stream = StringIO.new
+ ActiveRecord::SchemaDumper.ignore_tables = [5]
assert_raise(StandardError) do
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
end
@@ -120,7 +120,7 @@ if ActiveRecord::Base.connection.respond_to?(:tables)
end
def test_schema_dump_includes_decimal_options
- stream = StringIO.new
+ stream = StringIO.new
ActiveRecord::SchemaDumper.ignore_tables = [/^[^n]/]
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
output = stream.string
diff --git a/activerecord/test/schema_test_postgresql.rb b/activerecord/test/cases/schema_test_postgresql.rb
index c38d6c9253..c38d6c9253 100644
--- a/activerecord/test/schema_test_postgresql.rb
+++ b/activerecord/test/cases/schema_test_postgresql.rb
diff --git a/activerecord/test/serialization_test.rb b/activerecord/test/cases/serialization_test.rb
index 61756999ed..e14fa02780 100644
--- a/activerecord/test/serialization_test.rb
+++ b/activerecord/test/cases/serialization_test.rb
@@ -3,7 +3,7 @@ require 'fixtures/contact'
class SerializationTest < ActiveSupport::TestCase
FORMATS = [ :xml, :json ]
-
+
def setup
@contact_attributes = {
:name => 'aaron stack',
@@ -16,12 +16,12 @@ class SerializationTest < ActiveSupport::TestCase
@contact = Contact.new(@contact_attributes)
end
-
+
def test_serialize_should_be_reversible
for format in FORMATS
@serialized = Contact.new.send("to_#{format}")
contact = Contact.new.send("from_#{format}", @serialized)
-
+
assert_equal @contact_attributes.keys.collect(&:to_s).sort, contact.attributes.keys.collect(&:to_s).sort, "For #{format}"
end
end
diff --git a/activerecord/test/synonym_test_oracle.rb b/activerecord/test/cases/synonym_test_oracle.rb
index 2eff36b097..c053bacb69 100644
--- a/activerecord/test/synonym_test_oracle.rb
+++ b/activerecord/test/cases/synonym_test_oracle.rb
@@ -13,5 +13,5 @@ class TestOracleSynonym < ActiveSupport::TestCase
subject = Subject.new
assert_equal(topic.attributes, subject.attributes)
end
-
+
end
diff --git a/activerecord/test/table_name_test_sqlserver.rb b/activerecord/test/cases/table_name_test_sqlserver.rb
index f52a3da5fb..f52a3da5fb 100644
--- a/activerecord/test/table_name_test_sqlserver.rb
+++ b/activerecord/test/cases/table_name_test_sqlserver.rb
diff --git a/activerecord/test/threaded_connections_test.rb b/activerecord/test/cases/threaded_connections_test.rb
index 85cb1d5154..ec90df5294 100644
--- a/activerecord/test/threaded_connections_test.rb
+++ b/activerecord/test/cases/threaded_connections_test.rb
@@ -13,7 +13,7 @@ unless %w(FrontBase).include? ActiveRecord::Base.connection.adapter_name
@connections = []
@allow_concurrency = ActiveRecord::Base.allow_concurrency
end
-
+
def teardown
# clear the connection cache
ActiveRecord::Base.send(:clear_all_cached_connections!)
@@ -22,11 +22,11 @@ unless %w(FrontBase).include? ActiveRecord::Base.connection.adapter_name
# reestablish old connection
ActiveRecord::Base.establish_connection(@connection)
end
-
+
def gather_connections(use_threaded_connections)
ActiveRecord::Base.allow_concurrency = use_threaded_connections
ActiveRecord::Base.establish_connection(@connection)
-
+
5.times do
Thread.new do
Topic.find :first
diff --git a/activerecord/test/transactions_test.rb b/activerecord/test/cases/transactions_test.rb
index f36ee3f4bb..f36ee3f4bb 100644
--- a/activerecord/test/transactions_test.rb
+++ b/activerecord/test/cases/transactions_test.rb
diff --git a/activerecord/test/unconnected_test.rb b/activerecord/test/cases/unconnected_test.rb
index 6f475f8364..6f475f8364 100755
--- a/activerecord/test/unconnected_test.rb
+++ b/activerecord/test/cases/unconnected_test.rb
diff --git a/activerecord/test/validations_test.rb b/activerecord/test/cases/validations_test.rb
index daec199be1..daec199be1 100755
--- a/activerecord/test/validations_test.rb
+++ b/activerecord/test/cases/validations_test.rb
diff --git a/activerecord/test/xml_serialization_test.rb b/activerecord/test/cases/xml_serialization_test.rb
index 2db75fad46..2db75fad46 100644
--- a/activerecord/test/xml_serialization_test.rb
+++ b/activerecord/test/cases/xml_serialization_test.rb
diff --git a/activerecord/test/connections/native_db2/connection.rb b/activerecord/test/connections/native_db2/connection.rb
index 921ac28109..324315d2c8 100644
--- a/activerecord/test/connections/native_db2/connection.rb
+++ b/activerecord/test/connections/native_db2/connection.rb
@@ -1,5 +1,5 @@
print "Using native DB2\n"
-require_dependency 'fixtures/course'
+require_dependency 'models/course'
require 'logger'
ActiveRecord::Base.logger = Logger.new("debug.log")
diff --git a/activerecord/test/connections/native_firebird/connection.rb b/activerecord/test/connections/native_firebird/connection.rb
index c198a99869..67a936ca97 100644
--- a/activerecord/test/connections/native_firebird/connection.rb
+++ b/activerecord/test/connections/native_firebird/connection.rb
@@ -1,5 +1,5 @@
print "Using native Firebird\n"
-require_dependency 'fixtures/course'
+require_dependency 'models/course'
require 'logger'
ActiveRecord::Base.logger = Logger.new("debug.log")
diff --git a/activerecord/test/connections/native_frontbase/connection.rb b/activerecord/test/connections/native_frontbase/connection.rb
index 11dd8d275d..c01d864a8b 100644
--- a/activerecord/test/connections/native_frontbase/connection.rb
+++ b/activerecord/test/connections/native_frontbase/connection.rb
@@ -1,5 +1,5 @@
puts 'Using native Frontbase'
-require_dependency 'fixtures/course'
+require_dependency 'models/course'
require 'logger'
ActiveRecord::Base.logger = Logger.new("debug.log")
diff --git a/activerecord/test/connections/native_mysql/connection.rb b/activerecord/test/connections/native_mysql/connection.rb
index 64539248d2..1fab444e58 100644
--- a/activerecord/test/connections/native_mysql/connection.rb
+++ b/activerecord/test/connections/native_mysql/connection.rb
@@ -1,5 +1,5 @@
print "Using native MySQL\n"
-require_dependency 'fixtures/course'
+require_dependency 'models/course'
require 'logger'
RAILS_DEFAULT_LOGGER = Logger.new('debug.log')
diff --git a/activerecord/test/connections/native_openbase/connection.rb b/activerecord/test/connections/native_openbase/connection.rb
index deaa73d347..655cb9ca26 100644
--- a/activerecord/test/connections/native_openbase/connection.rb
+++ b/activerecord/test/connections/native_openbase/connection.rb
@@ -1,5 +1,5 @@
print "Using native OpenBase\n"
-require_dependency 'fixtures/course'
+require_dependency 'models/course'
require 'logger'
ActiveRecord::Base.logger = Logger.new("debug.log")
diff --git a/activerecord/test/connections/native_oracle/connection.rb b/activerecord/test/connections/native_oracle/connection.rb
index e127e36675..0954b27f87 100644
--- a/activerecord/test/connections/native_oracle/connection.rb
+++ b/activerecord/test/connections/native_oracle/connection.rb
@@ -1,5 +1,5 @@
print "Using Oracle\n"
-require_dependency 'fixtures/course'
+require_dependency 'models/course'
require 'logger'
ActiveRecord::Base.logger = Logger.new STDOUT
diff --git a/activerecord/test/connections/native_postgresql/connection.rb b/activerecord/test/connections/native_postgresql/connection.rb
index a75fc6e2ae..d644441fcc 100644
--- a/activerecord/test/connections/native_postgresql/connection.rb
+++ b/activerecord/test/connections/native_postgresql/connection.rb
@@ -1,5 +1,5 @@
print "Using native PostgreSQL\n"
-require_dependency 'fixtures/course'
+require_dependency 'models/course'
require 'logger'
ActiveRecord::Base.logger = Logger.new("debug.log")
diff --git a/activerecord/test/connections/native_sqlite/connection.rb b/activerecord/test/connections/native_sqlite/connection.rb
index 8ccce494f7..124cae43b9 100644
--- a/activerecord/test/connections/native_sqlite/connection.rb
+++ b/activerecord/test/connections/native_sqlite/connection.rb
@@ -1,5 +1,5 @@
print "Using native SQlite\n"
-require_dependency 'fixtures/course'
+require_dependency 'models/course'
require 'logger'
ActiveRecord::Base.logger = Logger.new("debug.log")
diff --git a/activerecord/test/connections/native_sqlite3/connection.rb b/activerecord/test/connections/native_sqlite3/connection.rb
index 46ef909775..c0cfaadcfa 100644
--- a/activerecord/test/connections/native_sqlite3/connection.rb
+++ b/activerecord/test/connections/native_sqlite3/connection.rb
@@ -1,5 +1,5 @@
print "Using native SQLite3\n"
-require_dependency 'fixtures/course'
+require_dependency 'models/course'
require 'logger'
ActiveRecord::Base.logger = Logger.new("debug.log")
diff --git a/activerecord/test/connections/native_sqlite3/in_memory_connection.rb b/activerecord/test/connections/native_sqlite3/in_memory_connection.rb
index a33f44e5fa..b7b348b4db 100644
--- a/activerecord/test/connections/native_sqlite3/in_memory_connection.rb
+++ b/activerecord/test/connections/native_sqlite3/in_memory_connection.rb
@@ -1,5 +1,5 @@
print "Using native SQLite3\n"
-require_dependency 'fixtures/course'
+require_dependency 'models/course'
require 'logger'
ActiveRecord::Base.logger = Logger.new("debug.log")
diff --git a/activerecord/test/connections/native_sybase/connection.rb b/activerecord/test/connections/native_sybase/connection.rb
index ec3e9ebfc3..3282d26922 100644
--- a/activerecord/test/connections/native_sybase/connection.rb
+++ b/activerecord/test/connections/native_sybase/connection.rb
@@ -1,5 +1,5 @@
print "Using native Sybase Open Client\n"
-require_dependency 'fixtures/course'
+require_dependency 'models/course'
require 'logger'
ActiveRecord::Base.logger = Logger.new("debug.log")