From 6af46e6b240342a5597345d30b50b46b1b8ed95f Mon Sep 17 00:00:00 2001 From: "kentsang.gds" Date: Tue, 18 Oct 2022 15:22:13 +0100 Subject: [PATCH] Remove dot (.) prefix from formats Some resources were set with the . prefix, e.g. .csv, this would cause prefix links to not show. So removing the . will enable previews again. --- app/models/datafile.rb | 2 +- spec/models/datafile_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/datafile.rb b/app/models/datafile.rb index 12bf80ce..1ddf2b19 100644 --- a/app/models/datafile.rb +++ b/app/models/datafile.rb @@ -10,7 +10,7 @@ def initialize(hash) @start_date = hash["start_date"] @created_at = hash["created_at"] @updated_at = hash["updated_at"] - @format = hash["format"]&.strip&.upcase + @format = hash["format"]&.strip&.delete_prefix(".")&.upcase @size = hash["size"] @uuid = hash["uuid"] end diff --git a/spec/models/datafile_spec.rb b/spec/models/datafile_spec.rb index c75004da..e25f1059 100644 --- a/spec/models/datafile_spec.rb +++ b/spec/models/datafile_spec.rb @@ -27,5 +27,12 @@ expect(datafile.csv?).to be true end end + + describe "#csv?" do + it 'returns true if datafile is ".csv "' do + datafile = build :datafile, format: ".csv " + expect(datafile.csv?).to be true + end + end end end