Sha256: c1e07f7af43c8abaf202a6e1e723e464e0d525a615a1ae0f0eca5c6830658ee8

Contents?: true

Size: 1.58 KB

Versions: 32

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe "automatic view updates" do
  before(:each) do
    recreate_db
    @db = CouchPotato.couchrest_database
  end
  
  it "should update a view that doesn't match the given functions" do
    CouchPotato::View::ViewQuery.new(@db, 'test_design1', {'test_view' => {:map => 'function(doc) {}', :reduce => 'function() {}'}}, nil).query_view! # create view
    CouchPotato::View::ViewQuery.new(@db, 'test_design1', {'test_view' => {:map => 'function(doc) {emit(doc.id, null)}', :reduce => 'function(key, values) {return sum(values)}'}}, nil).query_view!
    CouchPotato.database.load('_design/test_design1')['views']['test_view'].should == {
      'map' => 'function(doc) {emit(doc.id, null)}',
      'reduce' => 'function(key, values) {return sum(values)}'
    }
  end
  
  it "should only update a view once to avoid writing the view for every request" do
    CouchPotato::View::ViewQuery.new(@db, 'test_design2', {'test_view' => {:map => 'function(doc) {}', :reduce => 'function() {}'}}, nil).query_view! # create view
    CouchPotato::View::ViewQuery.new(@db, 'test_design2', {'test_view' => {:map => 'function(doc) {emit(doc.id, null)}', :reduce => 'function(key, values) {return sum(values)}'}}, nil).query_view!
    CouchPotato::View::ViewQuery.new(@db, 'test_design2', {'test_view' => {:map => 'function(doc) {}', :reduce => 'function() {}'}}, nil).query_view!
    CouchPotato.database.load('_design/test_design2')['views']['test_view'].should == {
      'map' => 'function(doc) {emit(doc.id, null)}',
      'reduce' => 'function(key, values) {return sum(values)}'
    }
  end
  
end

Version data entries

32 entries across 32 versions & 3 rubygems

Version Path
couch_potato-0.5.5 spec/view_updates_spec.rb
couch_potato-0.5.4 spec/view_updates_spec.rb
couch_potato-0.5.3 spec/view_updates_spec.rb
couch_potato-0.5.2 spec/view_updates_spec.rb
couch_potato-0.5.1 spec/view_updates_spec.rb
couch_potato-0.5.0 spec/view_updates_spec.rb
davber_couch_potato-0.4.0 spec/view_updates_spec.rb
couch_potato-0.4.0 spec/view_updates_spec.rb
couch_potato-0.3.2 spec/view_updates_spec.rb
couch_potato-0.3.1 spec/view_updates_spec.rb
davber_couch_potato-0.3.0 spec/view_updates_spec.rb
couch_potato-0.3.0 spec/view_updates_spec.rb