Sha256: 93a9e5300cd80520429c3f7727b5731b8ac47ae3d721ae4b1eaa7f144aa54305

Contents?: true

Size: 1.71 KB

Versions: 28

Compression:

Stored size: 1.71 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Hydra::ModelMethods do
  
  before :all do
    class TestModel < ActiveFedora::Base
      include Hydra::ModelMixins::CommonMetadata
      include Hydra::ModelMethods
      has_metadata :name => "properties", :type => Hydra::Datastream::Properties
    end
  end

  subject {TestModel.new }

  describe "apply_depositor_metadata" do
    it "should add edit access" do
      subject.apply_depositor_metadata('naomi')
      subject.rightsMetadata.individuals.should == {'naomi' => 'edit'}
    end
    it "should not overwrite people with edit access" do
      subject.rightsMetadata.permissions({:person=>"jessie"}, 'edit')
      subject.apply_depositor_metadata('naomi')
      subject.rightsMetadata.individuals.should == {'naomi' => 'edit', 'jessie' =>'edit'}
    end
    it "should set depositor" do
      subject.apply_depositor_metadata('chris')
      subject.properties.depositor.should == ['chris']
    end
    it "should accept objects that respond_to? :user_key" do
      stub_user = stub(:user, :user_key=>'monty')
      subject.apply_depositor_metadata(stub_user)
      subject.properties.depositor.should == ['monty']
    end
  end

  describe 'add_file' do
    it "should set the dsid, mimetype and content" do
      file_name = "my_file.foo"
      mock_file = "File contents"
      subject.should_receive(:add_file_datastream).with(mock_file, :label=>file_name, :mimeType=>"mymimetype", :dsid=>'bar')
      subject.should_receive(:set_title_and_label).with( file_name, :only_if_blank=>true )
      MIME::Types.should_receive(:of).with(file_name).and_return([stub(:content_type=>"mymimetype")])
      subject.add_file(mock_file, 'bar', file_name)
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
hydra-core-5.4.1 spec/lib/model_methods_spec.rb
hydra-core-6.3.4 spec/lib/model_methods_spec.rb
hydra-core-6.3.3 spec/lib/model_methods_spec.rb
hydra-core-6.3.2 spec/lib/model_methods_spec.rb
hydra-core-6.3.1 spec/lib/model_methods_spec.rb
hydra-core-6.3.0 spec/lib/model_methods_spec.rb
hydra-core-6.3.0.rc1 spec/lib/model_methods_spec.rb
hydra-core-6.2.2 spec/lib/model_methods_spec.rb
hydra-core-6.2.1 spec/lib/model_methods_spec.rb
hydra-core-6.2.0 spec/lib/model_methods_spec.rb
hydra-core-6.1.1 spec/lib/model_methods_spec.rb
hydra-core-6.1.0 spec/lib/model_methods_spec.rb
hydra-core-6.0.0 spec/lib/model_methods_spec.rb
hydra-core-6.0.0.rc4 spec/lib/model_methods_spec.rb
hydra-core-6.0.0.rc3 spec/lib/model_methods_spec.rb
hydra-core-6.0.0.rc2 spec/lib/model_methods_spec.rb
hydra-core-6.0.0.rc1 spec/lib/model_methods_spec.rb
hydra-core-6.0.0.pre8 spec/lib/model_methods_spec.rb
hydra-core-5.4.0 spec/lib/model_methods_spec.rb
hydra-core-6.0.0.pre7 spec/lib/model_methods_spec.rb