Fixing view deleting database option bug
This commit is contained in:
parent
0c008d4bc7
commit
226fe3bf38
|
@ -92,6 +92,7 @@ module CouchRest
|
||||||
|
|
||||||
# Dispatches to any named view.
|
# Dispatches to any named view.
|
||||||
def view(name, query={}, &block)
|
def view(name, query={}, &block)
|
||||||
|
query = query.dup # Modifications made on copy!
|
||||||
db = query.delete(:database) || database
|
db = query.delete(:database) || database
|
||||||
refresh_design_doc(db)
|
refresh_design_doc(db)
|
||||||
query[:raw] = true if query[:reduce]
|
query[:raw] = true if query[:reduce]
|
||||||
|
|
|
@ -14,6 +14,21 @@ describe "Model views" do
|
||||||
view_by :title
|
view_by :title
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
describe "ClassMethods" do
|
||||||
|
# NOTE! Add more unit tests!
|
||||||
|
|
||||||
|
describe "#view" do
|
||||||
|
|
||||||
|
it "should not alter original query" do
|
||||||
|
options = { :database => DB }
|
||||||
|
view = Article.view('by_date', options)
|
||||||
|
options[:database].should_not be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "a model with simple views and a default param" do
|
describe "a model with simple views and a default param" do
|
||||||
before(:all) do
|
before(:all) do
|
||||||
Article.all.map{|a| a.destroy(true)}
|
Article.all.map{|a| a.destroy(true)}
|
||||||
|
|
Loading…
Reference in a new issue