From 1f4a632818f5c4c4ad8898c547b773d3d5a9b3f2 Mon Sep 17 00:00:00 2001 From: Jeremy Friesen Date: Tue, 20 Feb 2024 10:08:35 -0500 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Favor=20using=20to=5Frdf?= =?UTF-8?q?=5Frepresentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We're more and more using the to_rdf_representation as the baseline conceptual class that we're persisting. It is different from generic_type in that in the case of Pcdm::Work, the `to_rdf_representation` represents the specific implemented work model and the generic_type remains `Work`. --- lib/hyrax/specs/shared_specs/indexers.rb | 2 +- spec/spec_helper.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/hyrax/specs/shared_specs/indexers.rb b/lib/hyrax/specs/shared_specs/indexers.rb index d8d6c736bf..fac710c948 100644 --- a/lib/hyrax/specs/shared_specs/indexers.rb +++ b/lib/hyrax/specs/shared_specs/indexers.rb @@ -18,7 +18,7 @@ describe '#to_solr' do it 'indexes base resource fields' do expect(indexer.to_solr) - .to include(has_model_ssim: resource.class.name, + .to include(has_model_ssim: resource.to_rdf_representation, human_readable_type_tesim: resource.human_readable_type, alternate_ids_sim: a_collection_containing_exactly(*ids)) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d1e9b3d3c2..6de2b804e5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -66,6 +66,25 @@ def ci_build? :fixture_disk ) +# Because we're relying on shared specs from Valkyrie, and assuming that all of the classes will +# respond to #to_rdf_representation and the base Valkyrie::Resource does not do that nor does the +# dynamic classes generated for the shared specs; we need the following coercion. +module Hyrax::Resource::Coercible + extend ActiveSupport::Concern + + class_methods do + def to_rdf_representation + name.to_s + end + end + + def to_rdf_representation + self.class.to_rdf_representation + end +end + +Valkyrie::Resource.include(Hyrax::Resource::Coercible) + # Require supporting ruby files from spec/support/ and subdirectories. Note: engine, not Rails.root context. Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each { |f| require f }