dont save over an existing design doc

This commit is contained in:
Chris Anderson 2008-10-02 21:21:48 -07:00
parent 428d304438
commit c170008deb
2 changed files with 40 additions and 7 deletions

View file

@ -336,7 +336,7 @@ describe CouchRest::Model do
it "should create the design doc" do
Article.by_date rescue nil
doc = Article.database.get("_design/Article")
doc = Article.design_doc
doc['views']['by_date'].should_not be_nil
end
@ -371,7 +371,7 @@ describe CouchRest::Model do
end
it "should create the design doc" do
Article.by_user_id_and_date rescue nil
doc = Article.database.get("_design/Article")
doc = Article.design_doc
doc['views']['by_date'].should_not be_nil
end
it "should sort correctly" do
@ -412,6 +412,24 @@ describe CouchRest::Model do
end
end
describe "adding a view" do
before(:each) do
Article.by_date
@design_docs = Article.database.documents :startkey => "_design/", :endkey => "_design/\u9999"
end
it "should not create a design doc on view definition" do
Article.view_by :created_at
newdocs = Article.database.documents :startkey => "_design/", :endkey => "_design/\u9999"
newdocs["rows"].length.should == @design_docs["rows"].length
end
it "should create a new design document on view access" do
Article.view_by :created_at
Article.by_created_at
newdocs = Article.database.documents :startkey => "_design/", :endkey => "_design/\u9999"
newdocs["rows"].length.should == @design_docs["rows"].length + 1
end
end
describe "destroying an instance" do
before(:each) do
@obj = Basic.new