samvera / hydra-works

A ruby gem implementation of the PCDM Works domain model based on the Samvera software stack
Other
24 stars 14 forks source link

Hydra::Works::AddFileToFileSet #find_or_create_file_for_rdf_uri fails to create original_file association #369

Open elrayle opened 5 years ago

elrayle commented 5 years ago

Descriptive summary

AddFileToFileSet is supposed to be able to process the use the file is playing in the fileset as either a symbol or a URI. But the code in the two methods that create the file through ActiveFedora are not equivalent. The find_or_create_file_for_rdf_uri method fails to create the original_file association which is needed to be able to reference the file from the fileset using the_file_set.original_file.

Expected behavior

Whether calling AddToFileSet with type as URI or symbol, it is expected that after the add, there will be an association method that can be used to access the file in the fileset.

the_file_set.original_file # is defined and returns the File

Actual behavior

the_file_set.original_file # raises method not found for original_file

find_or_create_file_for_symbol correctly creates original_file association

find_or_create_file_for_rdf_uri fails to create original_file association

Steps to reproduce the behavior

  let(:file_set) { Hydra::Works::FileSet.new }
  let(:type)  { RDF::URI.new('http://pcdm.org/use#originalFile') }
  let(:file)                { File.open(File.join(fixture_path, filename)) }

    it 'adds association method' do
      described_class.call(file_set, file, type)
      expect(file_set).to respond_to :original_file
    end