fixed a hash bug

This commit is contained in:
Chris Anderson 2008-10-28 10:07:57 -07:00
parent 3f908acce5
commit b37f6a326b
2 changed files with 7 additions and 4 deletions

View file

@ -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)

View file

@ -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|