|
508 | 508 | expect(@paper.reload.track).to eq(@track_2)
|
509 | 509 | end
|
510 | 510 | end
|
| 511 | + |
| 512 | + describe "#bibtex_authors" do |
| 513 | + it "should format author names correctly for BibTeX" do |
| 514 | + paper = create(:accepted_paper) |
| 515 | + paper.metadata['paper']['authors'] = [ |
| 516 | + {'given_name' => 'Rhoslyn', 'last_name' => 'Roebuck Williams'}, |
| 517 | + {'given_name' => 'Harry', 'middle_name' => 'J.', 'last_name' => 'Stroud'}, |
| 518 | + {'given_name' => 'Ludwig', 'last_name' => 'van Beethoven'} |
| 519 | + ] |
| 520 | + paper.save! |
| 521 | + |
| 522 | + expected_bibtex = "Roebuck Williams, Rhoslyn and Stroud, Harry J. and van Beethoven, Ludwig" |
| 523 | + expect(paper.bibtex_authors).to eq(expected_bibtex) |
| 524 | + end |
| 525 | + |
| 526 | + it "should handle authors with no given name" do |
| 527 | + paper = create(:accepted_paper) |
| 528 | + paper.metadata['paper']['authors'] = [ |
| 529 | + {'given_name' => 'John', 'last_name' => 'Smith'}, |
| 530 | + {'last_name' => 'Collective'} |
| 531 | + ] |
| 532 | + paper.save! |
| 533 | + |
| 534 | + expected_bibtex = "Smith, John and Collective" |
| 535 | + expect(paper.bibtex_authors).to eq(expected_bibtex) |
| 536 | + end |
| 537 | + |
| 538 | + it "should handle authors with only middle name" do |
| 539 | + paper = create(:accepted_paper) |
| 540 | + paper.metadata['paper']['authors'] = [ |
| 541 | + {'middle_name' => 'J.', 'last_name' => 'Smith'} |
| 542 | + ] |
| 543 | + paper.save! |
| 544 | + |
| 545 | + expected_bibtex = "Smith, J." |
| 546 | + expect(paper.bibtex_authors).to eq(expected_bibtex) |
| 547 | + end |
| 548 | + end |
511 | 549 | end
|
0 commit comments