Sha256: 3df8056eceac9645b40be2f114961bf73b5e11245de7786a37046a9f5909b6d0

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
      has_subresource "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.2.2 spec/services/persist_basic_contained_output_file_service_spec.rb
hydra-derivatives-3.2.1 spec/services/persist_basic_contained_output_file_service_spec.rb
hydra-derivatives-3.2.0 spec/services/persist_basic_contained_output_file_service_spec.rb
hydra-derivatives-3.1.4 spec/services/persist_basic_contained_output_file_service_spec.rb