Skip to content

Commit

Permalink
Merge pull request #1112 from alphagov/handle-dot-csv
Browse files Browse the repository at this point in the history
Remove dot (.) prefix from formats
  • Loading branch information
kentsanggds authored Oct 20, 2022
2 parents 157a457 + 6af46e6 commit 140a5a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/datafile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions spec/models/datafile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 140a5a2

Please sign in to comment.