From 73fd5111745c569f0b7286552e74a5181d3f34f2 Mon Sep 17 00:00:00 2001 From: Monique Rio Date: Fri, 30 Jul 2021 09:36:44 -0400 Subject: [PATCH] limited length of title and author --- lib/tasks/alma_circ_history.rake | 4 ++-- spec/tasks/alma_circ_history_task_spec.rb | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/tasks/alma_circ_history.rake b/lib/tasks/alma_circ_history.rake index 59e976f..797010e 100644 --- a/lib/tasks/alma_circ_history.rake +++ b/lib/tasks/alma_circ_history.rake @@ -23,8 +23,8 @@ namespace :alma_circ_history do loan = Loan.new do |l| l.user = u l.id = row["Item Loan Id"] - l.title = row["Title"] - l.author = row["Author"] + l.title = row["Title"][0,255] + l.author = row["Author"][0,255] l.mms_id = row["MMS Id"] l.return_date = row["Return Date"] l.checkout_date = row["Loan Date"] diff --git a/spec/tasks/alma_circ_history_task_spec.rb b/spec/tasks/alma_circ_history_task_spec.rb index 802422a..96d54bc 100644 --- a/spec/tasks/alma_circ_history_task_spec.rb +++ b/spec/tasks/alma_circ_history_task_spec.rb @@ -60,6 +60,28 @@ expect(User.all.count).to eq(2) expect(Loan.all.count).to eq(1) end + it "handles giant title" do + user_ajones + user_emcard + loans = File.read('./spec/fixtures/circ_history.json') + super_long_title = 'a'*1000 + loans.gsub!('Between the world and me',super_long_title) + @stub.to_return(body: loans, headers: {content_type: 'application/json'}) + @stub.response #clear out original response + load_circ_history + expect(Loan.all.count).to eq(2) + end + it "handles giant author" do + user_ajones + user_emcard + loans = File.read('./spec/fixtures/circ_history.json') + super_long_author = 'a'*1000 + loans.gsub!('Caldwell, John, 1938-',super_long_author) + @stub.to_return(body: loans, headers: {content_type: 'application/json'}) + @stub.response #clear out original response + load_circ_history + expect(Loan.all.count).to eq(2) + end end describe "alma_circ_history:purge" do