fixing proxy setting proxied_by accessor
This commit is contained in:
parent
e8959883a9
commit
6a896c27b3
|
@ -1,7 +1,7 @@
|
||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
couchrest_model (1.0.0)
|
couchrest_model (1.1.0.beta)
|
||||||
activemodel (~> 3.0.0)
|
activemodel (~> 3.0.0)
|
||||||
couchrest (~> 1.0.1)
|
couchrest (~> 1.0.1)
|
||||||
mime-types (~> 1.15)
|
mime-types (~> 1.15)
|
||||||
|
|
|
@ -20,7 +20,7 @@ module CouchRest
|
||||||
unless respond_to?('#{db_method}')
|
unless respond_to?('#{db_method}')
|
||||||
raise "Missing ##{db_method} method for proxy"
|
raise "Missing ##{db_method} method for proxy"
|
||||||
end
|
end
|
||||||
@#{model_name} ||= CouchRest::Model::Proxyable::ModelProxy.new(#{options[:class_name]}, self, '#{model_name}', #{db_method})
|
@#{model_name} ||= CouchRest::Model::Proxyable::ModelProxy.new(#{options[:class_name]}, self, self.class.to_s.underscore, #{db_method})
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
@ -118,12 +118,12 @@ module CouchRest
|
||||||
@model.design_doc
|
@model.design_doc
|
||||||
end
|
end
|
||||||
|
|
||||||
def refresh_design_doc
|
def refresh_design_doc(db = nil)
|
||||||
@model.refresh_design_doc(@database)
|
@model.refresh_design_doc(db || @database)
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_design_doc
|
def save_design_doc(db = nil)
|
||||||
@model.save_design_doc(@database)
|
@model.save_design_doc(db || @database)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ describe "Proxyable" do
|
||||||
it "should call ModelProxy" do
|
it "should call ModelProxy" do
|
||||||
DummyProxyable.proxy_for(:cats)
|
DummyProxyable.proxy_for(:cats)
|
||||||
@obj = DummyProxyable.new
|
@obj = DummyProxyable.new
|
||||||
CouchRest::Model::Proxyable::ModelProxy.should_receive(:new).with(Cat, @obj, 'cats', 'db').and_return(true)
|
CouchRest::Model::Proxyable::ModelProxy.should_receive(:new).with(Cat, @obj, 'dummy_proxyable', 'db').and_return(true)
|
||||||
@obj.should_receive('proxy_database').and_return('db')
|
@obj.should_receive('proxy_database').and_return('db')
|
||||||
@obj.should_receive(:respond_to?).with('proxy_database').and_return(true)
|
@obj.should_receive(:respond_to?).with('proxy_database').and_return(true)
|
||||||
@obj.cats
|
@obj.cats
|
||||||
|
@ -198,16 +198,31 @@ describe "Proxyable" do
|
||||||
@obj.design_doc
|
@obj.design_doc
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should proxy refresh_design_doc" do
|
describe "#refresh_design_doc" do
|
||||||
Cat.should_receive(:refresh_design_doc).with('database')
|
it "should be proxied without database arg" do
|
||||||
@obj.refresh_design_doc
|
Cat.should_receive(:refresh_design_doc).with('database')
|
||||||
|
@obj.refresh_design_doc
|
||||||
|
end
|
||||||
|
it "should be proxied with database arg" do
|
||||||
|
Cat.should_receive(:refresh_design_doc).with('db')
|
||||||
|
@obj.refresh_design_doc('db')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should proxy save_design_doc" do
|
describe "#save_design_doc" do
|
||||||
Cat.should_receive(:save_design_doc).with('database')
|
it "should be proxied without args" do
|
||||||
@obj.save_design_doc
|
Cat.should_receive(:save_design_doc).with('database')
|
||||||
|
@obj.save_design_doc
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should be proxied with database arg" do
|
||||||
|
Cat.should_receive(:save_design_doc).with('db')
|
||||||
|
@obj.save_design_doc('db')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Updating methods
|
### Updating methods
|
||||||
|
|
||||||
describe "#proxy_update" do
|
describe "#proxy_update" do
|
||||||
|
|
Loading…
Reference in a new issue