Sha256: fa08a46e88fbb603c48ddb163a65b1409b179f4363855fec6a3b889ce140dc38

Contents?: true

Size: 1.72 KB

Versions: 14

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

describe ActiveFedora::QueryResultBuilder do
  describe "reify solr results" do
    before(:all) do
      class AudioRecord
        attr_accessor :id
        def self.connection_for_id(id)
        end
      end
      @sample_solr_hits = [{"id"=>"my:_ID1_", ActiveFedora::SolrQueryBuilder.solr_name("has_model", :symbol)=>["AudioRecord"]},
                           {"id"=>"my:_ID2_", ActiveFedora::SolrQueryBuilder.solr_name("has_model", :symbol)=>["AudioRecord"]},
                           {"id"=>"my:_ID3_", ActiveFedora::SolrQueryBuilder.solr_name("has_model", :symbol)=>["AudioRecord"]}]
    end
    describe ".reify_solr_result" do
      it "should use .find to instantiate objects" do
        expect(AudioRecord).to receive(:find).with("my:_ID1_", cast: true)
        ActiveFedora::QueryResultBuilder.reify_solr_result(@sample_solr_hits.first)
      end
    end
    describe ".reify_solr_results" do
      it "should use AudioRecord.find to instantiate objects" do
        expect(AudioRecord).to receive(:find).with("my:_ID1_", cast: true)
        expect(AudioRecord).to receive(:find).with("my:_ID2_", cast: true)
        expect(AudioRecord).to receive(:find).with("my:_ID3_", cast: true)
        ActiveFedora::QueryResultBuilder.reify_solr_results(@sample_solr_hits)
      end
    end
    describe ".lazy_reify_solr_results" do
      it "should lazily reify solr results" do
        expect(AudioRecord).to receive(:find).with("my:_ID1_", cast: true)
        expect(AudioRecord).to receive(:find).with("my:_ID2_", cast: true)
        expect(AudioRecord).to receive(:find).with("my:_ID3_", cast: true)
        ActiveFedora::QueryResultBuilder.lazy_reify_solr_results(@sample_solr_hits).each {|r| r}
      end
    end
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
active-fedora-9.5.0 spec/unit/query_result_builder_spec.rb
active-fedora-9.4.3 spec/unit/query_result_builder_spec.rb
active-fedora-9.4.2 spec/unit/query_result_builder_spec.rb
active-fedora-9.4.1 spec/unit/query_result_builder_spec.rb
active-fedora-9.4.0 spec/unit/query_result_builder_spec.rb
active-fedora-9.3.0 spec/unit/query_result_builder_spec.rb
active-fedora-9.2.1 spec/unit/query_result_builder_spec.rb
active-fedora-9.2.0 spec/unit/query_result_builder_spec.rb
active-fedora-9.2.0.rc2 spec/unit/query_result_builder_spec.rb
active-fedora-9.2.0.rc1 spec/unit/query_result_builder_spec.rb
active-fedora-9.1.2 spec/unit/query_result_builder_spec.rb
active-fedora-9.1.1 spec/unit/query_result_builder_spec.rb
active-fedora-9.1.0 spec/unit/query_result_builder_spec.rb
active-fedora-9.1.0.rc1 spec/unit/query_result_builder_spec.rb