Skip to content

Commit

Permalink
indexer setup, including fixes / tests for activefedoraconverter and …
Browse files Browse the repository at this point in the history
…modeltransformer

monograph indexer spec
  • Loading branch information
Julie Allinson committed Jan 25, 2020
1 parent ac568f8 commit 0b21d22
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 27 deletions.
1 change: 1 addition & 0 deletions app/indexers/hyrax/valkyrie_work_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ class ValkyrieWorkIndexer < Hyrax::ValkyrieIndexer
include Hyrax::PermissionIndexer
include Hyrax::VisibilityIndexer
include Hyrax::Indexer(:core_metadata)
include Hyrax::Indexer(:basic_metadata)
end
end
114 changes: 87 additions & 27 deletions config/metadata/basic_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,131 @@ attributes:
abstract:
type: string
multiple: true
access_right:
index_keys:
- "abstract_sim"
- "abstract_tesim"
creator:
type: string
multiple: true
alternative_title:
index_keys:
- "creator_sim"
- "creator_tesim"
contributor:
type: string
multiple: true
based_near:
index_keys:
- "contributor_sim"
- "contributor_tesim"
subject:

This comment has been minimized.

Copy link
@no-reply

no-reply Jan 28, 2020

Contributor

is it worthwhile to alphabetize?

type: string
multiple: true
bibliographic_citation:
index_keys:
- "subject_sim"
- "subject_tesim"
publisher:
type: string
multiple: true
contributor:
index_keys:
- "publisher_sim"
- "publisher_tesim"
language:
type: string
multiple: true
creator:
index_keys:
- "language_sim"
- "language_tesim"
identifier:
type: string
multiple: true
index_keys:
- "identifier_sim"
- "identifier_tesim"
keyword:
type: string
multiple: true
index_keys:
- "keyword_sim"
- "keyword_tesim"
date_created:
type: date_time
multiple: true
description:
index_keys:
- "date_created_sim"
- "date_created_tesim"
related_url:
type: string
multiple: true
identifier:
index_keys:
- "related_url_sim"
- "related_url_tesim"
resource_type:
type: string
multiple: true
import_url:
type: string
keyword:
index_keys:
- "resource_type_sim"
- "resource_type_tesim"
source:
type: string
multiple: true
index_keys:
- "keyword_sim"
publisher:
- "source_sim"
- "source_tesim"
rights_statement:
type: string
multiple: true
label:
index_keys:
- "rights_statement_sim"
- "rights_statement_tesim"
rights_notes:
type: string
language:
multiple: true
index_keys:
- "rights_notes_sim"
- "rights_notes_tesim"
access_right:
type: string
multiple: true
index_keys:
- "access_right_sim"
- "access_right_tesim"
license:
type: string
multiple: true
relative_path:
type: string
related_url:
index_keys:
- "license_sim"
- "license_tesim"
alternative_title:
type: string
multiple: true
resource_type:
index_keys:
- "alternative_title_sim"
- "alternative_title_tesim"
based_near:
type: string
multiple: true
rights_notes:
bibliographic_citation:
type: string
multiple: true
rights_statement:
index_keys:
- "bibliographic_citation_sim"
- "bibliographic_citation_tesim"
description:
type: string
multiple: true
source:
index_keys:
- "description_sim"
- "description_tesim"
import_url:
type: string
multiple: true
subject:
index_keys:
- "import_url_sim"
- "import_url_tesim"
label:
type: string
multiple: true
index_keys:
- "subject_sim"
- "subject_tesim"
- "label_sim"
- "label_tesim"
relative_path:
type: string
index_keys:
- "relative_path_sim"
2 changes: 2 additions & 0 deletions spec/factories/hyrax_work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@
members { [valkyrie_create(:hyrax_work), valkyrie_create(:hyrax_work)] }
end
end

factory :monograph, class: 'Monograph'
end
end
33 changes: 33 additions & 0 deletions spec/indexers/hyrax/monograph_indexer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require 'hyrax/specs/shared_specs'

RSpec.describe MonographIndexer do
let(:indexer) { described_class.new(resource: resource) }
let(:resource) { build(:monograph) }
let(:indexer_class) { described_class }
let(:solr_document) { {} } # for now
let(:change_set) { Hyrax::ChangeSet.for(resource) }

it 'has resource' do
expect(indexer.resource).to eq resource
end

context '#to_solr' do
before do
change_set.title = 'comet in moominland'

This comment has been minimized.

Copy link
@no-reply

no-reply Jan 28, 2020

Contributor

would it be just as well to do let(:resource) { build(:monograph, title: 'comet in moominland', creator: 'Tove Jansson') } abeve, and drop changeset behavior from this spec setup?

change_set.creator = 'Tove Jansson'
change_set.sync
end

it 'Indexes core_metadata' do
expect(indexer.to_solr[:title_sim]).to eq resource.title
expect(indexer.to_solr[:title_tesim]).to eq resource.title
end

it 'Indexes basic_metadata' do
expect(indexer.to_solr[:creator_sim]).to eq resource.creator
expect(indexer.to_solr[:creator_tesim]).to eq resource.creator
end
end
end
11 changes: 11 additions & 0 deletions spec/indexers/hyrax/valkyrie_indexer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
.to be_a indexer_class
end
end

# Fails unless MonographIndexer has been pre-loaded

This comment has been minimized.

Copy link
@no-reply

no-reply Jan 28, 2020

Contributor

i suppose we could move the registration into an initializer, instead of running it in class definition?

context 'with registered Monograph indexer' do
let(:resource) { build(:monograph) }
let(:indexer_class) { MonographIndexer }

it 'gives an instance of MonographIndexer for Monograph' do
expect(described_class.for(resource: resource))
.to be_a indexer_class
end
end
end

describe "#to_solr" do
Expand Down

0 comments on commit 0b21d22

Please sign in to comment.