Browse Source

Exclude docs without a db file from the manifest

Thibaut 11 years ago
parent
commit
ca7ff6086e
2 changed files with 12 additions and 2 deletions
  1. 1 1
      lib/docs/core/manifest.rb
  2. 11 1
      test/lib/docs/core/manifest_test.rb

+ 1 - 1
lib/docs/core/manifest.rb

@@ -27,7 +27,7 @@ module Docs
 
 
     def indexed_docs
     def indexed_docs
       @docs.select do |doc|
       @docs.select do |doc|
-        @store.exist? doc.index_path
+        @store.exist?(doc.index_path) && @store.exist?(doc.db_path)
       end
       end
     end
     end
   end
   end

+ 11 - 1
test/lib/docs/core/manifest_test.rb

@@ -57,9 +57,10 @@ class ManifestTest < MiniTest::Spec
       assert_instance_of Array, manifest.as_json
       assert_instance_of Array, manifest.as_json
     end
     end
 
 
-    context "when the doc has an index" do
+    context "when the doc has an index and a db" do
       before do
       before do
         stub(store).exist?(index_path) { true }
         stub(store).exist?(index_path) { true }
+        stub(store).exist?(db_path) { true }
       end
       end
 
 
       it "includes the doc's JSON representation" do
       it "includes the doc's JSON representation" do
@@ -77,10 +78,19 @@ class ManifestTest < MiniTest::Spec
 
 
     context "when the doc doesn't have an index" do
     context "when the doc doesn't have an index" do
       it "doesn't include the doc" do
       it "doesn't include the doc" do
+        stub(store).exist?(db_path) { true }
         stub(store).exist?(index_path) { false }
         stub(store).exist?(index_path) { false }
         assert_empty manifest.as_json
         assert_empty manifest.as_json
       end
       end
     end
     end
+
+    context "when the doc doesn't have a db" do
+      it "doesn't include the doc" do
+        stub(store).exist?(index_path) { true }
+        stub(store).exist?(db_path) { false }
+        assert_empty manifest.as_json
+      end
+    end
   end
   end
 
 
   describe "#to_json" do
   describe "#to_json" do