Sha256: 6099fa7b15cf9310d84d83c570cd472e1114189a87630845fcb1b9e30da9e904

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe ActiveFedora::Base do
  before do
    class MyDS < ActiveFedora::OmDatastream
    end
    class Foo < ActiveFedora::Base
      extend Deprecation
      has_subresource 'foostream', class_name: 'MyDS'
      has_subresource 'dcstream', class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
    end
    class Bar < ActiveFedora::Base
      extend Deprecation
      has_subresource 'barstream', class_name: 'MyDS'
    end
  end

  it "doesn't overwrite stream specs" do
    f = Foo.new
    expect(f.attached_files.size).to eq 2
    streams = f.attached_files.values.map { |x| x.class.to_s }.sort
    expect(streams.pop).to eq "MyDS"
    expect(streams.pop).to eq "ActiveFedora::QualifiedDublinCoreDatastream"
  end

  it "works for multiple types" do
    b = Foo.new
    f = Bar.new
    Deprecation.silence(Foo) do
      Deprecation.silence(Bar) do
        expect(b.class.ds_specs).to_not eq f.class.ds_specs
      end
    end
  end

  after do
    Object.send(:remove_const, :Bar)
    Object.send(:remove_const, :Foo)
    Object.send(:remove_const, :MyDS)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active-fedora-9.13.0 spec/unit/inheritance_spec.rb