bug fixes in couchapp

This commit is contained in:
Chris Anderson 2008-09-16 12:10:45 -04:00
parent 92f4871696
commit 38462375b4
4 changed files with 21 additions and 4 deletions

View file

@ -30,11 +30,14 @@ when /generate/
when /push/
dirname = ARGV.shift
current = Dir.getwd
dir = File.expand_path(File.join(current, dirname))
dirapp = File.split(dir).last
if ARGV.length == 2
appname = ARGV.shift
dbstring = ARGV.shift
elsif ARGV.length == 1
appname = dirname
appname = dirapp
dbstring = ARGV.shift
else
puts opts
@ -43,7 +46,7 @@ when /push/
end
dbspec = CouchRest.parse(dbstring)
fm = CouchRest::FileManager.new(dbspec[:database], dbspec[:host])
fm.push_app(dirname, appname)
fm.push_app(dir, appname)
when /pull/
else

View file

@ -1,7 +1,7 @@
// example reduce function to count the
// number of rows in a given key range.
function(keys, value, rereduce) {
function(keys, values, rereduce) {
if (rereduce) {
return sum(values);
} else {

View file

@ -16,7 +16,7 @@
var dbname = document.location.href.split('/')[3];
var design = unescape(document.location.href.split('/')[4]).split('/')[1];
var DB = $.couch.db(dbname);
DB.view(design+"/example-map",{success: function(json) {
DB.view(design+"/example",{success: function(json) {
$("#view").html(json.rows.map(function(row) {
return '<li>'+row.key+'</li>';
}).join(''));

View file

@ -51,6 +51,20 @@ describe "couchapp" do
end
end
describe "push . #{TESTDB}" do
before(:all) do
@cr = CouchRest.new(COUCHHOST)
@db = @cr.database(TESTDB)
@db.delete! rescue nil
@db = @cr.create_db(TESTDB) rescue nil
`#{@run} generate my-app`
end
it "should create the design document" do
`cd #{@fixdir}/my-app && #{@couchapp} push . #{TESTDB}`
lambda{@db.get("_design/my-app")}.should_not raise_error
end
end
describe "push my-app my-design #{TESTDB}" do
before(:all) do
@cr = CouchRest.new(COUCHHOST)