Skip to content

Commit 9044ee9

Browse files
authored
Merge pull request #6709 from samvera/favor-to-rdf-representation
♻️ Favor using to_rdf_representation
2 parents 4401d17 + 1f4a632 commit 9044ee9

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/hyrax/specs/shared_specs/indexers.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
describe '#to_solr' do
1919
it 'indexes base resource fields' do
2020
expect(indexer.to_solr)
21-
.to include(has_model_ssim: resource.class.name,
21+
.to include(has_model_ssim: resource.to_rdf_representation,
2222
human_readable_type_tesim: resource.human_readable_type,
2323
alternate_ids_sim: a_collection_containing_exactly(*ids))
2424
end

spec/spec_helper.rb

+19
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,25 @@ def ci_build?
6666
:fixture_disk
6767
)
6868

69+
# Because we're relying on shared specs from Valkyrie, and assuming that all of the classes will
70+
# respond to #to_rdf_representation and the base Valkyrie::Resource does not do that nor does the
71+
# dynamic classes generated for the shared specs; we need the following coercion.
72+
module Hyrax::Resource::Coercible
73+
extend ActiveSupport::Concern
74+
75+
class_methods do
76+
def to_rdf_representation
77+
name.to_s
78+
end
79+
end
80+
81+
def to_rdf_representation
82+
self.class.to_rdf_representation
83+
end
84+
end
85+
86+
Valkyrie::Resource.include(Hyrax::Resource::Coercible)
87+
6988
# Require supporting ruby files from spec/support/ and subdirectories. Note: engine, not Rails.root context.
7089
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each { |f| require f }
7190

0 commit comments

Comments
 (0)