Fixing support for specifying database in collections
This commit is contained in:
parent
456946c149
commit
77cb8160c7
3 changed files with 11 additions and 4 deletions
|
@ -20,7 +20,7 @@ module CouchRest
|
|||
class_eval <<-END, __FILE__, __LINE__ + 1
|
||||
def self.find_all_#{collection_name}(options = {})
|
||||
view_options = #{view_options.inspect} || {}
|
||||
CollectionProxy.new(database, "#{design_doc}", "#{view_name}", view_options.merge(options), Kernel.const_get('#{self}'))
|
||||
CollectionProxy.new(options[:database] || database, "#{design_doc}", "#{view_name}", view_options.merge(options), Kernel.const_get('#{self}'))
|
||||
end
|
||||
END
|
||||
end
|
||||
|
@ -63,12 +63,12 @@ module CouchRest
|
|||
|
||||
def create_collection_proxy(options)
|
||||
design_doc, view_name, view_options = parse_view_options(options)
|
||||
CollectionProxy.new(database, design_doc, view_name, view_options, self)
|
||||
CollectionProxy.new(options[:database] || database, design_doc, view_name, view_options, self)
|
||||
end
|
||||
|
||||
def create_search_collection_proxy(options)
|
||||
design_doc, search_name, search_options = parse_search_options(options)
|
||||
CollectionProxy.new(@database, design_doc, search_name, search_options, self, :search)
|
||||
CollectionProxy.new(options[:database] || database, design_doc, search_name, search_options, self, :search)
|
||||
end
|
||||
|
||||
def parse_view_options(options)
|
||||
|
|
|
@ -83,7 +83,7 @@ describe "ExtendedDocument" do
|
|||
self.conditional_two = true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class WithTemplateAndUniqueID < CouchRest::ExtendedDocument
|
||||
use_database TEST_SERVER.default_database
|
||||
unique_id do |model|
|
||||
|
@ -641,6 +641,7 @@ describe "ExtendedDocument" do
|
|||
@doc.run_after_validate.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "save" do
|
||||
it "should run the after filter after saving" do
|
||||
@doc.run_after_save.should be_nil
|
||||
|
|
|
@ -451,6 +451,12 @@ describe "ExtendedDocument views" do
|
|||
articles.paginate(:page => 4, :per_page => 3).size.should == 3
|
||||
articles.paginate(:page => 5, :per_page => 3).size.should == 1
|
||||
end
|
||||
it "should pass database parameter to pager" do
|
||||
proxy = mock(:proxy)
|
||||
proxy.stub!(:paginate)
|
||||
::CouchRest::Mixins::Collection::CollectionProxy.should_receive(:new).with('database', anything(), anything(), anything(), anything()).and_return(proxy)
|
||||
Article.paginate(:design_doc => 'Article', :view_name => 'by_date', :database => 'database')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue