Sha256: 8b773d8dd73fe92ca71b384101aeb1c80079b305cad39cda070534c7f3456c51
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
require 'spec_helper' describe Sufia::Migration::Survey::FedoraIdService do it { is_expected.to respond_to(:register_model) } it { is_expected.to respond_to(:call) } let(:service) { described_class.new } describe "default registry" do subject { service.model_registry } it { is_expected.to eq([::GenericFile, ::Collection]) } end describe "#register_model" do subject { service.model_registry } let(:model_class) { TestModel } before do class TestModel < ActiveFedora::Base; end end after do Object.send(:remove_const, :TestModel) end it "registers a model" do service.register_model(model_class) is_expected.to include(model_class) end it "registers a model once" do service.register_model(model_class) service.register_model(model_class) expect(subject.count(model_class)).to eq(1) end context "invalid model" do let(:model_class) { String } it "throws an error" do expect { service.register_model(model_class) }.to raise_error(Sufia::Migration::Survey::RegistryError) is_expected.not_to include(model_class) end end end describe "#call" do let!(:file) { create :generic_file } let!(:collection) do Collection.create(title: "title1", creator: ["creator1"], description: "description1") do |col| col.apply_depositor_metadata("jilluser") end end subject { service.call } it "finds the model ids" do is_expected.to include(file.id, collection.id) subject.count eq 2 end context "we only want a limited set" do subject { service.call(1) } it "finds the model ids" do is_expected.to include(file.id) subject.count eq 1 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sufia-6.7.0 | spec/lib/sufia/migration/survey_fedora_id_service_spec.rb |