Skip to content

Commit b98eb9f

Browse files
committed
Revert CSV ingestor changes and fix test
1 parent 8125c8b commit b98eb9f

2 files changed

Lines changed: 7 additions & 20 deletions

File tree

lib/ingestors/material_csv_ingestor.rb

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def read(url)
4242
material.date_published = get_column row, 'Published'
4343
material.date_modified = get_column row, 'Modified'
4444
material.difficulty_level = process_competency row, 'Competency'
45-
material.person_links_attributes = process_authors(process_array(row, 'Authors'))
45+
material.authors = process_array row, 'Authors'
4646
material.contributors = process_array row, 'Contributors'
4747
material.fields = process_array row, 'Fields'
4848
material.target_audience = process_array row, 'Audiences'
@@ -65,21 +65,6 @@ def read(url)
6565

6666
private
6767

68-
def process_authors(authors_array)
69-
return [] if authors_array.blank?
70-
71-
authors_array.map do |author_name|
72-
# Store the full name directly without trying to parse it
73-
{
74-
role: 'author',
75-
person_attributes: {
76-
full_name: author_name.to_s.strip,
77-
orcid: nil
78-
}
79-
}
80-
end
81-
end
82-
8368
def process_competency(row, header)
8469
row[header].nil? ? 'notspecified' : row[header]
8570
end

test/unit/ingestors/material_csv_ingestor_test.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ def run
9494
# contributors
9595
refute material.contributors.nil?, 'material contributors is nil'
9696
assert_equal 1, material.contributors.size, 'material contributors count not matched.'
97-
assert material.contributors.include?('Sam Smiths'), 'material contributor[Sam Smiths] missing.'
98-
refute material.contributors.include?('Wily Coyote'), 'material contributor[Wily Coyote] exists.'
97+
contributor_names = material.contributors.map(&:display_name)
98+
assert contributor_names.include?('Sam Smiths'), 'material contributor[Sam Smiths] missing.'
99+
refute contributor_names.include?('Wily Coyote'), 'material contributor[Wily Coyote] exists.'
99100
# fields
100101
refute material.fields.nil?, 'material fields is nil'
101102
refute_empty material.fields, 'material fields is empty'
@@ -195,8 +196,9 @@ def run
195196
assert_equal 2, updated.keywords.size, 'Updated keywords count not matched!'
196197
assert updated.keywords.include?('book'), 'Updated keywords missing value!'
197198
assert_equal 2, updated.authors.size, "Updated authors count not matched! ... #{updated.authors.inspect}"
198-
assert updated.authors.include?('Steven Smith'), 'Updated authors[Steven Smith] missing!'
199-
assert updated.authors.include?('Sam Harpic'), 'Updated authors[Sam Harpic] missing!'
199+
author_names = updated.authors.map(&:display_name)
200+
assert author_names.include?('Steven Smith'), 'Updated authors[Steven Smith] missing!'
201+
assert author_names.include?('Sam Harpic'), 'Updated authors[Sam Harpic] missing!'
200202
assert_equal 0, updated.contributors.size, 'Updated contributors count not matched!'
201203

202204
# check locked fields not updated

0 commit comments

Comments
 (0)