Permalink
Browse files

Simplify query conditions a bit in nested attributes test

Also refactor the test a bit.
  • Loading branch information...
carlosantoniodasilva committed Nov 3, 2012
1 parent 51b9014 commit 66bcaff0620e0b4ba1c7cc711f356007a65d12ec
Showing with 3 additions and 5 deletions.
  1. +3 −5 activerecord/test/cases/nested_attributes_test.rb
@@ -464,17 +464,15 @@ def test_should_destroy_an_existing_record_if_there_is_a_matching_id_and_destroy
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

0 comments on commit 66bcaff

Please sign in to comment.