1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Simplify query conditions a bit in nested attributes test

Also refactor the test a bit.
This commit is contained in:
Carlos Antonio da Silva 2012-11-03 19:51:52 -02:00
parent 51b901408e
commit 66bcaff062

View file

@ -464,17 +464,15 @@ class TestNestedAttributesOnABelongsToAssociation < ActiveRecord::TestCase
end
def test_should_unset_association_when_an_existing_record_is_destroyed
@ship.reload
original_pirate_id = @ship.pirate.id
@ship.attributes = {:pirate_attributes => {:id => @ship.pirate.id, :_destroy => true}}
@ship.save!
@ship.update_attributes! pirate_attributes: { id: @ship.pirate.id, _destroy: true }
assert_empty Pirate.where(["id = ?", original_pirate_id])
assert_empty Pirate.where(id: original_pirate_id)
assert_nil @ship.pirate_id
assert_nil @ship.pirate
@ship.reload
assert_empty Pirate.where(["id = ?", original_pirate_id])
assert_empty Pirate.where(id: original_pirate_id)
assert_nil @ship.pirate_id
assert_nil @ship.pirate
end