Skip to content

Commit

Permalink
Merge pull request #6954 from samvera/reindex-fileset-after-file-migr…
Browse files Browse the repository at this point in the history
…ation

Reindex fileset after file lazy migration
  • Loading branch information
laritakr authored Nov 2, 2024
2 parents 3f20242 + e4e9244 commit 7834acc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/jobs/migrate_files_to_valkyrie_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def migrate_files!(resource:)
Hyrax.persister.save(resource: valkyrie_file)
end
end
# reindex the file set after migrating files to include characterization info
Hyrax.index_adapter.save(resource: resource)
end

def copy_attributes(valkyrie_file:, original_file:)
Expand Down
7 changes: 3 additions & 4 deletions spec/jobs/migrate_files_to_valkyrie_job_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'wings'

RSpec.describe MigrateFilesToValkyrieJob, valkyrie_adapter: :freyja_adapter, perform_enqueued: [MigrateFilesToValkyrieJob] do
RSpec.describe MigrateFilesToValkyrieJob, index_adapter: :solr_index, valkyrie_adapter: :freyja_adapter, perform_enqueued: [MigrateFilesToValkyrieJob] do
let(:user) { create(:user) }
let(:content) { File.open(fixture_path + '/' + label) }
let(:uploaded_file1) { build(:uploaded_file, file:) }
Expand All @@ -23,9 +23,6 @@

before do
allow(Hyrax.config).to receive(:valkyrie_transition?).and_return(true)
# allow(ActiveFedora::Base).to receive(:find).and_call_original
# allow(ActiveFedora::Base).to receive(:find).with(migrated_file_set.original_file.file_identifier.to_s).and_return(file_with_characterization)
# allow(File_Set).to receive(:find).with(fedora_file_set.id).and_return(fedora_file_set)
end

it "it migrates all derivatives along with a file" do
Expand All @@ -35,5 +32,7 @@
described_class.new.attribute_mapping.each do |k, v|
expect(valkyrized_file_set.original_file.send(k)).to match_array(pcdm_file.send(v))
end
solr_doc = Hyrax.index_adapter.connection.get("select", params: { q: "id:#{valkyrized_file_set.id.to_s}" })["response"]["docs"].first
expect(solr_doc['width_is']).to eq(222)
end
end

0 comments on commit 7834acc

Please sign in to comment.