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

♻️ Favor using to_rdf_representation #6709

Merged
merged 1 commit into from
Feb 20, 2024
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
2 changes: 1 addition & 1 deletion lib/hyrax/specs/shared_specs/indexers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down