Sha256: 3c45e74bfca8ccfe28201a31ef3be50b4ca50695faba43f3f4ab1633456f45c4

Contents?: true

Size: 905 Bytes

Versions: 2

Compression:

Stored size: 905 Bytes

Contents

require 'spec_helper'

describe Sufia::IdService do
  describe "mint" do
    subject { Sufia::IdService.mint }

    it { is_expected.not_to be_empty }

    it "should not mint the same id twice in a row" do
      expect(Sufia::IdService.mint).to_not eq subject
    end

    it "should be valid" do
      expect(Sufia::IdService.valid?(subject)).to be true
    end

    context "when the pid already exists in Fedora" do
      let(:mock_pid) { 'ef12ef12f' }
      let(:unique_pid) { 'bb22bb22b' }

      before do
        allow(Sufia::IdService).to receive(:next_id).and_return(mock_pid, unique_pid)
        expect(ActiveFedora::Base).to receive(:exists?).with(mock_pid).and_return(true)
        expect(ActiveFedora::Base).to receive(:exists?).with(unique_pid).and_return(false)
      end

      it "should not assign that pid again" do
        expect(subject).to eq unique_pid
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sufia-6.0.0.rc4 spec/lib/sufia/id_service_spec.rb
sufia-6.0.0.rc3 spec/lib/sufia/id_service_spec.rb