Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add collection_type_gid attribute to Hyrax::AdministrativeSets #5422

Merged
merged 1 commit into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/indexers/hyrax/administrative_set_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class AdministrativeSetIndexer < Hyrax::ValkyrieIndexer

def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
super.tap do |solr_doc|
solr_doc[Hyrax.config.collection_type_index_field.to_sym] = Array(resource.try(:collection_type_gid)&.to_s)
solr_doc[:alternative_title_tesim] = resource.alternative_title
solr_doc[:creator_ssim] = [resource.creator]
solr_doc[:creator_tesim] = [resource.creator]
Expand Down
10 changes: 6 additions & 4 deletions lib/hyrax/specs/shared_specs/hydra_works.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,12 @@
.to contain_exactly('lorem ipsum')
end

it 'has an #title' do
expect { admin_set.title = ['Moomin'] }
.to change { admin_set.title }
.to contain_exactly('Moomin')
describe '#collection_type_gid' do
let(:gid) { Hyrax::CollectionType.find_or_create_admin_set_type.to_global_id }

it 'has a GlobalID for a collection type' do
expect(admin_set.collection_type_gid).to eq gid
end
end
end

Expand Down
5 changes: 5 additions & 0 deletions lib/hyrax/specs/shared_specs/indexers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@
it_behaves_like 'a visibility indexer'

describe '#to_solr' do
it 'indexes collection type gid' do
expect(indexer.to_solr)
.to include(collection_type_gid_ssim: a_collection_containing_exactly(an_instance_of(String)))
end

it 'indexes generic type' do
expect(indexer.to_solr)
.to include(generic_type_sim: a_collection_containing_exactly('Admin Set'))
Expand Down