aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-09-04 07:08:16 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-09-04 07:08:16 +0000
commite2a397ff8a5e58cdd40663342d0256ffd3c6324a (patch)
tree31888b9b50086325ac33b525338571c168c51b95
parentf3d6726dfa3efdb895a85f5e2f72e7b430b788e9 (diff)
downloadrails-e2a397ff8a5e58cdd40663342d0256ffd3c6324a.tar.gz
rails-e2a397ff8a5e58cdd40663342d0256ffd3c6324a.tar.bz2
rails-e2a397ff8a5e58cdd40663342d0256ffd3c6324a.zip
Deprecation: use :dependent => :delete_all rather than :exclusively_dependent => true. Closes #6024.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4981 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/associations.rb2
-rwxr-xr-xactiverecord/test/associations_test.rb8
-rw-r--r--activerecord/test/reflection_test.rb4
4 files changed, 12 insertions, 4 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index a51c3460a4..c316f3b66d 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Deprecation: use :dependent => :delete_all rather than :exclusively_dependent => true. #6024 [Josh Susser]
+
* Document validates_presences_of behavior with booleans: you probably want validates_inclusion_of :attr, :in => [true, false]. #2253 [Bob Silva]
* Optimistic locking: gracefully handle nil versions, treat as zero. #5908 [Tom Ward]
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index b2ea56be4c..0771f26218 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -991,7 +991,7 @@ module ActiveRecord
if reflection.options[:exclusively_dependent]
reflection.options[:dependent] = :delete_all
- #warn "The :exclusively_dependent option is deprecated. Please use :dependent => :delete_all instead.")
+ ::ActiveSupport::Deprecation.warn("The :exclusively_dependent option is deprecated and will be removed from Rails 2.0. Please use :dependent => :delete_all instead. See http://www.rubyonrails.org/deprecation for details.", caller)
end
# See HasManyAssociation#delete_records. Dependent associations
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index ede0e399c0..b6ffda8105 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -178,7 +178,13 @@ class HasOneAssociationsTest < Test::Unit::TestCase
assert_equal num_accounts - 1, Account.count
assert_equal [account_id], Account.destroyed_account_ids[firm.id]
end
-
+
+ def test_deprecated_exclusive_dependence
+ assert_deprecated(/:exclusively_dependent.*:dependent => :delete_all/) do
+ Firm.has_many :deprecated_exclusively_dependent_clients, :class_name => 'Client', :exclusively_dependent => true
+ end
+ end
+
def test_exclusive_dependence
num_accounts = Account.count
firm = ExclusivelyDependentFirm.find(9)
diff --git a/activerecord/test/reflection_test.rb b/activerecord/test/reflection_test.rb
index 86fb083348..76e42860fb 100644
--- a/activerecord/test/reflection_test.rb
+++ b/activerecord/test/reflection_test.rb
@@ -143,8 +143,8 @@ class ReflectionTest < Test::Unit::TestCase
end
def test_reflection_of_all_associations
- assert_equal 15, Firm.reflect_on_all_associations.size
- assert_equal 13, Firm.reflect_on_all_associations(:has_many).size
+ assert_equal 16, Firm.reflect_on_all_associations.size
+ assert_equal 14, Firm.reflect_on_all_associations(:has_many).size
assert_equal 2, Firm.reflect_on_all_associations(:has_one).size
assert_equal 0, Firm.reflect_on_all_associations(:belongs_to).size
end