diff --git a/lib/couchrest/helper/file_manager.rb b/lib/couchrest/helper/file_manager.rb index c491dfb..bf1fb66 100644 --- a/lib/couchrest/helper/file_manager.rb +++ b/lib/couchrest/helper/file_manager.rb @@ -213,10 +213,9 @@ module CouchRest myfield = fields while farray.length > 1 front = farray.shift - myfield[front] = {} + myfield[front] ||= {} myfield = myfield[front] end - # todo: json fname, fext = farray.shift.split('.') fguts = File.open(file).read if fext == 'json' @@ -227,7 +226,6 @@ module CouchRest end if File.exists?("#{appdir}/doc.json") default_json = JSON.parse(File.open("#{appdir}/doc.json").read) - end design = @db.get(docid) rescue {} design.merge!(fields) diff --git a/spec/couchrest/helpers/file_manager_spec.rb b/spec/couchrest/helpers/file_manager_spec.rb index 37bb27b..7e6d4db 100644 --- a/spec/couchrest/helpers/file_manager_spec.rb +++ b/spec/couchrest/helpers/file_manager_spec.rb @@ -82,10 +82,15 @@ describe CouchRest::FileManager, "pushing an app" do doc = @db.get("_design/couchapp") doc['_attachments']['index.html']["content_type"].should == 'text/html' end - it "should push bar.txt" do + it "should push bar.txt and pals" do + File.open("#{@appdir}/foo/test.json",'w') do |f| + f.write("[1,2,3,4]") + end + r = @fm.push_app(@appdir, "couchapp") doc = @db.get("_design/couchapp") doc["foo"].should_not be_nil doc["foo"]["bar"].should include("Couchapp will") + doc["foo"]["test"].should == [1,2,3,4] end it "should push json as json" do File.open("#{@appdir}/test.json",'w') do |f|