Sha256: a4bde998d283eabf8fcaacdf1a289ca785c8ed6f9838a8b5e82cf191916244a4

Contents?: true

Size: 1.99 KB

Versions: 12

Compression:

Stored size: 1.99 KB

Contents

require 'spec_helper'

describe ActiveFedora::Base do

  before(:all) do
    class HydrangeaArticle < ActiveFedora::Base
      include ActiveFedora::Relationships
      has_relationship "parts", :is_part_of, :inbound => true

      # Uses the Hydra Rights Metadata Schema for tracking access permissions & copyright
      # has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadata 

      # Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
      has_metadata :name => "descMetadata", :type => Hydra::ModsArticleDatastream 

      # A place to put extra metadata values
      has_metadata :name => "properties", :type => ActiveFedora::MetadataDatastream do |m|
        m.field 'collection', :string
      end
    end
  end
  
  before(:each) do
    @test_article = HydrangeaArticle.find("hydrangea:fixture_mods_article1")
  end
  
  describe ".update_indexed_attributes" do
    before(:each) do
      @test_article.update_indexed_attributes({[{:person=>0}, :first_name] => "GIVEN NAMES"}, :datastreams=>"descMetadata")
    end
    after(:each) do
      @test_article.update_indexed_attributes({[{:person=>0}, :first_name] => "GIVEN NAMES"}, :datastreams=>"descMetadata")
    end
    it "should update the xml in the specified datatsream and save those changes to Fedora" do
      @test_article.get_values_from_datastream("descMetadata", [{:person=>0}, :first_name]).should == ["GIVEN NAMES"]
      test_args = {:params=>{[{:person=>0}, :first_name]=>{"0"=>"Replacement FirstName"}}, :opts=>{:datastreams=>"descMetadata"}}
      @test_article.update_indexed_attributes(test_args[:params], test_args[:opts])
      @test_article.get_values_from_datastream("descMetadata", [{:person=>0}, :first_name]).should == ["Replacement FirstName"]
      @test_article.save
      retrieved_article = HydrangeaArticle.find("hydrangea:fixture_mods_article1")
      retrieved_article.get_values_from_datastream("descMetadata", [{:person=>0}, :first_name]).should == ["Replacement FirstName"]
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
active-fedora-4.0.0.rc13 spec/integration/mods_article_integration_spec.rb
active-fedora-4.0.0.rc12 spec/integration/mods_article_integration_spec.rb
active-fedora-4.0.0.rc11 spec/integration/mods_article_integration_spec.rb
active-fedora-4.0.0.rc10 spec/integration/mods_article_integration_spec.rb
active-fedora-4.0.0.rc9 spec/integration/mods_article_integration_spec.rb
active-fedora-4.0.0.rc8 spec/integration/mods_article_integration_spec.rb
active-fedora-4.0.0.rc7 spec/integration/mods_article_integration_spec.rb
active-fedora-4.0.0.rc6 spec/integration/mods_article_integration_spec.rb
active-fedora-4.0.0.rc5 spec/integration/mods_article_integration_spec.rb
active-fedora-4.0.0.rc4 spec/integration/mods_article_integration_spec.rb
active-fedora-4.0.0.rc3 spec/integration/mods_article_integration_spec.rb
active-fedora-4.0.0.rc2 spec/integration/mods_article_integration_spec.rb