fixed a typo in the previous commit

This commit is contained in:
Matt Aimonetti 2009-03-02 22:36:57 -08:00
parent d383c5a7d4
commit 7455152f63
3 changed files with 22 additions and 7 deletions

View file

@ -22,6 +22,7 @@ $:.unshift File.dirname(__FILE__) unless
$:.include?(File.dirname(__FILE__)) ||
$:.include?(File.expand_path(File.dirname(__FILE__)))
$COUCHREST_DEBUG ||= false
require 'couchrest/monkeypatches'
@ -129,7 +130,11 @@ module CouchRest
begin
JSON.parse(RestClient.put(uri, payload))
rescue Exception => e
if $COUCHREST_DEBUG == true
raise "Error while sending a PUT request #{uri}\npayload: #{payload.inspect}\n#{e}"
else
raise e
end
end
end
@ -137,7 +142,11 @@ module CouchRest
begin
JSON.parse(RestClient.get(uri), :max_nesting => false)
rescue => e
if $COUCHREST_DEBUG == true
raise "Error while sending a GET request #{uri}\n: #{e}"
else
raise e
end
end
end
@ -146,7 +155,11 @@ module CouchRest
begin
JSON.parse(RestClient.post(uri, payload))
rescue Exception => e
if $COUCHREST_DEBUG == true
raise "Error while sending a POST request #{uri}\npayload: #{payload.inspect}\n#{e}"
else
raise e
end
end
end

View file

@ -133,9 +133,8 @@ module CouchRest
fetch_view(name, opts, &block)
else
begin
# auto load mentioned documents unless asked differently
opts.merge({:include_docs => true}) unless opts.has_key?(:include_docs)
view = fetch_view name, opts, &block
# auto load mentioned documents unless asked differently (didn't use merge! on a previous line to avoid duping the object)
view = fetch_view name, (opts.has_key?(:include_docs) ? opts : opts.merge({:include_docs => true})), &block
view['rows'].collect{|r|new(r['doc'])} if view['rows']
rescue
# fallback for old versions of couchdb that don't

View file

@ -105,6 +105,9 @@ describe "ExtendedDocument views" do
describe "a model with a compound key view" do
before(:all) do
Article.design_doc_fresh = false
Article.by_user_id_and_date.each{|a| a.destroy(true)}
Article.database.bulk_delete
written_at = Time.now - 24 * 3600 * 7
@titles = ["uniq one", "even more interesting", "less fun", "not junk"]
@user_ids = ["quentin", "aaron"]