Sha256: 08bfc61fa6eaff227fa45b614afa47bdbab2bc9f11b2ab4d1615455919130d3d

Contents?: true

Size: 1.73 KB

Versions: 20

Compression:

Stored size: 1.73 KB

Contents

require File.expand_path( File.join( File.dirname(__FILE__),'..','spec_helper') )

require "hydra"

class FakeAssetsController
  include MediaShelf::ActiveFedoraHelper
end

def helper
  @fake_controller
end

describe MediaShelf::ActiveFedoraHelper do

  before(:all) do
    @fake_controller = FakeAssetsController.new
  end
  
  describe "retrieve_af_model" do
    it "should return a Model class if the named model has been defined" do
      result = helper.retrieve_af_model("file_asset")
      result.should == FileAsset
      result.superclass.should == ActiveFedora::Base
      result.included_modules.should include(ActiveFedora::Model) 
    end
    
    it "should accept camel cased OR underscored model name" do
       result = helper.retrieve_af_model("generic_content")
       result.should == GenericContent
        
       result = helper.retrieve_af_model("GenericContent")
       result.should == GenericContent
    
    end
    
    it "should return false if the name is not a real class" do
       result = helper.retrieve_af_model("foo_foo_class_class")
       result.should be_false
    end
    
  end

  describe "load_af_instance_from_solr" do
    it "should return an ActiveFedora object given a valid solr doc same as loading from Fedora" do
      pid = "hydrangea:fixture_mods_article1"
      result = ActiveFedora::Base.find_by_solr(pid)
      solr_doc = result.hits.first 
      solr_af_obj = helper.load_af_instance_from_solr(solr_doc)
      fed_af_obj = ActiveFedora::Base.load_instance(pid)
      #check both inbound and outbound match
      fed_af_obj.outbound_relationships.to_hash.should == solr_af_obj.outbound_relationships.to_hash
      fed_af_obj.inbound_relationships.should == solr_af_obj.inbound_relationships
    end
  end
  
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
hydra-head-3.3.0 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.2.2 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.2.1 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.2.0 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.2.0.pre3 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.2.0.pre2 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.2.0.pre1 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.1.5 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.1.4 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.1.3 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.1.2 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.1.1 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.1.0 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.1.0.rc2 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.1.0.rc1 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.1.0.pre5 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.1.0.pre4 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.1.0.pre3 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.1.0.pre2 test_support/spec/lib/active_fedora_helper_spec.rb
hydra-head-3.1.0.pre1 test_support/spec/lib/active_fedora_helper_spec.rb