mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
load_target
is a public method
`send` is unnecessary.
This commit is contained in:
parent
1ca571cc47
commit
beb6b7add7
3 changed files with 5 additions and 7 deletions
|
@ -15,7 +15,7 @@ module ActiveRecord
|
|||
ensure_not_nested
|
||||
|
||||
through_proxy = owner.association(through_reflection.name)
|
||||
through_record = through_proxy.send(:load_target)
|
||||
through_record = through_proxy.load_target
|
||||
|
||||
if through_record && !record
|
||||
through_record.destroy
|
||||
|
|
|
@ -45,7 +45,6 @@ class AssociationsTest < ActiveRecord::TestCase
|
|||
ship = Ship.create!(:name => "The good ship Dollypop")
|
||||
part = ship.parts.create!(:name => "Mast")
|
||||
part.mark_for_destruction
|
||||
ship.parts.send(:load_target)
|
||||
assert ship.parts[0].marked_for_destruction?
|
||||
end
|
||||
|
||||
|
@ -54,7 +53,6 @@ class AssociationsTest < ActiveRecord::TestCase
|
|||
part = ship.parts.create!(:name => "Mast")
|
||||
part.mark_for_destruction
|
||||
ShipPart.find(part.id).update_columns(name: 'Deck')
|
||||
ship.parts.send(:load_target)
|
||||
assert_equal 'Deck', ship.parts[0].name
|
||||
end
|
||||
|
||||
|
|
|
@ -642,13 +642,13 @@ module NestedAttributesOnACollectionAssociationTests
|
|||
def test_should_not_overwrite_unsaved_updates_when_loading_association
|
||||
@pirate.reload
|
||||
@pirate.send(association_setter, [{ :id => @child_1.id, :name => 'Grace OMalley' }])
|
||||
assert_equal 'Grace OMalley', @pirate.send(@association_name).send(:load_target).find { |r| r.id == @child_1.id }.name
|
||||
assert_equal 'Grace OMalley', @pirate.send(@association_name).load_target.find { |r| r.id == @child_1.id }.name
|
||||
end
|
||||
|
||||
def test_should_preserve_order_when_not_overwriting_unsaved_updates
|
||||
@pirate.reload
|
||||
@pirate.send(association_setter, [{ :id => @child_1.id, :name => 'Grace OMalley' }])
|
||||
assert_equal @child_1.id, @pirate.send(@association_name).send(:load_target).first.id
|
||||
assert_equal @child_1.id, @pirate.send(@association_name).load_target.first.id
|
||||
end
|
||||
|
||||
def test_should_refresh_saved_records_when_not_overwriting_unsaved_updates
|
||||
|
@ -657,13 +657,13 @@ module NestedAttributesOnACollectionAssociationTests
|
|||
@pirate.send(@association_name) << record
|
||||
record.save!
|
||||
@pirate.send(@association_name).last.update!(name: 'Polly')
|
||||
assert_equal 'Polly', @pirate.send(@association_name).send(:load_target).last.name
|
||||
assert_equal 'Polly', @pirate.send(@association_name).load_target.last.name
|
||||
end
|
||||
|
||||
def test_should_not_remove_scheduled_destroys_when_loading_association
|
||||
@pirate.reload
|
||||
@pirate.send(association_setter, [{ :id => @child_1.id, :_destroy => '1' }])
|
||||
assert @pirate.send(@association_name).send(:load_target).find { |r| r.id == @child_1.id }.marked_for_destruction?
|
||||
assert @pirate.send(@association_name).load_target.find { |r| r.id == @child_1.id }.marked_for_destruction?
|
||||
end
|
||||
|
||||
def test_should_take_a_hash_with_composite_id_keys_and_assign_the_attributes_to_the_associated_models
|
||||
|
|
Loading…
Reference in a new issue