Sha256: 75c75aa580f0ab2c6673581e37bfa07cce5847f9450fcad53d4889c650dd0c3d

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

describe Hydra::Derivatives::PersistBasicContainedOutputFileService do

  before(:all) do
    class BasicContainerObject < ActiveFedora::Base
      contains "the_derivative_name"
    end
  end

  let(:object)            { BasicContainerObject.new  }
  let(:file_path)         { File.join(fixture_path, 'test.tif') }
  let(:file)              { File.new(file_path)}
  let(:destination_name)  { 'the_derivative_name' }

  # alas, we have to support this as the default because all legacy code (and fedora 3 systems) created basic contained files
  # The new signature does not have a destination_name option.  There is a default string that will get applied, but his might
  # not be sufficient.
  context "when file is basic contained (default assumption)" do
    let(:object) { BasicContainerObject.create  }
    let(:stream) { StringIO.new("fake file content") }
    it "persists the file to the specified destination on the given object" do
      described_class.call(stream, { format: 'jpg', url: "#{object.uri}/the_derivative_name" })
      expect(object.send(destination_name.to_sym).content).to eq("fake file content")
      expect(object.send(destination_name.to_sym).content_changed?).to eq false
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hydra-derivatives-3.1.0 spec/services/persist_basic_contained_output_file_service_spec.rb
hydra-derivatives-3.0.2 spec/services/persist_basic_contained_output_file_service_spec.rb
hydra-derivatives-3.0.1 spec/services/persist_basic_contained_output_file_service_spec.rb
hydra-derivatives-3.0.0 spec/services/persist_basic_contained_output_file_service_spec.rb