From ca7ff6086e775b69869be009725449533428d311 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Wed, 31 Dec 2014 14:11:30 -0500 Subject: [PATCH] Exclude docs without a db file from the manifest --- lib/docs/core/manifest.rb | 2 +- test/lib/docs/core/manifest_test.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/docs/core/manifest.rb b/lib/docs/core/manifest.rb index 5cfc55a5..2c04b2b0 100644 --- a/lib/docs/core/manifest.rb +++ b/lib/docs/core/manifest.rb @@ -27,7 +27,7 @@ module Docs def indexed_docs @docs.select do |doc| - @store.exist? doc.index_path + @store.exist?(doc.index_path) && @store.exist?(doc.db_path) end end end diff --git a/test/lib/docs/core/manifest_test.rb b/test/lib/docs/core/manifest_test.rb index cb02e259..7b22a25e 100644 --- a/test/lib/docs/core/manifest_test.rb +++ b/test/lib/docs/core/manifest_test.rb @@ -57,9 +57,10 @@ class ManifestTest < MiniTest::Spec assert_instance_of Array, manifest.as_json end - context "when the doc has an index" do + context "when the doc has an index and a db" do before do stub(store).exist?(index_path) { true } + stub(store).exist?(db_path) { true } end 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 it "doesn't include the doc" do + stub(store).exist?(db_path) { true } stub(store).exist?(index_path) { false } assert_empty manifest.as_json 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 describe "#to_json" do