mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Deprecated the AssociationCollection constant
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user