This repository has been archived by the owner on May 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Job for updating a record in geoblacklight
- Loading branch information
1 parent
19ad198
commit 54941bf
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class UpdateGeoBlacklightJob < ApplicationJob | ||
queue_as :ingest | ||
|
||
# @param [String] Identifier of geo work | ||
# @param [String] Model name of geo work | ||
def perform(work_id, model_name) | ||
klass = model_name.constantize | ||
work = klass.search_with_conditions(id: work_id).first | ||
return unless work | ||
show_presenter_class = DynamicShowPresenter.new | ||
doc = SolrDocument.new(work) | ||
geo_work = show_presenter_class.new(doc, nil, nil) | ||
geo_works_events_generator.record_updated(geo_work) | ||
end | ||
|
||
def show_presenter_class | ||
DynamicShowPresenter.new | ||
end | ||
|
||
def geo_works_events_generator | ||
GeoWorks::EventsGenerator.new | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe UpdateGeoBlacklightJob do | ||
describe "#perform" do | ||
let(:image_work) { FactoryGirl.create(:image_work) } | ||
let(:events_generator) { instance_double(GeoWorks::EventsGenerator) } | ||
|
||
subject { described_class.perform_now(image_work.id, 'ImageWork') } | ||
|
||
before do | ||
allow(GeoWorks::EventsGenerator).to receive(:new).and_return(events_generator) | ||
end | ||
|
||
it 'triggers an update record event' do | ||
expect(events_generator).to receive(:record_updated) | ||
subject | ||
end | ||
end | ||
end |