JSON.unparse is picky compared to to_json... go figure
This commit is contained in:
parent
dc6c9276e5
commit
b93f6e7677
|
@ -39,7 +39,7 @@ class CouchRest
|
|||
|
||||
class << self
|
||||
def put uri, doc = nil
|
||||
payload = JSON.unparse doc if doc
|
||||
payload = doc.to_json if doc
|
||||
JSON.parse(RestClient.put(uri, payload))
|
||||
end
|
||||
|
||||
|
@ -48,7 +48,7 @@ class CouchRest
|
|||
end
|
||||
|
||||
def post uri, doc = nil
|
||||
payload = JSON.unparse doc if doc
|
||||
payload = doc.to_json if doc
|
||||
JSON.parse(RestClient.post(uri, payload))
|
||||
end
|
||||
|
||||
|
@ -59,7 +59,7 @@ class CouchRest
|
|||
def paramify_url url, params = nil
|
||||
if params
|
||||
query = params.collect do |k,v|
|
||||
v = JSON.unparse(v) if %w{key startkey endkey}.include?(k.to_s)
|
||||
v = v.to_json if %w{key startkey endkey}.include?(k.to_s)
|
||||
"#{k}=#{CGI.escape(v.to_s)}"
|
||||
end.join("&")
|
||||
url = "#{url}?#{query}"
|
||||
|
|
|
@ -15,7 +15,7 @@ class CouchRest
|
|||
|
||||
def temp_view funcs, params = nil
|
||||
url = CouchRest.paramify_url "#{@root}/_temp_view", params
|
||||
JSON.parse(RestClient.post(url, JSON.unparse(funcs), {"Content-Type" => 'application/json'}))
|
||||
JSON.parse(RestClient.post(url, funcs.to_json, {"Content-Type" => 'application/json'}))
|
||||
end
|
||||
|
||||
def view name, params = nil
|
||||
|
|
|
@ -22,7 +22,7 @@ describe CouchRest do
|
|||
it "should be up to date" do
|
||||
v = @cr.info["version"]
|
||||
vi = v.split(/a/).pop.to_i
|
||||
vi.should be_between 658733, 659600
|
||||
vi.should be_between(658733, 659864)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue