Sha256: 62b7c3c9205138cd55211a9593c822c5ac567bfb75e3718cab572b98b212c0fc
Contents?: true
Size: 1.59 KB
Versions: 16
Compression:
Stored size: 1.59 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! expect(CouchPotato.database.load('_design/test_design1')['views']['test_view']).to eq({ '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! expect(CouchPotato.database.load('_design/test_design2')['views']['test_view']).to eq({ 'map' => 'function(doc) {emit(doc.id, null)}', 'reduce' => 'function(key, values) {return sum(values)}' }) end end
Version data entries
16 entries across 16 versions & 1 rubygems