Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/jobs/load_big_sam_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ def fix_date(row)
end

def mc_or_mac?(names)
return names if names.family.starts_with?(/Mc[A-Z]/) || names.family.starts_with?(/Mac[A-Z]/)
return names if names.family.start_with?(/Mc[A-Z]/) || names.family.start_with?(/Mac[A-Z]/)

if names.family.starts_with?('Mac ') || names.family.starts_with?('Mc ')
if names.family.start_with?('Mac ') || names.family.start_with?('Mc ')
names.family = names.family.split.map(&:titleize).join
return names
end
Expand All @@ -398,6 +398,8 @@ def mc_or_mac?(names)
return names
end

return names unless names.family.downcase.start_with?('mac') || names.family.downcase.start_with?('mc')

names.family.gsub!(/M.*c\K.*/, &:titleize)
names
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/letters/_letter.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ json.repositories do
end
end

json.set! 'previously_published', letter.letter_publisher.label if letter.letter_publisher.present?

json.set! 'publication_information', letter.publication_information if letter.publication_information.present?

json.recipients do
Expand Down
7 changes: 7 additions & 0 deletions spec/jobs/load_big_sam_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,11 @@
names = bs.mc_or_mac?(macintosh)
expect(names.family).to eq('MacIntosh')
end

it 'handles M names that also include a c' do
bs = described_class.new
marcuse = Namae.parse('Herbert Marcuse').first
names = bs.mc_or_mac?(marcuse)
expect(names.family).to eq('Marcuse')
end
end
1 change: 1 addition & 0 deletions spec/requests/letters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
expect(letter.published).to be(true)
get letter_url(letter), as: :json
expect(json[:repositories]).to be_nil
expect(json[:previously_published]).to eq(letter.letter_publisher.label)
end

it 'renders unpublished when requested from beckettapi' do
Expand Down