Skip to content

Commit

Permalink
Use deduplication field to find Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkadel committed Sep 16, 2021
1 parent c3f42d3 commit 56e4cf4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/zizia/hyrax/hyrax_record_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/spec/system/import_from_csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 56e4cf4

Please sign in to comment.