Sha256: 3e5adaf6de59c9415ab90987e3c2c789000d7aaf48abd383b3d78fb9871bfb65

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

describe ActiveFedora::SolrHit do
  before do
    class MyDS < ActiveFedora::OmDatastream
      set_terminology do |t|
        t.root(path: "durh")
        t.foo
        t.bar
      end
    end

    class Foo < ActiveFedora::Base
      has_subresource 'descMetadata', class_name: 'MyDS'
      Deprecation.silence(ActiveFedora::Attributes) do
        has_attributes :foo, datastream: 'descMetadata', multiple: true
        has_attributes :bar, datastream: 'descMetadata', multiple: false
      end
      property :title, predicate: ::RDF::Vocab::DC.title, multiple: false
    end
  end

  let(:another) { Foo.create }

  let!(:obj) { Foo.create!(
    id: 'test-123',
    foo: ["baz"],
    bar: 'quix',
    title: 'My Title'
  ) }

  let(:doc) { obj.to_solr }
  let(:solr_hit) { described_class.new(doc) }

  after do
    Object.send(:remove_const, :Foo)
    Object.send(:remove_const, :MyDS)
  end

  describe "#reify" do
    subject { solr_hit.reify }

    it "finds the document in solr" do
      expect(subject).to be_instance_of Foo
      expect(subject.title).to eq 'My Title'
    end
  end

  describe "#instantiate_with_json" do
    subject { solr_hit.instantiate_with_json }

    it { is_expected.to be_persisted }

    it "finds the document in solr" do
      expect(subject).to be_instance_of Foo
      expect(subject.title).to eq 'My Title'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active-fedora-9.13.0 spec/integration/solr_hit_spec.rb