diff --git a/Gemfile.lock b/Gemfile.lock index a0e9846..4fe2a62 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/lib/couchrest/model/designs.rb b/lib/couchrest/model/designs.rb index e0d1850..2ddb9ab 100644 --- a/lib/couchrest/model/designs.rb +++ b/lib/couchrest/model/designs.rb @@ -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 diff --git a/lib/couchrest/model/proxyable.rb b/lib/couchrest/model/proxyable.rb index e35656e..839278d 100644 --- a/lib/couchrest/model/proxyable.rb +++ b/lib/couchrest/model/proxyable.rb @@ -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 diff --git a/spec/couchrest/designs_spec.rb b/spec/couchrest/designs_spec.rb index a035ad7..a1ac98f 100644 --- a/spec/couchrest/designs_spec.rb +++ b/spec/couchrest/designs_spec.rb @@ -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 diff --git a/spec/couchrest/proxyable_spec.rb b/spec/couchrest/proxyable_spec.rb index 13098b7..4873c5d 100644 --- a/spec/couchrest/proxyable_spec.rb +++ b/spec/couchrest/proxyable_spec.rb @@ -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