Skip to content

Commit

Permalink
do not set model to nil on raw csv data (#376)
Browse files Browse the repository at this point in the history
* do not set model to nil on raw csv data

* spec fix
  • Loading branch information
orangewolf authored Nov 16, 2021
1 parent 23efea3 commit 417ab3b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/bulkrax/csv_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def self.data_for_entry(data, _source_id)
data = data.first if data.is_a?(CSV::Table)
# model has to be separated so that it doesn't get mistranslated by to_h
raw_data = data.to_h
raw_data[:model] = data[:model]
raw_data[:model] = data[:model] if data[:model].present?
# If the collection field mapping is not 'collection', add 'collection' - the parser needs it
raw_data[:collection] = raw_data[collection_field.to_sym] if raw_data.keys.include?(collection_field.to_sym) && collection_field != 'collection'
# If the children field mapping is not 'children', add 'children' - the parser needs it
Expand Down
1 change: 0 additions & 1 deletion spec/models/bulkrax/importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ module Bulkrax
it 'creates a default mapping from the column headers' do
expect(importer.mapping).to eq(
"collection" => { "excluded" => false, "from" => ["collection"], "if" => nil, "parsed" => false, "split" => false },
"model" => { "excluded" => false, "from" => ["model"], "if" => nil, "parsed" => true, "split" => false },
"source_identifier" => { "excluded" => false, "from" => ["source_identifier"], "if" => nil, "parsed" => false, "split" => false },
"title" => { "excluded" => false, "from" => ["title"], "if" => nil, "parsed" => false, "split" => false }
)
Expand Down

0 comments on commit 417ab3b

Please sign in to comment.