From 413e35feddd8f86d16bfdab6b8291986ba2a8014 Mon Sep 17 00:00:00 2001 From: Doug Orleans Date: Mon, 3 Sep 2012 02:29:42 -0400 Subject: [PATCH] Add failing test for destroyed records. Also, generalize the previous test to use persisted? rather than !new_record?. --- test/import_test.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/import_test.rb b/test/import_test.rb index d9440bf..cc06891 100644 --- a/test/import_test.rb +++ b/test/import_test.rb @@ -135,7 +135,17 @@ describe "#import" do it "reloads data for existing in-memory instances" do Topic.import(new_topics, :synchronize => new_topics, :synchronize_keys => [:title] ) - assert !new_topics.any?(&:new_record?), "Records should have been reloaded" + assert new_topics.all?(&:persisted?), "Records should have been reloaded" + end + end + + context "synchronizing on destroyed records with explicit conditions" do + let(:new_topics) { Generate(3, :topics) } + + it "reloads data for existing in-memory instances" do + new_topics.each &:destroy + Topic.import(new_topics, :synchronize => new_topics, :synchronize_keys => [:title] ) + assert new_topics.all?(&:persisted?), "Records should have been reloaded" end end end