Skip to content

Commit

Permalink
Merge pull request #802 from pulibrary/i799-three-more-fields-for-air…
Browse files Browse the repository at this point in the history
…table

[airtable staff directory] Add websiteUrl, bios, and expertise fields
  • Loading branch information
kevinreiss authored Jun 26, 2024
2 parents 4a38ce0 + f3749bc commit c2044f1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
5 changes: 4 additions & 1 deletion app/models/air_table_staff/staff_directory_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def fields
{ airtable_field: :'pul:Unit', our_field: :unit },
{ airtable_field: :'pul:Team', our_field: :team },
{ airtable_field: :Title, our_field: :title },
{ airtable_field: :'Area of Study', our_field: :areasOfStudy, transformer: ->(areas) { areas&.join('//') } }
{ airtable_field: :'Area of Study', our_field: :areasOfStudy, transformer: ->(areas) { areas&.join('//') } },
{ airtable_field: :'Website URL', our_field: :websiteUrl },
{ airtable_field: :Bios, our_field: :bios },
{ airtable_field: :Expertise, our_field: :expertise, transformer: ->(areas) { areas&.join('//') } }
]
end
# rubocop:enable Metrics/MethodLength
Expand Down
3 changes: 2 additions & 1 deletion spec/fixtures/files/air_table/records_no_offset.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"netid": "ab123",
"University Phone": "(123) 123-1234",
"pul:Preferred Name": "Phillip Librarian",
"Email": "[email protected]"
"Email": "[email protected]",
"Bios": "Hello\nMy research interests\nare\n\nfantastic!"
}
}
]
Expand Down
13 changes: 10 additions & 3 deletions spec/models/air_table_staff/csv_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@
)
.to_return(status: 200, body: File.read(file_fixture('air_table/records_no_offset.json')), headers: {})
end
it 'creates a CSV object with data from the HTTP API' do
it 'creates a CSV string with data from the HTTP API' do
# The following CSV contains new lines within a single cell.
# Since the cell is in in double quotes, it will still be read
# as a single cell within a single row"
expected = <<~END_CSV
puid,netid,phone,name,lastName,firstName,email,address,building,department,division,unit,team,title,areasOfStudy
123,ab123,(123) 123-1234,Phillip Librarian,Librarian,Phillip,[email protected],123 Stokes,Stokes,Stokes,,,,Library Collections Specialist V,Virtual Reality
puid,netid,phone,name,lastName,firstName,email,address,building,department,division,unit,team,title,areasOfStudy,websiteUrl,bios,expertise
123,ab123,(123) 123-1234,Phillip Librarian,Librarian,Phillip,[email protected],123 Stokes,Stokes,Stokes,,,,Library Collections Specialist V,Virtual Reality,,"Hello
My research interests
are
fantastic!",
END_CSV
directory = described_class.new
expect(directory.to_csv).to eq(expected)
Expand Down
13 changes: 12 additions & 1 deletion spec/models/air_table_staff/staff_directory_person_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
'pul:Unit': 'Rare Books Cataloging Team',
'pul:Team': 'IT, Discovery and Access Services',
'Title': 'Library Software Engineer',
'Expertise': ['Discovery', 'Library Systems'],
'Bios': "Kevin has worked at Princeton since 2011. He has a M.S. in Library and Information Science from the University of Illinois at Urbana-Champaign." \
"\n\nKevin heads the Discovery and Access Services Team that supports the Library Catalog. \n",
'Website URL': 'https://github.com/kevinreiss',
'Area of Study': ['Chemistry', 'African American Studies']
}
expected = [
Expand All @@ -36,7 +40,14 @@
'Rare Books Cataloging Team', # unit
'IT, Discovery and Access Services', # team
'Library Software Engineer', # title
'Chemistry//African American Studies' # areasOfStudy
'Chemistry//African American Studies', # areasOfStudy
'https://github.com/kevinreiss', # websiteUrl
"Kevin has worked at Princeton since 2011. "\
"He has a M.S. in Library and Information Science "\
"from the University of Illinois at Urbana-Champaign."\
"\n\nKevin heads the Discovery and Access Services Team "\
"that supports the Library Catalog. \n", # bios
'Discovery//Library Systems' # expertise
]

expect(described_class.new(json).to_a).to eq(expected)
Expand Down
3 changes: 2 additions & 1 deletion spec/models/air_table_staff/staff_list_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
let(:first_row) do
[
'123', 'ab123', '(123) 123-1234', 'Phillip Librarian', 'Librarian', 'Phillip', '[email protected]',
'123 Stokes', 'Stokes', 'Stokes', nil, nil, nil, 'Library Collections Specialist V', 'Virtual Reality'
'123 Stokes', 'Stokes', 'Stokes', nil, nil, nil, 'Library Collections Specialist V', 'Virtual Reality',
nil, "Hello\nMy research interests\nare\n\nfantastic!", nil
]
end

Expand Down

0 comments on commit c2044f1

Please sign in to comment.