Sha256: 09e5f9a83123dd903389f80e51bce9285382cb5bc7664eaf0d1676003bcb899e

Contents?: true

Size: 1.58 KB

Versions: 25

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe ActiveFedora::Model do
  
  before(:all) do
    module SpecModel
      class Basic < ActiveFedora::Base
      end
    end
    @model_query = "has_model_s:#{solr_uri("info:fedora/afmodel:SpecModel_Basic")}"
  end
  
  after(:all) do
    Object.send(:remove_const, :SpecModel)
  end
  
  describe '.solr_query_handler' do
    after do
      # reset to default
      SpecModel::Basic.solr_query_handler = 'standard'
    end
    it "should have a default" do
      SpecModel::Basic.solr_query_handler.should == 'standard'
    end
    it "should be settable" do
      SpecModel::Basic.solr_query_handler = 'search'
      SpecModel::Basic.solr_query_handler.should == 'search'
    end
  end
  
  describe "URI translation" do
    before :all do
      module SpecModel
        class CamelCased
          include ActiveFedora::Model
        end
      end
    end
    
    after :all do
      SpecModel.send(:remove_const, :CamelCased)
    end
    subject {SpecModel::CamelCased}
  
    describe ".classname_from_uri" do 
      it "should turn an afmodel URI into a Model class name" do
        ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:SpecModel_CamelCased').should == ['SpecModel::CamelCased', 'afmodel']
      end
      it "should not change plurality" do
        ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:MyMetadata').should == ['MyMetadata', 'afmodel']
      end
      it "should capitalize the first letter" do
        ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:image').should == ['Image', 'afmodel']
      end
    end
  end
  
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
active-fedora-7.3.1 spec/unit/model_spec.rb
active-fedora-7.3.0 spec/unit/model_spec.rb
active-fedora-8.2.1 spec/unit/model_spec.rb
active-fedora-8.2.0 spec/unit/model_spec.rb
active-fedora-7.2.0 spec/unit/model_spec.rb
active-fedora-8.1.0 spec/unit/model_spec.rb
active-fedora-8.0.1 spec/unit/model_spec.rb
active-fedora-8.0.0 spec/unit/model_spec.rb
active-fedora-8.0.0.rc3 spec/unit/model_spec.rb
active-fedora-8.0.0.rc2 spec/unit/model_spec.rb
active-fedora-8.0.0.rc1 spec/unit/model_spec.rb
active-fedora-7.1.2 spec/unit/model_spec.rb
active-fedora-7.1.1 spec/unit/model_spec.rb
active-fedora-7.1.0 spec/unit/model_spec.rb
active-fedora-7.0.4 spec/unit/model_spec.rb
active-fedora-7.0.3 spec/unit/model_spec.rb
active-fedora-7.0.2 spec/unit/model_spec.rb
active-fedora-7.0.1 spec/unit/model_spec.rb
active-fedora-7.0.0 spec/unit/model_spec.rb
active-fedora-7.0.0.rc3 spec/unit/model_spec.rb