Sha256: 4b0dfd46dcbbc6223ddeb5bdf199ce6f0bfcfb93703187b3e472eede2f6d6037

Contents?: true

Size: 1.91 KB

Versions: 12

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'

describe ActiveFedora::QueryResultBuilder do
  describe "#reify_solr_results" do
    before(:each) do
      class FooObject < ActiveFedora::Base
        def self.id_namespace
          "foo"
        end

        has_metadata :name => "descMetadata", :type => ActiveFedora::QualifiedDublinCoreDatastream
      end
      @test_object = ActiveFedora::Base.new
      @foo_object = FooObject.new
      attributes = {"language"=>{0=>"Italian"},
                    "creator"=>{0=>"Linguist, A."},
                    "geography"=>{0=>"Italy"},
                    "title"=>{0=>"Italian and Spanish: A Comparison of Common Phrases"}}
      @foo_object.descMetadata.update_indexed_attributes(attributes)
      @test_object.save
      @foo_object.save
      @profiles = {
        # 'test' => @test_object.profile,
        # 'foo' => @foo_object.profile,
        # 'foo_descMetadata' => @foo_object.datastreams['descMetadata'].profile
      }
      @foo_content = @foo_object.attached_files['descMetadata'].content
    end
    after(:each) do
      Object.send(:remove_const, :FooObject)
    end
    it "should return an array of objects that are of the class stored in active_fedora_model_s" do
      query = "id\:#{RSolr.escape(@test_object.id)} OR id\:#{RSolr.escape(@foo_object.id)}"
      solr_result = ActiveFedora::SolrService.query(query)
      result = ActiveFedora::QueryResultBuilder.reify_solr_results(solr_result)
      expect(result.length).to eq 2
      result.each do |r|
        expect((r.class == ActiveFedora::Base || r.class == FooObject)).to be true
      end
    end

    it 'should #reify a lightweight object as a new instance' do
      query = "id\:#{RSolr.escape(@foo_object.id)}"
      solr_result = ActiveFedora::SolrService.query(query)
      result = ActiveFedora::QueryResultBuilder.reify_solr_results(solr_result,{:load_from_solr=>true})
      expect(result.first).to be_instance_of FooObject
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
active-fedora-9.0.2 spec/integration/query_result_builder_spec.rb
active-fedora-9.0.1 spec/integration/query_result_builder_spec.rb
active-fedora-9.0.0 spec/integration/query_result_builder_spec.rb
active-fedora-9.0.0.rc3 spec/integration/query_result_builder_spec.rb
active-fedora-9.0.0.rc2 spec/integration/query_result_builder_spec.rb
active-fedora-9.0.0.rc1 spec/integration/query_result_builder_spec.rb
active-fedora-9.0.0.beta8 spec/integration/query_result_builder_spec.rb
active-fedora-9.0.0.beta7 spec/integration/query_result_builder_spec.rb
active-fedora-9.0.0.beta6 spec/integration/query_result_builder_spec.rb
active-fedora-9.0.0.beta5 spec/integration/query_result_builder_spec.rb
active-fedora-9.0.0.beta4 spec/integration/query_result_builder_spec.rb
active-fedora-9.0.0.beta3 spec/integration/query_result_builder_spec.rb