提交 f1217c60 编写于 作者: R Ryuta Kamizono

No need to cache collection proxies separately

Because merging the association scope was removed.
上级 d1e0f11b
......@@ -38,13 +38,7 @@ def reader(force_reload = false)
reload
end
if null_scope?
# Cache the proxy separately before the owner has an id
# or else a post-save proxy will still lack the id
@null_proxy ||= CollectionProxy.create(klass, self)
else
@proxy ||= CollectionProxy.create(klass, self)
end
CollectionProxy.create(klass, self)
end
# Implements the writer method, e.g. foo.items= for Foo.has_many :items
......
......@@ -611,21 +611,16 @@ def test_finding_using_primary_key
def test_update_all_on_association_accessed_before_save
firm = Firm.new(name: "Firm")
clients_proxy_id = firm.clients.object_id
firm.clients << Client.first
firm.save!
assert_equal firm.clients.count, firm.clients.update_all(description: "Great!")
assert_not_equal clients_proxy_id, firm.clients.object_id
end
def test_update_all_on_association_accessed_before_save_with_explicit_foreign_key
# We can use the same cached proxy object because the id is available for the scope
firm = Firm.new(name: "Firm", id: 100)
clients_proxy_id = firm.clients.object_id
firm.clients << Client.first
firm.save!
assert_equal firm.clients.count, firm.clients.update_all(description: "Great!")
assert_equal clients_proxy_id, firm.clients.object_id
end
def test_belongs_to_sanity
......
......@@ -233,11 +233,6 @@ def test_scoped_allows_conditions
assert_equal david.projects, david.projects.scope
end
test "proxy object is cached" do
david = developers(:david)
assert david.projects.equal?(david.projects)
end
test "inverses get set of subsets of the association" do
man = Man.create
man.interests.create
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册