Sha256: 7516a033208176f90598bd578ffce8576aa7dc0165fd543bafb18955c08ff979

Contents?: true

Size: 1.45 KB

Versions: 23

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

describe ActiveFedora::UnsavedDigitalObject do
  it "should have an ARK-style pid" do    
    @obj = ActiveFedora::UnsavedDigitalObject.new(ActiveFedora::Base, 'id')
    @obj.save
    Sufia::IdService.valid?(@obj.pid).should be_true
  end
  it "should not use Fedora's pid service" do
    ActiveFedora::RubydoraConnection.any_instance.should_receive(:nextid).never
    @obj = ActiveFedora::UnsavedDigitalObject.new(ActiveFedora::Base, 'id')
    @obj.save
  end
  it "should allow objects to override ARK-style pid generation" do
    mock_pid = 'scholarsphere:ef12ef12f'
    @obj = ActiveFedora::UnsavedDigitalObject.new(ActiveFedora::Base, 'id', mock_pid)
    @obj.pid.should == mock_pid
  end
  it "should not assign a new pid if a pid was specified at instantiation" do
    mock_pid = 'scholarsphere:ef12ef12f'
    @obj = ActiveFedora::UnsavedDigitalObject.new(ActiveFedora::Base, 'id', mock_pid)
    @obj.assign_pid
    @obj.pid.should == mock_pid
  end
  it "should not assign a pid that already exists in Fedora" do
    mock_pid = 'scholarsphere:ef12ef12f'
    unique_pid = 'scholarsphere:bb22bb22b'
    Sufia::IdService.stub(:next_id).and_return(mock_pid, unique_pid)
    ActiveFedora::Base.stub(:exists?).with(mock_pid).and_return(true)
    ActiveFedora::Base.stub(:exists?).with(unique_pid).and_return(false)
    @obj = ActiveFedora::UnsavedDigitalObject.new(ActiveFedora::Base, 'id')
    pid = @obj.assign_pid
    @obj.pid.should == unique_pid
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
sufia-4.0.0.rc1 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-4.0.0.beta4 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-4.0.0.beta3 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-4.0.0.beta2 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-4.0.0.beta1 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.7.2 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.7.1 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.7.0 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.6.1 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.6.0 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.5.0 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.4.0 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.4.0.rc4 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.4.0.rc3 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.3.1 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.4.0.rc2 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.4.0.rc1 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.3.0 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.2.1 spec/active_fedora/unsaved_digital_object_spec.rb
sufia-3.1.3 spec/active_fedora/unsaved_digital_object_spec.rb