spec/unit/design_spec.rb in couchrest_model-2.0.3 vs spec/unit/design_spec.rb in couchrest_model-2.0.4
- old
+ new
@@ -161,89 +161,11 @@
end
end
- describe "#migrate" do
- # WARNING! ORDER IS IMPORTANT!
- describe "with limited changes" do
-
- class DesignSampleModelMigrate < DesignSampleModelBase
- end
-
- before :all do
- reset_test_db!
- @mod = DesignSampleModelMigrate
- @doc = @mod.design_doc
- @db = @mod.database
- end
-
- it "should create new design if non exists" do
- @db.should_receive(:view).with("#{@doc['_id']}/_view/#{@doc['views'].keys.first}", {:limit => 1, :reduce => false})
- callback = @doc.migrate do |res|
- res.should eql(:created)
- end
- doc = @db.get(@doc['_id'])
- doc['views']['all'].should eql(@doc['views']['all'])
- callback.should be_nil
- end
-
- it "should not change anything if design is up to date" do
- @doc.sync
- @db.should_not_receive(:view)
- callback = @doc.migrate do |res|
- res.should eql(:no_change)
- end
- callback.should be_nil
- end
-
- end
-
- describe "migrating a document if there are changes" do
-
- class DesignSampleModelMigrate2 < DesignSampleModelBase
- end
-
- before :all do
- reset_test_db!
- @mod = DesignSampleModelMigrate2
- @doc = @mod.design_doc
- @db = @mod.database
- @doc.sync!
- @doc.create_view(:by_name_and_surname)
- @doc_id = @doc['_id'] + '_migration'
- end
-
- it "should save new migration design doc" do
- @db.should_receive(:view).with("#{@doc_id}/_view/by_name", {:limit => 1, :reduce => false})
- @callback = @doc.migrate do |res|
- res.should eql(:migrated)
- end
- @callback.should_not be_nil
-
- # should not have updated original view until cleanup
- doc = @db.get(@doc['_id'])
- doc['views'].should_not have_key('by_name_and_surname')
-
- # Should have created the migration
- new_doc = @db.get(@doc_id)
- new_doc.should_not be_nil
-
- # should be possible to perform cleanup
- @callback.call
- lambda { new_doc = @db.get(@doc_id) }.should raise_error RestClient::ResourceNotFound
-
- doc = @db.get(@doc['_id'])
- doc['views'].should have_key('by_name_and_surname')
- end
-
- end
-
- end
-
-
describe "#checksum" do
before :all do
@mod = DesignSampleModel
@doc = @mod.design_doc
@@ -344,9 +266,20 @@
@doc['filters']['test'].should eql('foobar')
@doc['filters'] = nil # cleanup
end
end
+ describe "#create_view_lib" do
+ before :each do
+ @doc = DesignSampleModel.design_doc
+ end
+
+ it "should add simple view lib" do
+ @doc.create_view_lib('test', 'foobar')
+ @doc['views']['lib']['test'].should eql('foobar')
+ @doc['views']['lib'] = nil # cleanup
+ end
+ end
end
describe "Checksum calculations" do