Sha256: 7c6a9ab453761d9b9561da46e08a346df75ddbaaf9c274d276cfd899abfee56f

Contents?: true

Size: 1 KB

Versions: 25

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

describe CouchPotato::View::CustomViewSpec, '#process_results' do
  it 'returns the documents' do
    spec = CouchPotato::View::CustomViewSpec.new(Child, 'all', {}, {})
    processed_results = spec.process_results('rows' => [{'doc' => {JSON.create_id => 'Child'}}])

    expect(processed_results.map{|row| row.class}).to eql([Child])
  end

  it 'returns values where there are no documents' do
    spec = CouchPotato::View::CustomViewSpec.new(Child, 'all', {}, {:include_docs => false})
    processed_results = spec.process_results('rows' => [{'value' => {JSON.create_id => 'Child'}}])

    expect(processed_results.map{|row| row.class}).to eql([Child])
  end

  it 'filters out rows without documents when include_docs=true (i.e. doc has been deleted)' do
    spec = CouchPotato::View::CustomViewSpec.new(Child, 'all', {}, {:include_docs => true})
    processed_results = spec.process_results('rows' => [{'value' => {JSON.create_id => 'Child'}}])

    expect(processed_results).to be_empty
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
couch_potato-1.17.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.16.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.15.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.14.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.13.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.12.1 spec/unit/custom_view_spec_spec.rb
couch_potato-1.12.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.11.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.10.1 spec/unit/custom_view_spec_spec.rb
couch_potato-1.10.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.9.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.7.1 spec/unit/custom_view_spec_spec.rb
couch_potato-1.7.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.6.5 spec/unit/custom_view_spec_spec.rb
couch_potato-1.6.4 spec/unit/custom_view_spec_spec.rb
couch_potato-1.6.3 spec/unit/custom_view_spec_spec.rb
couch_potato-1.4.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.3.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.2.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.1.4 spec/unit/custom_view_spec_spec.rb