From f3749bcf937360dfe93b19741000420869afa575 Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Wed, 26 Jun 2024 14:48:02 -0700 Subject: [PATCH] [airtable staff directory] Add websiteUrl, bios, and expertise fields --- .../air_table_staff/staff_directory_mapping.rb | 5 ++++- .../fixtures/files/air_table/records_no_offset.json | 3 ++- spec/models/air_table_staff/csv_builder_spec.rb | 13 ++++++++++--- .../air_table_staff/staff_directory_person_spec.rb | 13 ++++++++++++- spec/models/air_table_staff/staff_list_job_spec.rb | 3 ++- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/app/models/air_table_staff/staff_directory_mapping.rb b/app/models/air_table_staff/staff_directory_mapping.rb index 584f9c57..84bfc739 100644 --- a/app/models/air_table_staff/staff_directory_mapping.rb +++ b/app/models/air_table_staff/staff_directory_mapping.rb @@ -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 diff --git a/spec/fixtures/files/air_table/records_no_offset.json b/spec/fixtures/files/air_table/records_no_offset.json index e32faeee..a7731ead 100644 --- a/spec/fixtures/files/air_table/records_no_offset.json +++ b/spec/fixtures/files/air_table/records_no_offset.json @@ -15,7 +15,8 @@ "netid": "ab123", "University Phone": "(123) 123-1234", "pul:Preferred Name": "Phillip Librarian", - "Email": "ab123@princeton.edu" + "Email": "ab123@princeton.edu", + "Bios": "Hello\nMy research interests\nare\n\nfantastic!" } } ] diff --git a/spec/models/air_table_staff/csv_builder_spec.rb b/spec/models/air_table_staff/csv_builder_spec.rb index dd324655..1c025919 100644 --- a/spec/models/air_table_staff/csv_builder_spec.rb +++ b/spec/models/air_table_staff/csv_builder_spec.rb @@ -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,ab123@princeton.edu,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,ab123@princeton.edu,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) diff --git a/spec/models/air_table_staff/staff_directory_person_spec.rb b/spec/models/air_table_staff/staff_directory_person_spec.rb index 491a0cf0..d7cbbd1b 100644 --- a/spec/models/air_table_staff/staff_directory_person_spec.rb +++ b/spec/models/air_table_staff/staff_directory_person_spec.rb @@ -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 = [ @@ -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) diff --git a/spec/models/air_table_staff/staff_list_job_spec.rb b/spec/models/air_table_staff/staff_list_job_spec.rb index a70aa457..52030fe3 100644 --- a/spec/models/air_table_staff/staff_list_job_spec.rb +++ b/spec/models/air_table_staff/staff_list_job_spec.rb @@ -22,7 +22,8 @@ let(:first_row) do [ '123', 'ab123', '(123) 123-1234', 'Phillip Librarian', 'Librarian', 'Phillip', 'ab123@princeton.edu', - '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