diff --git a/app/search_builders/hyrax/dashboard/collections_search_builder.rb b/app/search_builders/hyrax/dashboard/collections_search_builder.rb index 40782f209e..f356f643e2 100644 --- a/app/search_builders/hyrax/dashboard/collections_search_builder.rb +++ b/app/search_builders/hyrax/dashboard/collections_search_builder.rb @@ -9,7 +9,7 @@ class CollectionsSearchBuilder < Hyrax::CollectionSearchBuilder # This overrides the models in FilterByType def models - [::AdminSet, ::Collection, Hyrax.config.collection_model.safe_constantize].uniq.compact + [::AdminSet, ::Collection, Hyrax.config.collection_class].uniq.compact end # adds a filter to exclude collections and admin sets created by the diff --git a/app/search_builders/hyrax/my/collections_search_builder.rb b/app/search_builders/hyrax/my/collections_search_builder.rb index f08ec16c99..28aeb0f3a0 100644 --- a/app/search_builders/hyrax/my/collections_search_builder.rb +++ b/app/search_builders/hyrax/my/collections_search_builder.rb @@ -21,6 +21,6 @@ def show_only_collections_deposited_by_current_user(solr_parameters) # This overrides the models in FilterByType # @return [Array] a list of classes to include def models - [::AdminSet, Hyrax::AdministrativeSet, Hyrax.config.collection_model.safe_constantize].compact + [::AdminSet, Hyrax::AdministrativeSet, ::Collection, Hyrax.config.collection_class].uniq.compact end end diff --git a/lib/hyrax/configuration.rb b/lib/hyrax/configuration.rb index dd96d2009a..38929db1d7 100644 --- a/lib/hyrax/configuration.rb +++ b/lib/hyrax/configuration.rb @@ -707,7 +707,7 @@ def collection_model ## # @return [Class] the configured collection model class def collection_class - collection_model.constantize + collection_model.safe_constantize end attr_writer :admin_set_model diff --git a/spec/search_builders/hyrax/collection_search_builder_spec.rb b/spec/search_builders/hyrax/collection_search_builder_spec.rb index 04c94b0908..ad43678c2e 100644 --- a/spec/search_builders/hyrax/collection_search_builder_spec.rb +++ b/spec/search_builders/hyrax/collection_search_builder_spec.rb @@ -14,6 +14,14 @@ is_expected .to contain_exactly(*[::Collection, Hyrax.config.collection_class].uniq) end + + context 'when collection class is not ::Collection' do + before { allow(Hyrax.config).to receive(:collection_model).and_return('Hyrax::PcdmCollection') } + its(:models) do + is_expected + .to contain_exactly(*[::Collection, Hyrax::PcdmCollection].uniq) + end + end end describe '#discovery_permissions' do diff --git a/spec/search_builders/hyrax/my/collections_search_builder_spec.rb b/spec/search_builders/hyrax/my/collections_search_builder_spec.rb index 5d73823e05..7b8a53a72f 100644 --- a/spec/search_builders/hyrax/my/collections_search_builder_spec.rb +++ b/spec/search_builders/hyrax/my/collections_search_builder_spec.rb @@ -19,6 +19,16 @@ Hyrax::AdministrativeSet, Hyrax.config.collection_class) end + + context 'when collection class is something other than ::Collection' do + before { allow(Hyrax.config).to receive(:collection_model).and_return('Hyrax::PcdmCollection') } + it do + is_expected.to contain_exactly(AdminSet, + Hyrax::AdministrativeSet, + ::Collection, + Hyrax::PcdmCollection) + end + end end describe ".default_processor_chain" do