Sha256: 2026d24f009d7f2bb443649f8a6f1b763a0bd8ae3b8f1afa9fbf2383c511fe99

Contents?: true

Size: 1.72 KB

Versions: 45

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

describe ActiveFedora::Base do

  describe "active model methods" do 
    class BarStream < ActiveFedora::OmDatastream 
      set_terminology do |t|
        t.root(:path=>"first", :xmlns=>"urn:foobar")
        t.duck()
      end

      def self.xml_template
            Nokogiri::XML::Document.parse '<first xmlns="urn:foobar"> 
              <duck></duck>
            </first>'
      end
    end

    class BarHistory < ActiveFedora::Base
      has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"someData" do |m|
        m.field "fubar", :string
        m.field "swank", :text
      end
      has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"withText" do |m|
        m.field "fubar", :text
      end
      has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"withText2", :label=>"withLabel" do |m|
        m.field "fubar", :text
      end 

      has_metadata :type=>BarStream, :name=>"xmlish"
      delegate :fubar, :to=>'withText', :unique=>true
      delegate :duck, :to=>'xmlish', :unique=>true
    end
    before :each do
      @n = BarHistory.new()
    end
    describe "attributes=" do
      it "should set attributes" do
        @n.attributes = {:fubar=>"baz", :duck=>"Quack"}
        @n.fubar.should == "baz"
        @n.withText.get_values(:fubar).first.should == 'baz'
        @n.duck.should == "Quack"
        @n.xmlish.term_values(:duck).first.should == 'Quack'
      end
    end
    describe "update_attributes" do
      it "should set attributes and save " do
        @n.update_attributes(:fubar=>"baz", :duck=>"Quack")
        @q = BarHistory.find(@n.pid)
        @q.fubar.should == "baz"
        @q.duck.should == "Quack"
      end
      after do
        @n.delete
      end
    end

  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
active-fedora-5.7.1 spec/unit/base_active_model_spec.rb
active-fedora-5.7.0 spec/unit/base_active_model_spec.rb
active-fedora-6.4.3 spec/unit/base_active_model_spec.rb
active-fedora-6.4.2 spec/unit/base_active_model_spec.rb
active-fedora-6.4.1 spec/unit/base_active_model_spec.rb
active-fedora-6.4.0 spec/unit/base_active_model_spec.rb
active-fedora-6.4.0.rc4 spec/unit/base_active_model_spec.rb
active-fedora-6.4.0.rc3 spec/unit/base_active_model_spec.rb
active-fedora-6.4.0.rc2 spec/unit/base_active_model_spec.rb
active-fedora-6.4.0.rc1 spec/unit/base_active_model_spec.rb
active-fedora-6.3.0 spec/unit/base_active_model_spec.rb
active-fedora-6.2.0 spec/unit/base_active_model_spec.rb
active-fedora-6.1.1 spec/unit/base_active_model_spec.rb
active-fedora-6.1.0 spec/unit/base_active_model_spec.rb
active-fedora-5.6.3 spec/unit/base_active_model_spec.rb
active-fedora-6.0.0 spec/unit/base_active_model_spec.rb
active-fedora-6.0.0.rc7 spec/unit/base_active_model_spec.rb
active-fedora-6.0.0.rc6 spec/unit/base_active_model_spec.rb
active-fedora-6.0.0.rc5 spec/unit/base_active_model_spec.rb
active-fedora-6.0.0.rc4 spec/unit/base_active_model_spec.rb