Sha256: 5d167ff262663ae2c0fadd66768af0fed616c62944aeb726454abc5d0179a7e4

Contents?: true

Size: 1.33 KB

Versions: 8

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe ActiveFedora::Base do
  
  before(:each) do
    @test_object = ActiveFedora::Base.new
  end
  
  describe '.add_datastream' do
    it "should not call Datastream.save" do
      ds = ActiveFedora::Datastream.new(@test_object.inner_object, 'ds_to_add')
      expect(ds).to receive(:save).never
      @test_object.add_datastream(ds)
    end
    it "should add the datastream to the datastreams_in_memory array" do
      ds = ActiveFedora::Datastream.new(@test_object.inner_object, 'ds_to_add')
      expect(@test_object.datastreams).not_to have_key(ds.dsid)
      @test_object.add_datastream(ds)
      expect(@test_object.datastreams).to have_key(ds.dsid)
    end
    it "should auto-assign dsids using auto-incremented integers if dsid is nil or an empty string" do 
      ds = ActiveFedora::Datastream.new(@test_object.inner_object, nil)
      expect(ds.dsid).to eq('DS1')
      expect(@test_object.add_datastream(ds)).to eq('DS1')
      ds_emptystringid = ActiveFedora::Datastream.new(@test_object.inner_object, '')
      expect(@test_object.add_datastream(ds_emptystringid)).to eq('DS2')
    end
    it "should accept a prefix option and apply it to automatically assigned dsids" do
      ds = ActiveFedora::Datastream.new(@test_object.inner_object, nil, :prefix=> "FOO")
      expect(ds.dsid).to eq('FOO1')
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
active-fedora-8.7.0 spec/unit/base_datastream_management_spec.rb
active-fedora-8.6.0 spec/unit/base_datastream_management_spec.rb
active-fedora-8.5.0 spec/unit/base_datastream_management_spec.rb
active-fedora-8.4.2 spec/unit/base_datastream_management_spec.rb
active-fedora-8.4.1 spec/unit/base_datastream_management_spec.rb
active-fedora-8.4.0 spec/unit/base_datastream_management_spec.rb
active-fedora-8.3.0 spec/unit/base_datastream_management_spec.rb
active-fedora-8.2.2 spec/unit/base_datastream_management_spec.rb