added attachment uploading
This commit is contained in:
parent
baa2c1dd37
commit
7f818c2cf1
|
@ -47,6 +47,8 @@ module CouchRest
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
doc["signatures"] ||= {}
|
||||||
|
doc["_attachments"] ||= {}
|
||||||
# remove deleted docs
|
# remove deleted docs
|
||||||
to_be_removed = doc["signatures"].keys.select do |d|
|
to_be_removed = doc["signatures"].keys.select do |d|
|
||||||
!pushfiles.collect{|p| p.keys.first}.include?(d)
|
!pushfiles.collect{|p| p.keys.first}.include?(d)
|
||||||
|
@ -69,7 +71,6 @@ module CouchRest
|
||||||
doc["_attachments"][path].delete("length")
|
doc["_attachments"][path].delete("length")
|
||||||
doc["_attachments"][path]["data"] = @attachments[path]["data"]
|
doc["_attachments"][path]["data"] = @attachments[path]["data"]
|
||||||
doc["_attachments"][path].merge!({"data" => @attachments[path]["data"]} )
|
doc["_attachments"][path].merge!({"data" => @attachments[path]["data"]} )
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -190,12 +191,14 @@ module CouchRest
|
||||||
viewdir = File.join(appdir,"views")
|
viewdir = File.join(appdir,"views")
|
||||||
attachdir = File.join(appdir,"attachments")
|
attachdir = File.join(appdir,"attachments")
|
||||||
views, lang = read_design_views(viewdir)
|
views, lang = read_design_views(viewdir)
|
||||||
|
# attachments = read_attachments(attachdir)
|
||||||
docid = "_design/#{appname}"
|
docid = "_design/#{appname}"
|
||||||
design = @db.get(docid) rescue {}
|
design = @db.get(docid) rescue {}
|
||||||
design['_id'] = docid
|
design['_id'] = docid
|
||||||
design['views'] = views
|
design['views'] = views
|
||||||
design['language'] = lang
|
design['language'] = lang
|
||||||
@db.save(design)
|
@db.save(design)
|
||||||
|
push_directory(attachdir, docid)
|
||||||
# puts views.inspect
|
# puts views.inspect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,16 @@ describe "couchapp" do
|
||||||
`#{@run} push my-app #{TESTDB}`
|
`#{@run} push my-app #{TESTDB}`
|
||||||
lambda{@db.get("_design/my-app")}.should_not raise_error
|
lambda{@db.get("_design/my-app")}.should_not raise_error
|
||||||
end
|
end
|
||||||
|
it "should create the views" do
|
||||||
|
`#{@run} push my-app #{TESTDB}`
|
||||||
|
doc = @db.get("_design/my-app")
|
||||||
|
doc['views']['example']['map'].should match(/function/)
|
||||||
|
end
|
||||||
|
it "should create the index" do
|
||||||
|
`#{@run} push my-app #{TESTDB}`
|
||||||
|
doc = @db.get("_design/my-app")
|
||||||
|
doc['_attachments']['index.html']["content_type"].should == 'text/html'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "push my-app my-design #{TESTDB}" do
|
describe "push my-app my-design #{TESTDB}" do
|
||||||
|
@ -50,7 +60,8 @@ describe "couchapp" do
|
||||||
`#{@run} generate my-app`
|
`#{@run} generate my-app`
|
||||||
end
|
end
|
||||||
it "should create the design document" do
|
it "should create the design document" do
|
||||||
|
`#{@run} push my-app my-design #{TESTDB}`
|
||||||
|
lambda{@db.get("_design/my-design")}.should_not raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -67,6 +67,14 @@ describe CouchRest::FileManager, "pushing an app" do
|
||||||
it "should create a design document" do
|
it "should create a design document" do
|
||||||
lambda{@db.get("_design/couchapp")}.should_not raise_error
|
lambda{@db.get("_design/couchapp")}.should_not raise_error
|
||||||
end
|
end
|
||||||
|
it "should create the views" do
|
||||||
|
doc = @db.get("_design/couchapp")
|
||||||
|
doc['views']['example']['map'].should match(/function/)
|
||||||
|
end
|
||||||
|
it "should create the index" do
|
||||||
|
doc = @db.get("_design/couchapp")
|
||||||
|
doc['_attachments']['index.html']["content_type"].should == 'text/html'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue