Skip to content

Commit

Permalink
map SolrDocument#collection? to configured class
Browse files Browse the repository at this point in the history
using `#collection?` on the `hydra_model` turns out to be useless, since
`hydra_model` is actually a Class, not a model instance.

instead just respect whatever model is configured. trust that
`SolrDocument#hydra_model` will get resolved to the configured class.
  • Loading branch information
tamsin johnson committed Oct 21, 2021
1 parent 1fa578b commit 85444e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions app/models/concerns/hyrax/solr_document_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ def to_model
##
# @return [Boolean]
def collection?
hydra_model.try(:collection?) ||
hydra_model == Hyrax.config.collection_class
hydra_model == Hyrax.config.collection_class
end

##
Expand All @@ -77,7 +76,7 @@ def work?

# Method to return the model
def hydra_model(classifier: ActiveFedora.model_mapper)
"::#{first('has_model_ssim')}".safe_constantize ||
first('has_model_ssim').safe_constantize ||
classifier.classifier(self).best_model
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/solr_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class Mimes
end

describe "#collection?" do
let(:attributes) { { 'has_model_ssim' => 'Collection' } }
let(:attributes) { { 'has_model_ssim' => Hyrax.config.collection_model } }

it { is_expected.to be_collection }
end
Expand Down

0 comments on commit 85444e6

Please sign in to comment.