Sha256: 12d8b6ee4f797b6480a999ead20eb24618200a336c2afa84165cf6cf2f59514e

Contents?: true

Size: 1.46 KB

Versions: 36

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe ActiveFedora::QueryResultBuilder do
  describe "reify solr results" do
    before(:all) do
      class AudioRecord < ActiveFedora::Base
        attr_accessor :id
        def self.connection_for_id(_id)
        end
      end
      @sample_solr_hits = [{ "id" => "my:_ID1_", ActiveFedora.index_field_mapper.solr_name("has_model", :symbol) => ["AudioRecord"] },
                           { "id" => "my:_ID2_", ActiveFedora.index_field_mapper.solr_name("has_model", :symbol) => ["AudioRecord"] },
                           { "id" => "my:_ID3_", ActiveFedora.index_field_mapper.solr_name("has_model", :symbol) => ["AudioRecord"] }]
    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

36 entries across 36 versions & 1 rubygems

Version Path
active-fedora-11.1.4 spec/unit/query_result_builder_spec.rb
active-fedora-11.1.3 spec/unit/query_result_builder_spec.rb
active-fedora-11.1.2 spec/unit/query_result_builder_spec.rb
active-fedora-11.1.1 spec/unit/query_result_builder_spec.rb
active-fedora-11.1.0 spec/unit/query_result_builder_spec.rb
active-fedora-10.3.0 spec/unit/query_result_builder_spec.rb
active-fedora-11.0.1 spec/unit/query_result_builder_spec.rb
active-fedora-11.0.0 spec/unit/query_result_builder_spec.rb
active-fedora-10.3.0.rc2 spec/unit/query_result_builder_spec.rb
active-fedora-11.0.0.rc7 spec/unit/query_result_builder_spec.rb
active-fedora-10.3.0.rc1 spec/unit/query_result_builder_spec.rb
active-fedora-11.0.0.rc6 spec/unit/query_result_builder_spec.rb
active-fedora-10.2.1 spec/unit/query_result_builder_spec.rb
active-fedora-11.0.0.rc5 spec/unit/query_result_builder_spec.rb
active-fedora-11.0.0.rc4 spec/unit/query_result_builder_spec.rb
active-fedora-10.2.0 spec/unit/query_result_builder_spec.rb
active-fedora-11.0.0.rc3 spec/unit/query_result_builder_spec.rb
active-fedora-11.0.0.rc2 spec/unit/query_result_builder_spec.rb
active-fedora-11.0.0.rc1 spec/unit/query_result_builder_spec.rb
active-fedora-10.1.0 spec/unit/query_result_builder_spec.rb