diff --git a/lib/zizia/hyrax/hyrax_record_importer.rb b/lib/zizia/hyrax/hyrax_record_importer.rb index 24558d8..765c3d3 100644 --- a/lib/zizia/hyrax/hyrax_record_importer.rb +++ b/lib/zizia/hyrax/hyrax_record_importer.rb @@ -60,7 +60,7 @@ def find_collection_id(csv_import_detail:, record:) if csv_import_detail&.collection_id&.present? csv_import_detail.collection_id elsif record&.parent&.first - Collection.where(deduplication_key: "def/123")&.first&.id + Collection.where("#{deduplication_field}": record.parent.first)&.first&.id end end diff --git a/spec/dummy/spec/system/import_from_csv_spec.rb b/spec/dummy/spec/system/import_from_csv_spec.rb index 84351ad..ebf0a67 100644 --- a/spec/dummy/spec/system/import_from_csv_spec.rb +++ b/spec/dummy/spec/system/import_from_csv_spec.rb @@ -228,7 +228,7 @@ end context 'with an existing collection' do - let(:collection) { FactoryBot.build(:collection, title: ['Testing Collection'], deduplication_key: 'def/123') } + let(:collection) { FactoryBot.build(:collection, title: ['Testing Collection'], identifier: ['def/123']) } before do collection.save! end @@ -245,7 +245,7 @@ expect(Work.count).to eq 1 # Ensure that all the fields got assigned as expected work = Work.where(title: "*haberdashery*").first - expect(collection.deduplication_key).to eq 'def/123' + expect(collection.identifier&.first).to eq 'def/123' expect(work.member_of_collection_ids).to eq [collection.id] end end