Skip to content

Commit

Permalink
Change && to if (#6860)
Browse files Browse the repository at this point in the history
* Change && to if

In the case of a `GenericWorkResource` the `#hydra_model` method would
still return `GenericWork` because the first condition evaluated to
`true` instead.

* Add clean_repo

The "can delete all objects but only from postgres" spec was sometimes
failing because of `MyLockingResource` not being a constant.
  • Loading branch information
kirkkwang authored Jul 5, 2024
1 parent 814fdcc commit b98d6f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/models/concerns/hyrax/solr_document_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def valkyrie?

# Method to return the model
def hydra_model(classifier: nil)
((first('has_model_ssim')&.+ 'Resource')&.safe_constantize && Hyrax.config.valkyrie_transition) ||
first('has_model_ssim')&.safe_constantize ||
model_classifier(classifier).classifier(self).best_model
model = first('has_model_ssim')&.safe_constantize
model = (first('has_model_ssim')&.+ 'Resource')&.safe_constantize if Hyrax.config.valkyrie_transition?
model || model_classifier(classifier).classifier(self).best_model
end

def depositor(default = '')
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/freyja/persister_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require 'wings'
require 'freyja/metadata_adapter'

RSpec.describe Freyja::Persister, :active_fedora do
RSpec.describe Freyja::Persister, :active_fedora, :clean_repo do
subject(:persister) { described_class.new(adapter: adapter) }
let(:adapter) { Freyja::MetadataAdapter.new }
let(:query_service) { adapter.query_service }
Expand Down Expand Up @@ -268,7 +268,7 @@ class Custom < ActiveFedora::Base
.to raise_error Valkyrie::Persistence::ObjectNotFoundError
end

it "can delete all objects but only from postgers" do
it "can delete all objects but only from postgres" do
resource2 = resource_class.new

persister.save_all(resources: [resource, resource2])
Expand Down

0 comments on commit b98d6f4

Please sign in to comment.