Sha256: 3476af9703cf8ca7f00ae8e7601c19ed88e7b9020d4ed1174e88925ee9f8f7d4

Contents?: true

Size: 1.51 KB

Versions: 7

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

describe CurationConcerns::WorkBehavior do
  before do
    class EssentialWork < ActiveFedora::Base
      include CurationConcerns::WorkBehavior
    end
  end
  after do
    Object.send(:remove_const, :EssentialWork)
  end

  subject { EssentialWork.new }

  it 'mixes together all the goodness' do
    [::CurationConcerns::WithFileSets, ::CurationConcerns::HumanReadableType, CurationConcerns::Noid, CurationConcerns::Serializers, Hydra::WithDepositor, Hydra::AccessControls::Embargoable, Solrizer::Common].each do |mixin|
      expect(subject.class.ancestors).to include(mixin)
    end
  end
  describe '#to_s' do
    it 'uses the provided titles' do
      # The title property would return the terms in random order, so stub the behavior:
      allow(subject).to receive(:title).and_return(%w(Hello World))
      expect(subject.to_s).to eq('Hello | World')
    end
  end

  describe 'human_readable_type' do
    it 'has a default' do
      expect(subject.human_readable_type).to eq 'Essential Work'
    end
    it 'is settable' do
      EssentialWork.human_readable_type = 'Custom Type'
      expect(subject.human_readable_type).to eq 'Custom Type'
    end
  end

  it 'inherits (and extends) to_solr behaviors from superclass' do
    expect(subject.to_solr.keys).to include(:id)
    expect(subject.to_solr.keys).to include('has_model_ssim')
  end

  describe 'indexer' do
    let(:klass) { Class.new }
    it 'is settable' do
      EssentialWork.indexer = klass
      expect(subject.indexer).to eq klass
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
curation_concerns-1.7.0.beta1 spec/models/curation_concerns/work_behavior_spec.rb
curation_concerns-1.6.3 spec/models/curation_concerns/work_behavior_spec.rb
curation_concerns-1.6.2 spec/models/curation_concerns/work_behavior_spec.rb
curation_concerns-1.6.1 spec/models/curation_concerns/work_behavior_spec.rb
curation_concerns-1.6.0 spec/models/curation_concerns/work_behavior_spec.rb
curation_concerns-1.5.0 spec/models/curation_concerns/work_behavior_spec.rb
curation_concerns-1.4.0 spec/models/curation_concerns/work_behavior_spec.rb