Skip to content

Commit

Permalink
add collection_type_gid attribute to Hyrax::AdministrativeSets
Browse files Browse the repository at this point in the history
Collection type gid is required for listing admin sets at Dashboard -> Collections.  This is what identifies this as an admin set.
  • Loading branch information
elrayle committed Jan 31, 2022
1 parent 54b6f04 commit 838a554
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
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

0 comments on commit 838a554

Please sign in to comment.