Created
May 9, 2011 20:20
-
-
Save miloops/963301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_does_not_delete_association_if_it_was_removed | |
author_address = AuthorAddress.first | |
author = author_address.author | |
author.author_address_id = nil | |
assert author.save | |
author.destroy | |
assert AuthorAddress.find(author_address.id) | |
assert_raise(ActiveRecord::RecordNotFound) { Author.find(author.id) } | |
end | |
def test_does_not_delete_association_if_it_was_removed_on_has_many | |
firm = Firm.first | |
client = firm.clients.build :name => "Dharma Initiative" | |
assert client.save | |
client.firm_id = nil | |
assert client.save | |
assert Firm.find(firm.id) | |
same_client = Client.find(client.id) | |
assert_nil same_client.firm | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment