From ccf10791e2e3b77dec9ac32b870048096682df0e Mon Sep 17 00:00:00 2001 From: Justin Littman Date: Mon, 20 May 2024 15:23:38 -0400 Subject: [PATCH] Changes collections_for_object_spec to use RepositoryObject models. refs #5014 --- spec/factories/repository_object_versions.rb | 2 +- spec/requests/collections_for_object_spec.rb | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/spec/factories/repository_object_versions.rb b/spec/factories/repository_object_versions.rb index 24c4e947e..988799271 100644 --- a/spec/factories/repository_object_versions.rb +++ b/spec/factories/repository_object_versions.rb @@ -67,7 +67,7 @@ end trait :with_repository_object do - repository_object + repository_object { association :repository_object, external_identifier: } after(:build) do |repository_object_version, _evaluator| repository_object = repository_object_version.repository_object diff --git a/spec/requests/collections_for_object_spec.rb b/spec/requests/collections_for_object_spec.rb index 37a832dab..c7fdbe483 100644 --- a/spec/requests/collections_for_object_spec.rb +++ b/spec/requests/collections_for_object_spec.rb @@ -12,8 +12,8 @@ end end - let(:collection_records) { create_list(:ar_collection, 1) } - let(:collections) { collection_records.map(&:to_cocina).map { |cocina_object| Cocina::Models.without_metadata(cocina_object) } } + let(:collection_repository_object_versions) { create_list(:repository_object_version, 1, :collection_repository_object_version, :with_repository_object) } + let(:collections) { collection_repository_object_versions.map(&:to_cocina) } let(:expected) do { @@ -21,8 +21,13 @@ } end - let(:dro_record) { create(:ar_dro, isMemberOf: collections.map(&:externalIdentifier)) } - let(:dro) { dro_record.to_cocina } + let(:dro_record) do + create(:repository_object, :dro, :with_repository_object_version).tap do |repo_obj| + repo_obj.head_version.structural['isMemberOf'] = collections.map(&:externalIdentifier) + repo_obj.head_version.save! + end + end + let(:dro) { dro_record.head_version.to_cocina } let(:response_model) { response.parsed_body.deep_symbolize_keys } @@ -47,7 +52,7 @@ end describe 'more than one collection' do - let(:collection_records) { create_list(:ar_collection, 2) } + let(:collection_repository_object_versions) { create_list(:repository_object_version, 2, :collection_repository_object_version, :with_repository_object) } it 'returns an empty array for collections' do get "/v1/objects/#{dro.externalIdentifier}/query/collections",