#view method works when auto_update_design_doc is disabled
This commit is contained in:
parent
f28cce1f0a
commit
f2c16144b0
2 changed files with 20 additions and 3 deletions
|
@ -58,10 +58,11 @@ module CouchRest
|
|||
self.model = model
|
||||
end
|
||||
|
||||
# Define a view and generate a method that will provide a new
|
||||
# View instance when requested.
|
||||
# Generate a method that will provide a new View instance when
|
||||
# requested. This will also define the view in CouchDB unless
|
||||
# auto_update_design_doc is disabled.
|
||||
def view(name, opts = {})
|
||||
View.create(model, name, opts)
|
||||
View.create(model, name, opts) if model.auto_update_design_doc
|
||||
create_view_method(name)
|
||||
end
|
||||
|
||||
|
|
|
@ -84,7 +84,23 @@ describe "Design" do
|
|||
@object.should_receive(:create_view_method).with('test')
|
||||
@object.view('test')
|
||||
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
|
||||
|
||||
describe "#filter" do
|
||||
|
|
Loading…
Reference in a new issue