From c0646186c2049e75ae932966aa0604d712b4f4c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Sabat=C3=A9=20Sol=C3=A0?= Date: Wed, 20 Mar 2024 11:30:20 +0100 Subject: [PATCH] csv: don't export underscores on "authors" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It does not make sense on this context. Signed-off-by: Miquel Sabaté Solà --- lib/csv_exporter.rb | 9 ++------- test/controllers/exports_controller_test.rb | 3 +++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/csv_exporter.rb b/lib/csv_exporter.rb index 0463ba6..3cab092 100644 --- a/lib/csv_exporter.rb +++ b/lib/csv_exporter.rb @@ -16,14 +16,9 @@ def export # Generate a new CSV line from the given `thing`. def thing_to_csv(thing:) - CSV.generate_line([thing.target, thing.authors, thing.editors, thing.year, - clean_title(title: thing.title), thing.note, thing.insideof, + CSV.generate_line([thing.target, thing.authors.delete('_'), thing.editors, thing.year, + thing.title.delete('_'), thing.note, thing.insideof, thing.url, thing.publisher, thing.kind, thing.access, thing.bought_at], quote_empty: false) end - - # Clean the given title from underscores and other such characters. - def clean_title(title:) - title.delete('_') - end end diff --git a/test/controllers/exports_controller_test.rb b/test/controllers/exports_controller_test.rb index eefff6f..fe94362 100644 --- a/test/controllers/exports_controller_test.rb +++ b/test/controllers/exports_controller_test.rb @@ -8,6 +8,9 @@ class ExportsControllerTest < ActionDispatch::IntegrationTest get search_exports_url(0, format: 'csv') body = @response.body.split("\n") + + assert_nil body.last.index('_') + targets = body.map { |b| b.split(',').first } assert_equal targets, [things(:thing2).target, things(:thing1).target]