Skip to content

Commit

Permalink
Merge pull request #4894 from sul-dlss/index_on_create
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne authored Apr 18, 2024
2 parents 6de07a0 + 15194e7 commit dc14d0d
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/services/create_object_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def create(cocina_request_object, assign_doi: false)

# Broadcast this to a topic
Notifications::ObjectCreated.publish(model: cocina_object_with_metadata)
Indexer.reindex(cocina_object: cocina_object_with_metadata)
cocina_object_with_metadata
end

Expand Down
2 changes: 1 addition & 1 deletion app/services/ur_admin_policy_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ def self.create
)

cocina_object_with_metadata = CocinaObjectStore.store(admin_policy_cocina, skip_lock: true)
Notifications::ObjectCreated.publish(model: cocina_object_with_metadata)
Indexer.reindex(cocina_object: cocina_object_with_metadata)
end
end
2 changes: 1 addition & 1 deletion spec/requests/create_collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
before do
allow(SuriService).to receive(:mint_id).and_return(druid)
allow_any_instance_of(CocinaObjectStore).to receive(:find).with('druid:dd999df4567').and_return(minimal_cocina_admin_policy)
stub_request(:put, 'https://dor-indexing-app.example.edu/dor/reindex_from_cocina')
allow(Indexer).to receive(:reindex)
end

context 'when the folio instance hrid is provided and save is successful' do
Expand Down
1 change: 1 addition & 0 deletions spec/requests/create_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
before do
allow(SuriService).to receive(:mint_id).and_return(druid)
allow(Catalog::MarcService).to receive(:new).and_return(marc_service)
allow(Indexer).to receive(:reindex)
end

context 'when a DRO is provided' do
Expand Down
1 change: 1 addition & 0 deletions spec/services/cocina_object_store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
before do
allow(Settings.ur_admin_policy).to receive(:druid).and_return('druid:bc123df4567')
allow(Settings.enabled_features).to receive(:create_ur_admin_policy).and_return(true)
allow(Indexer).to receive(:reindex)
end

it 'bootstraps' do
Expand Down
3 changes: 3 additions & 0 deletions spec/services/create_object_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
before do
allow(Cocina::ObjectValidator).to receive(:validate)
allow(Notifications::ObjectCreated).to receive(:publish)
allow(Indexer).to receive(:reindex)
allow(store).to receive(:merge_access_for).and_return(requested_cocina_object)
allow(store).to receive(:add_project_tag)
allow(SuriService).to receive(:mint_id).and_return(druid)
Expand Down Expand Up @@ -49,6 +50,7 @@
end.to change(Dro, :count).by(1).and change(RepositoryObject, :count).by(1)

expect(Notifications::ObjectCreated).to have_received(:publish)
expect(Indexer).to have_received(:reindex)
expect(Cocina::ObjectValidator).to have_received(:validate).with(requested_cocina_object)
expect(store).to have_received(:merge_access_for).with(requested_cocina_object)
expect(store).to have_received(:add_project_tag).with(druid, requested_cocina_object)
Expand All @@ -66,6 +68,7 @@
expect(store.create(requested_cocina_object)).to be_a Cocina::Models::CollectionWithMetadata
end.to change(Collection, :count).by(1)
expect(Notifications::ObjectCreated).to have_received(:publish)
expect(Indexer).to have_received(:reindex)
expect(Cocina::ObjectValidator).to have_received(:validate).with(requested_cocina_object)
expect(store).to have_received(:merge_access_for).with(requested_cocina_object)
expect(store).to have_received(:add_project_tag).with(druid, requested_cocina_object)
Expand Down
4 changes: 2 additions & 2 deletions spec/services/ur_admin_policy_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
let(:druid) { Settings.ur_admin_policy.druid }

before do
allow(Notifications::ObjectCreated).to receive(:publish)
allow(Indexer).to receive(:reindex)
end

it 'creates the Ur-AdminPolicy' do
expect(AdminPolicy.exists?(external_identifier: druid)).to be false
policy
expect(AdminPolicy.exists?(external_identifier: druid)).to be true
expect(Notifications::ObjectCreated).to have_received(:publish)
expect(Indexer).to have_received(:reindex)
end
end

0 comments on commit dc14d0d

Please sign in to comment.