Sha256: 3e185c402908fb1478a58a42445bb405eb1730347ab5af511ae45b080da103fa

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'

describe FedoraMigrate::ObjectMover do
  before :all do
    Object.send(:remove_const, :GenericFile) if defined?(GenericFile)
    class GenericFile < ActiveFedora::Base
      belongs_to :batch, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
      property :title, predicate: ::RDF::Vocab::DC.title do |index|
        index.as :stored_searchable, :facetable
      end
      property :creator, predicate: ::RDF::Vocab::DC.creator do |index|
        index.as :stored_searchable, :facetable
      end
    end

    Object.send(:remove_const, :Batch) if defined?(Batch)
    class Batch < ActiveFedora::Base
      has_many :generic_files, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
    end
  end

  after :all do
    Object.send(:remove_const, :GenericFile) if defined?(GenericFile)
    Object.send(:remove_const, :Batch) if defined?(Batch)
  end

  let(:parent_source) { FedoraMigrate.source.connection.find("sufia:rb68xc09k") }
  let(:child_source)  { FedoraMigrate.source.connection.find("sufia:rb68xc11m") }

  context "when all objects exist in Fedora4" do
    before do
      described_class.new(parent_source).migrate
      described_class.new(child_source).migrate
    end

    subject { Batch.find("rb68xc09k") }

    describe "migrating the parent object's relationships" do
      before do
        FedoraMigrate::RelsExtDatastreamMover.new(child_source).migrate
      end
      specify "should connect the child to the parent" do
        expect(subject.generic_files.count).to eql 1
      end
      specify "is repeatable" do
        FedoraMigrate::RelsExtDatastreamMover.new(child_source).migrate
        expect(subject.generic_files.count).to eql 1
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fedora-migrate-0.5.0 spec/integration/relationship_migration_spec.rb