Skip to content

Commit

Permalink
Don't default member_of_collection_ids in collection_params
Browse files Browse the repository at this point in the history
This default is not necessary and had the side effect of removing
pre-existing member_of_collection_ids when updating collections

Co-authored-by: Jose Blanco <blancoj@umich.edu>
  • Loading branch information
2 people authored and tamsin johnson committed Sep 12, 2022
1 parent 053de2d commit 7add213
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion app/controllers/hyrax/dashboard/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ def collection_params
params.permit(collection: {})[:collection]
.merge(params.permit(:collection_type_gid)
.with_defaults(collection_type_gid: default_collection_type_gid))
.merge(member_of_collection_ids: Array(params[:parent_id]))
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,25 @@
end
end
end

context 'with nested collection' do
let(:parent_collection) { FactoryBot.valkyrie_create(:collection_resource) }
let(:collection) do
FactoryBot.valkyrie_create(:collection_resource,
:public,
title: ["My collection"],
creator: ["Mr. Smith"],
depositor: user.user_key,
edit_users: [user],
member_of_collection_ids: [parent_collection.id])
end

it 'retains parent collection relationship' do
put :update, params: { id: collection, collection: { description: ['Videos of importance'] } }
expect(assigns[:collection].description).to eq ['Videos of importance']
expect(assigns[:collection].member_of_collection_ids).to eq [parent_collection.id]
end
end
end

describe "#show" do
Expand Down

0 comments on commit 7add213

Please sign in to comment.