From 9b96f344cc2fed9a347ebdaf27e61ab337077489 Mon Sep 17 00:00:00 2001 From: Justin Littman Date: Fri, 17 May 2024 13:36:41 -0400 Subject: [PATCH] Changes MembersController to use RepositoryObject. closes #4995 --- app/controllers/members_controller.rb | 2 +- spec/requests/members_for_collection_spec.rb | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index b69f7f407..15e4a62a7 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -4,6 +4,6 @@ class MembersController < ApplicationController # Return the members of this collection def index - @members = Dro.members_of_collection(params[:object_id]).select(:external_identifier, :version) + @members = RepositoryObject.currently_members_of_collection(params[:object_id]).select(:external_identifier, :version) end end diff --git a/spec/requests/members_for_collection_spec.rb b/spec/requests/members_for_collection_spec.rb index 0c660bb5e..cab914a4b 100644 --- a/spec/requests/members_for_collection_spec.rb +++ b/spec/requests/members_for_collection_spec.rb @@ -4,20 +4,24 @@ RSpec.describe 'Get the members' do let(:collection_druid) { 'druid:mk420bs7601' } - - let!(:dro) { create(:ar_dro, isMemberOf: [collection_druid]) } - let(:expected) do { members: [ { - externalIdentifier: dro.external_identifier, - version: dro.version + externalIdentifier: repository_object.external_identifier, + version: repository_object.head_version.version } ] } end + let(:repository_object) { create(:repository_object) } + + before do + repository_object_version = create(:repository_object_version, version: 2, is_member_of: [collection_druid], repository_object:) + repository_object.update!(head_version: repository_object_version, opened_version: repository_object_version) + end + it 'returns the druids' do get "/v1/objects/#{collection_druid}/members", headers: { 'Authorization' => "Bearer #{jwt}" }