#view method works when auto_update_design_doc is disabled

This commit is contained in:
Peter Williams 2011-11-16 15:30:46 -07:00
parent f28cce1f0a
commit f2c16144b0
2 changed files with 20 additions and 3 deletions

View file

@ -58,10 +58,11 @@ module CouchRest
self.model = model self.model = model
end end
# Define a view and generate a method that will provide a new # Generate a method that will provide a new View instance when
# View instance when requested. # requested. This will also define the view in CouchDB unless
# auto_update_design_doc is disabled.
def view(name, opts = {}) def view(name, opts = {})
View.create(model, name, opts) View.create(model, name, opts) if model.auto_update_design_doc
create_view_method(name) create_view_method(name)
end end

View file

@ -84,7 +84,23 @@ describe "Design" do
@object.should_receive(:create_view_method).with('test') @object.should_receive(:create_view_method).with('test')
@object.view('test') @object.view('test')
end end
end
context "for model with auto_update_design_doc disabled " do
class ::DesignModelAutoUpdateDesignDocDisabled < ::CouchRest::Model::Base
self.auto_update_design_doc = false
end
describe "#view" do
before :each do
@object = @klass.new(DesignModelAutoUpdateDesignDocDisabled)
end
it "does not attempt to create view" do
CouchRest::Model::Designs::View.should_not_receive(:create)
@object.view('test')
end
end
end end
describe "#filter" do describe "#filter" do