removed the suffix and duplication when importing views

This commit is contained in:
Frederik Fix 2008-12-29 11:06:37 +01:00 committed by Chris Anderson
parent c488aab338
commit cae6395007
2 changed files with 10 additions and 15 deletions

View file

@ -124,18 +124,13 @@ module CouchRest
libs << "\n"
end
if design_doc_parts.last =~ /-map/
designs[folder]["views"]["#{view_name}-map"] ||= {}
designs[folder]["views"]["#{view_name}-map"]["map"] = read(design_doc, libs)
designs[folder]["views"]["#{view_name}-reduce"] ||= {}
designs[folder]["views"]["#{view_name}-reduce"]["map"] = read(design_doc, libs)
designs[folder]["views"][view_name] ||= {}
designs[folder]["views"][view_name]["map"] = read(design_doc, libs)
end
if design_doc_parts.last =~ /-reduce/
designs[folder]["views"]["#{view_name}-reduce"] ||= {}
designs[folder]["views"]["#{view_name}-reduce"]["reduce"] = read(design_doc, libs)
designs[folder]["views"][view_name] ||= {}
designs[folder]["views"][view_name]["reduce"] = read(design_doc, libs)
end
end

View file

@ -127,16 +127,16 @@ describe CouchRest::FileManager, "pushing views" do
@design["views"].should_not be_nil
end
it "should push a map and reduce view" do
@design["views"]["test-map"].should_not be_nil
@design["views"]["test-reduce"].should_not be_nil
@design["views"]["test"]["map"].should_not be_nil
@design["views"]["test"]["reduce"].should_not be_nil
end
it "should push a map only view" do
@design["views"]["only-map"].should_not be_nil
@design["views"]["only-reduce"].should be_nil
@design["views"]["only"]["map"].should_not be_nil
@design["views"]["only"]["reduce"].should be_nil
end
it "should include library files" do
@design["views"]["only-map"]["map"].should include("globalLib")
@design["views"]["only-map"]["map"].should include("justThisView")
@design["views"]["only"]["map"].should include("globalLib")
@design["views"]["only"]["map"].should include("justThisView")
end
it "should not create extra design docs" do
docs = @db.documents(:startkey => '_design', :endkey => '_design/ZZZZZZ')