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