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:
parent
51b901408e
commit
66bcaff062
1 changed files with 3 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue