Sha256: c92b07d1216020e401bc21e418f86847ce5dd706900aa8bbc0b55788def7d4e6

Contents?: true

Size: 1.75 KB

Versions: 4

Compression:

Stored size: 1.75 KB

Contents

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


# See cucumber tests (ie. /features/edit_document.feature) for more tests, including ones that test the edit method & view
# You can run the cucumber tests with 
#
# cucumber --tags @edit
# or
# rake cucumber

describe Hydra::Controller::RepositoryControllerBehavior do
  
  describe "load_document_from_params" do
    it "should choose which model to use based on submitted params" do
      mock_model_class = mock("model class")
      mock_model_class.expects(:find).with("object id")
      helper.stubs(:params).returns( {:content_type => "preferred model", :id => "object id"} )
      helper.expects(:retrieve_af_model).with("preferred model").returns(mock_model_class)
      helper.load_document_from_params
    end
  end
  
  describe "format_pid" do
    it "convert pids into XHTML safe strings" do 
     pid = helper.format_pid("hydra:123")
     pid.should match(/hydra_123/)   
    end 
  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

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hydra-head-4.1.3 test_support/spec/helpers/hydra-repository_controller_spec.rb
hydra-head-4.1.2 test_support/spec/helpers/hydra-repository_controller_spec.rb
hydra-head-4.1.1 test_support/spec/helpers/hydra-repository_controller_spec.rb
hydra-head-4.1.0 test_support/spec/helpers/hydra-repository_controller_spec.rb