Checking for block given and ensuring proyxable finds classes in root namespace
This commit is contained in:
parent
f58482553c
commit
d1baf99324
|
@ -66,6 +66,11 @@ PLATFORMS
|
|||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activemodel (~> 3.0.0)
|
||||
couchrest (~> 1.0.1)
|
||||
couchrest_model!
|
||||
mime-types (~> 1.15)
|
||||
rack-test (>= 0.5.7)
|
||||
railties (~> 3.0.0)
|
||||
rspec (>= 2.0.0)
|
||||
tzinfo (~> 0.3.22)
|
||||
|
|
|
@ -27,7 +27,7 @@ module CouchRest
|
|||
mapper = DesignMapper.new(self)
|
||||
mapper.create_view_method(:all)
|
||||
|
||||
mapper.instance_eval(&block)
|
||||
mapper.instance_eval(&block) if block_given?
|
||||
|
||||
req_design_doc_refresh
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ module CouchRest
|
|||
unless respond_to?('#{db_method}')
|
||||
raise "Missing ##{db_method} method for proxy"
|
||||
end
|
||||
@#{model_name} ||= CouchRest::Model::Proxyable::ModelProxy.new(#{options[:class_name]}, self, self.class.to_s.underscore, #{db_method})
|
||||
@#{model_name} ||= CouchRest::Model::Proxyable::ModelProxy.new(::#{options[:class_name]}, self, self.class.to_s.underscore, #{db_method})
|
||||
end
|
||||
EOS
|
||||
end
|
||||
|
|
|
@ -36,6 +36,10 @@ describe "Design" do
|
|||
DesignModel.design() { }
|
||||
end
|
||||
|
||||
it "should work even if a block is not provided" do
|
||||
lambda { DesignModel.design }.should_not raise_error
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "default_per_page" do
|
||||
|
|
|
@ -41,6 +41,18 @@ describe "Proxyable" do
|
|||
@obj.cats
|
||||
end
|
||||
|
||||
it "should call class on root namespace" do
|
||||
class ::Document < CouchRest::Model::Base
|
||||
def self.foo; puts 'bar'; end
|
||||
end
|
||||
DummyProxyable.proxy_for(:documents)
|
||||
@obj = DummyProxyable.new
|
||||
CouchRest::Model::Proxyable::ModelProxy.should_receive(:new).with(::Document, @obj, 'dummy_proxyable', 'db').and_return(true)
|
||||
@obj.should_receive('proxy_database').and_return('db')
|
||||
@obj.should_receive(:respond_to?).with('proxy_database').and_return(true)
|
||||
@obj.documents
|
||||
end
|
||||
|
||||
it "should raise an error if the database method is missing" do
|
||||
DummyProxyable.proxy_for(:cats)
|
||||
@obj = DummyProxyable.new
|
||||
|
@ -54,6 +66,7 @@ describe "Proxyable" do
|
|||
lambda { @obj.proxy_kittens }.should raise_error(StandardError, "Missing #foobardom method for proxy")
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue