From bc62b98e2ae5b3d2d3efda24101590dd802d2a26 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Fri, 26 Jun 2026 19:28:57 +0200 Subject: exporter: handle names surrounded with underscores MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Handle underscores which surround the full name, not just a part of it. In this case, then the whole thing should be considered as the name, and the last name should be left nil. Signed-off-by: Miquel Sabaté Solà --- test/lib/base_exporter_test.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/lib/base_exporter_test.rb (limited to 'test/lib/base_exporter_test.rb') diff --git a/test/lib/base_exporter_test.rb b/test/lib/base_exporter_test.rb new file mode 100644 index 0000000..752445b --- /dev/null +++ b/test/lib/base_exporter_test.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'application_system_test_case' + +class BaseExporterTest < ApplicationSystemTestCase + test 'parse authors works' do + instance = BaseExporter.new(things: []) + + [ + ['Name Surname', %w[Name Surname]], + ['Name', ['Name', nil]], + ['Compound Name Surname', ['Compound Name', 'Surname']], + ['Name _Underscored Surname_', ['Name', 'Underscored Surname']], + ['_Name in underscores_', ['Name in underscores', nil]] + ].each do |row| + got = instance.send(:parse_author, author: row[0]) + + assert_equal got[0], row[1][0] + + if row[1][1] + assert_equal got[1], row[1][1] + else + assert_nil got[1] + end + end + end +end -- cgit v1.2.3