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.6.2 spec/models/has_struct_metadata_spec.rb
ddr-models-2.6.1 spec/models/has_struct_metadata_spec.rb
ddr-models-2.6.0 spec/models/has_struct_metadata_spec.rb
ddr-models-2.6.0.rc4 spec/models/has_struct_metadata_spec.rb
ddr-models-2.6.0.rc3 spec/models/has_struct_metadata_spec.rb
ddr-models-2.6.0.rc2 spec/models/has_struct_metadata_spec.rb
ddr-models-2.6.0.rc1 spec/models/has_struct_metadata_spec.rb
ddr-models-2.5.3 spec/models/has_struct_metadata_spec.rb
ddr-models-2.5.2 spec/models/has_struct_metadata_spec.rb
ddr-models-2.5.1 spec/models/has_struct_metadata_spec.rb
ddr-models-2.5.0 spec/models/has_struct_metadata_spec.rb
ddr-models-2.5.0.rc1 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.16 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.15 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.14 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.13 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.12 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.11 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.10 spec/models/has_struct_metadata_spec.rb
ddr-models-2.4.9 spec/models/has_struct_metadata_spec.rb