Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #333 from sul-dlss/configure-collection
Browse files Browse the repository at this point in the history
Configure an indexer for a collection
  • Loading branch information
mjgiarlo committed Jan 29, 2020
2 parents 39f00c6 + 9bde22a commit 6b70970
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/services/indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ class Indexer
WorkflowsIndexer
)

COLLECTION_INDEXER = CompositeIndexer.new(
DataIndexer,
DescribableIndexer,
IdentifiableIndexer,
ProcessableIndexer,
ReleasableIndexer,
WorkflowsIndexer
)

ETD_INDEXER = CompositeIndexer.new(
DataIndexer
)
Expand All @@ -40,8 +49,10 @@ class Indexer
)

INDEXERS = {
Dor::Agreement => ITEM_INDEXER, # Agreement uses same indexer as Dor::Item
Dor::WorkflowObject => WORKFLOW_INDEXER,
Dor::AdminPolicyObject => ADMIN_POLICY_INDEXER,
Dor::Collection => COLLECTION_INDEXER,
Dor::Etd => ETD_INDEXER,
Dor::Item => ITEM_INDEXER,
Dor::Set => SET_INDEXER
Expand Down
25 changes: 25 additions & 0 deletions spec/services/indexer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Indexer do
subject(:indexer) { described_class.for(model) }

context 'when the model is an item' do
let(:model) { Dor::Item.new }

it { is_expected.to be_instance_of CompositeIndexer::Instance }
end

context 'when the model is a collection' do
let(:model) { Dor::Collection.new }

it { is_expected.to be_instance_of CompositeIndexer::Instance }
end

context 'when the model is an agreement' do
let(:model) { Dor::Agreement.new }

it { is_expected.to be_instance_of CompositeIndexer::Instance }
end
end

0 comments on commit 6b70970

Please sign in to comment.