Sha256: 4180dc9bfee3c9c61138979ca91d272b552533b331eda0edb68c4414ebb1af29

Contents?: true

Size: 1.84 KB

Versions: 50

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'

module Ddr
  module Models
    RSpec.describe HasStructMetadata, type: :model, structural_metadata: true do

      let(:item) { Item.new(pid: 'test:2') }

      describe "#structure" do
        context "no existing structural metadata" do
          it "should return nil" do
            expect(item.structure).to eq(nil)
          end
        end
        context "existing structural metadata" do
          before { item.datastreams[Ddr::Datastreams::STRUCT_METADATA].content = simple_structure }
          it "should return the structural metadata" do
            expect(item.structure.to_xml).to be_equivalent_to(simple_structure)
          end
        end
      end

      describe "#build_default_structure" do
        let(:components) { [ Component.new(pid: 'test:5', identifier: [ 'abc002' ]),
                             Component.new(pid: 'test:6', identifier: [ 'abc001' ]),
                             Component.new(pid: 'test:7', identifier: [ 'abc003' ])
                           ] }
        let(:expected) { FactoryGirl.build(:simple_structure) }
        before { allow(item).to receive(:find_children) { simple_structure_query_response } }
        it "should build the appropriate structural metadata" do
          results = item.build_default_structure
          expect(results).to be_equivalent_to(expected)
        end
      end

      describe "indexing" do
        let(:expected_json) { multiple_struct_maps_structure_to_json }
        before { item.datastreams[Ddr::Datastreams::STRUCT_METADATA].content = multiple_struct_maps_structure }
        it "should index the JSON representation of the structure" do
          indexing = item.to_solr
          expect(indexing.keys).to include(Ddr::Index::Fields::STRUCT_MAPS)
          expect(indexing[Ddr::Index::Fields::STRUCT_MAPS]).to eq(expected_json)
        end
      end

    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
ddr-models-2.4.8 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.7 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.6 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.5 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.4 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.3 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.2 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.1 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.0 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.0.rc6 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.0.rc5 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.0.rc4 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.0.rc3 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.0.rc2 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.0.rc1 spec/models/has_struct_metadata_spec.rb
ddr-models-2.3.2 spec/models/has_struct_metadata_spec.rb
ddr-models-3.0.0.beta.1 spec/models/has_struct_metadata_spec.rb
ddr-models-2.3.1 spec/models/has_struct_metadata_spec.rb
ddr-models-3.0.0.alpha.4 spec/models/has_struct_metadata_spec.rb
ddr-models-3.0.0.alpha.3 spec/models/has_struct_metadata_spec.rb