Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Commit

Permalink
Merge pull request #880 from psu-libraries/i#817
Browse files Browse the repository at this point in the history
Adding work type to csv export
  • Loading branch information
awead committed Mar 14, 2019
2 parents 3c94115 + 1b1fccf commit 01a12ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/blacklight/document/csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def blacklight_config

def export_collection
::CSV.generate do |csv|
csv << ['id'] + fields.map(&:label)
csv << ['id', 'work_type'] + fields.map(&:label)
export_members(csv)
end
end
Expand Down Expand Up @@ -76,7 +76,7 @@ def export_fields(solr_document)
values = fields.map do |field|
to_csv_field(solr_document.send(field.method_name))
end
[solr_document.id].concat(values)
[solr_document.id, solr_document.work_type].concat(values)
end

def fields
Expand Down
16 changes: 8 additions & 8 deletions spec/blacklight/solr_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ class MyResource < Valkyrie::Resource
}
end

it { is_expected.to eq("abc123,my_title,,,,,,,,value1||value2,,xyx789,,\n") }
it { is_expected.to eq("abc123,,my_title,,,,,,,,value1||value2,,xyx789,,\n") }

context 'with a collection containing works and file sets' do
let(:collection) { create :library_collection }
let(:work) { create :work, :with_file, member_of_collection_ids: [collection.id], title: 'Work One' }
let(:work1_csv) { "#{work.id},Work One,,,,,,,,,,#{collection.id},," }
let(:file_set1_csv) { "#{work.member_ids.first},hello_world.txt,,,,,,,,,,,," }
let(:work1_csv) { "#{work.id},Generic,Work One,,,,,,,,,,#{collection.id},," }
let(:file_set1_csv) { "#{work.member_ids.first},,hello_world.txt,,,,,,,,,,,," }
let(:work2) { create :work, :with_file, member_of_collection_ids: [collection.id], title: 'Work Two' }
let(:work2_csv) { "#{work2.id},Work Two,,,,,,,,,,#{collection.id},," }
let(:file_set2_csv) { "#{work2.member_ids.first},hello_world.txt,,,,,,,,,,,," }
let(:work2_csv) { "#{work2.id},Generic,Work Two,,,,,,,,,,#{collection.id},," }
let(:file_set2_csv) { "#{work2.member_ids.first},,hello_world.txt,,,,,,,,,,,," }

let(:csv_header) do
'id,title,subtitle,description,alternate_ids,creator,audio_field,created,document_field,'\
'id,work_type,title,subtitle,description,alternate_ids,creator,audio_field,created,document_field,'\
'generic_field,map_field,member_of_collection_ids,moving_image_field,still_image_field'
end

Expand Down Expand Up @@ -122,8 +122,8 @@ class MyResource < Valkyrie::Resource
end

let(:file_set) { create(:file_set) }
let(:work_csv) { 'abc123,my_title,,,,,,,,value1||value2,,xyx789,,' }
let(:file_set_csv) { "#{file_set.id},Original File Name,,,,,,,,,,,," }
let(:work_csv) { 'abc123,,my_title,,,,,,,,value1||value2,,xyx789,,' }
let(:file_set_csv) { "#{file_set.id},,Original File Name,,,,,,,,,,,," }

before { file_set }

Expand Down

0 comments on commit 01a12ee

Please sign in to comment.