Sha256: 4480081d6fee92064f0beef82b7d97bbe2dfee21112b39814d68d62a324c0815

Contents?: true

Size: 1.34 KB

Versions: 30

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

require 'active_fedora'
require 'active_fedora/base'
require 'active_fedora/metadata_datastream'
require 'active_fedora/qualified_dublin_core_datastream'

describe ActiveFedora::Base do
  before(:each) do
    #Fedora::Repository.instance.stubs(:nextid).returns("_nextid_")
    class Foo < ActiveFedora::Base
      has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"foostream" do|m|
        m.field "foostream", :string
      end
      has_metadata :type=>ActiveFedora::QualifiedDublinCoreDatastream, :name=>"dcstream" do|m|
        m.field "fz", :string
      end
    end
    class Bar  < ActiveFedora::Base
      has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"barstream" do |m|
        m.field "barfield", :string
      end
    end
  end

  it "doesn't overwrite stream specs" do
    f = Foo.new
    f.datastreams.size.should == 3
    streams = f.datastreams.values.map{|x| x.class.to_s}.sort
    streams.pop.should == "ActiveFedora::RelsExtDatastream"
    streams.pop.should == "ActiveFedora::QualifiedDublinCoreDatastream"
    streams.pop.should == "ActiveFedora::MetadataDatastream"
  end

  it "should work for multiple types" do
    b = Foo.new
    f = Bar.new
    b.class.ds_specs.should_not == f.class.ds_specs
  end
  after do
    Object.send(:remove_const, :Bar)
    Object.send(:remove_const, :Foo)
  end

end
  

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
active-fedora-4.0.0.rc16 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc15 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc14 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc13 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc12 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc11 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc10 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc9 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc8 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc7 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc6 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc5 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc4 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc3 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc2 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc1 spec/unit/inheritance_spec.rb
active-fedora-3.3.2 spec/unit/inheritance_spec.rb
active-fedora-3.3.1 spec/unit/inheritance_spec.rb
active-fedora-3.3.0 spec/unit/inheritance_spec.rb
active-fedora-3.2.2 spec/unit/inheritance_spec.rb