Deprecated the AssociationCollection constant

This commit is contained in:
Jon Leighton
2011-07-16 14:21:53 +01:00
parent 0f37def4bb
commit fb95dee926
3 changed files with 34 additions and 0 deletions

View File

@@ -1,5 +1,13 @@
*Rails 3.1.0 (unreleased)*
* Deprecated the AssociationCollection constant. CollectionProxy is now the appropriate constant
to use, though be warned that this is not really a public API.
This should solve upgrade problems with the will_paginate plugin (and perhaps others). Thanks
Paul Battley for reporting.
[Jon Leighton]
* ActiveRecord::MacroReflection::AssociationReflection#build_record has a new method signature.
Before: def build_association(*options)

View File

@@ -1,5 +1,12 @@
require 'active_support/deprecation'
module ActiveRecord
module Associations
AssociationCollection = ActiveSupport::Deprecation::DeprecatedConstantProxy.new(
'ActiveRecord::Associations::AssociationCollection',
'ActiveRecord::Associations::CollectionProxy'
)
# Association proxies in Active Record are middlemen between the object that
# holds the association, known as the <tt>@owner</tt>, and the actual associated
# object, known as the <tt>@target</tt>. The kind of association any proxy is

View File

@@ -1599,4 +1599,23 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
undef_method :old_build_association
end
end
def test_AssociationCollection_deprecated
assert_deprecated do
ActiveRecord::Associations::AssociationCollection.class_eval do
def foo
"bar"
end
end
end
author = Author.new
assert_equal "bar", author.posts.foo
ensure
ActiveSupport::Deprecation.silence do
ActiveRecord::Associations::AssociationCollection.class_eval do
undef_method :foo
end
end
end
end