Skip to content

Commit

Permalink
csv: don't export underscores on "authors"
Browse files Browse the repository at this point in the history
It does not make sense on this context.

Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
  • Loading branch information
mssola committed Mar 20, 2024
1 parent 2cf0ffb commit c064618
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/csv_exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions test/controllers/exports_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit c064618

Please sign in to comment.