Sha256: 361d765418b1b00bd3ef97bed65d0f3d07502913bdcbbba8d46712b093917cf6

Contents?: true

Size: 1.89 KB

Versions: 26

Compression:

Stored size: 1.89 KB

Contents

require "spec_helper"

describe Blacklight::SolrResponse::GroupResponse do
  
  let(:response) do
    create_response(sample_response)
  end

  let(:group) do
    response.grouped.select { |x| x.key == "result_group_ssi" }.first
  end

  describe "groups" do
    it "should return an array of Groups" do
      expect(response.grouped).to be_a Array

      expect(group.groups).to have(2).items
      group.groups.each do |group|
        expect(group).to be_a Blacklight::SolrResponse::Group
      end
    end
    it "should include a list of SolrDocuments" do

      group.groups.each do |group|
        group.docs.each do |doc|
          expect(doc).to be_a SolrDocument
        end
      end
    end
  end
  
  describe "total" do
    it "should return the ngroups value" do
      expect(group.total).to eq 3
    end
  end
  
  describe "facets" do
    it "should exist in the response object (not testing, we just extend the module)" do
      expect(group).to respond_to :facets
    end
  end
  
  describe "rows" do
    it "should get the rows from the response" do
      expect(group.rows).to eq 3
    end
  end

  describe "group_field" do
    it "should be the field name for the current group" do
      expect(group.group_field).to eq "result_group_ssi"
    end
  end

  describe "group_limit" do
    it "should be the number of documents to return for a group" do
      expect(group.group_limit).to eq 5
    end
  end
end

def create_response(response, params = {})
  Blacklight::SolrResponse.new(response, params)
end

def sample_response
  {"responseHeader" => {"params" =>{"rows" => 3, "group.limit" => 5}},
   "grouped" => 
     {'result_group_ssi' => 
       {'groups' => [{'groupValue'=>"Group 1", 'doclist'=>{'numFound'=>2, 'docs'=>[{:id=>1}]}},
                     {'groupValue'=>"Group 2", 'doclist'=>{'numFound'=>3, 'docs'=>[{:id=>2}, :id=>3]}}
                    ],
        'ngroups' => "3"
       }
     }
  }
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
blacklight-5.13.0 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.11.3 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.12.1 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.12.0 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.10.3 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.9.4 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.11.2 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.11.1 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.11.0 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.10.2 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.10.1 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.10.0 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.9.3 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.9.2 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.9.1 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.9.0 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.8.2 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.8.1 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.8.0 spec/lib/blacklight/solr_response/group_response_spec.rb
blacklight-5.7.2 spec/lib/blacklight/solr_response/group_response_spec.rb