Sha256: 98f2aaae8b5eb4367421d3d2fc0807bfcd6160d8c8ca7e045d566f88dec68694

Contents?: true

Size: 1.67 KB

Versions: 11

Compression:

Stored size: 1.67 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 "uses .find to instantiate objects" do
        expect(AudioRecord).to receive(:find).with("my:_ID1_", cast: true)
        described_class.reify_solr_result(@sample_solr_hits.first)
      end
    end
    describe ".reify_solr_results" do
      it "uses 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)
        described_class.reify_solr_results(@sample_solr_hits)
      end
    end
    describe ".lazy_reify_solr_results" do
      it "lazilies 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)
        described_class.lazy_reify_solr_results(@sample_solr_hits).each { |r| r }
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
active-fedora-9.7.3 spec/unit/query_result_builder_spec.rb
active-fedora-9.7.2 spec/unit/query_result_builder_spec.rb
active-fedora-9.9.1 spec/unit/query_result_builder_spec.rb
active-fedora-9.9.0 spec/unit/query_result_builder_spec.rb
active-fedora-9.8.2 spec/unit/query_result_builder_spec.rb
active-fedora-9.8.1 spec/unit/query_result_builder_spec.rb
active-fedora-9.8.0 spec/unit/query_result_builder_spec.rb
active-fedora-9.7.1 spec/unit/query_result_builder_spec.rb
active-fedora-9.7.0 spec/unit/query_result_builder_spec.rb
active-fedora-9.6.2 spec/unit/query_result_builder_spec.rb
active-fedora-9.6.1 spec/unit/query_result_builder_spec.rb