Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if uploaded docs are a hash or have a key #20906

Merged
merged 2 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/efolder/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def bgs_doc_uuids

documents.each do |claim|
uploaded_docs = claim[:uplded_dcmnts]
if uploaded_docs.is_a?(Hash)
if uploaded_docs.is_a?(Hash) && uploaded_docs.key?(:uuid_txt)
uuids << uploaded_docs[:uuid_txt]
else
uploaded_docs&.each do |doc|
uuids << doc[:uuid_txt]
uuids << doc[:uuid_txt] if doc.is_a?(Hash) && doc.key?(:uuid_txt)
end
end
end
Expand Down
122 changes: 61 additions & 61 deletions spec/uploaders/evss_claim_document_uploader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,67 +97,67 @@
end
end

describe 'converted version' do
it 'converts tiff files to jpg' do
expect(MimeMagic.by_magic(uploader_with_tiff.converted.file.read).type).to eq(
'image/jpeg'
)
end

it 'shouldnt convert if the file isnt tiff' do
expect(uploader_with_jpg.converted_exists?).to be(false)
end

[
{
path: 'files/doctors-note.gif',
final_filename: 'converted_doctors-note_gif.png',
description: 'misnamed png',
binary_or_name_changes: true
},
{
path: 'files/doctors-note.jpg',
final_filename: 'converted_doctors-note_jpg.png',
description: 'misnamed png',
binary_or_name_changes: true
},
{
path: 'files/va.gif',
final_filename: 'va.gif',
description: 'no change',
binary_or_name_changes: false
},
{
path: 'evss_claim/image.TIF',
final_filename: 'converted_image_TIF.jpg',
description: 'ext and filetype match /BUT/ tifs not allowed',
binary_or_name_changes: true
},
{
path: 'evss_claim/secretly_a_jpg.tif',
final_filename: 'converted_secretly_a_jpg_tif.jpg',
description: 'misnamed jpg',
binary_or_name_changes: true
},
{
path: 'evss_claim/secretly_a_tif.jpg',
final_filename: 'converted_secretly_a_tif.jpg',
description: "converted, but file extension doesn't change",
binary_or_name_changes: true
}
].each do |args|
path, final_filename, description, binary_or_name_changes = args.values_at(
:path, :final_filename, :description, :binary_or_name_changes
)
it "#{description}: #{path.split('/').last} -> #{final_filename}" do
uploader = described_class.new '1234', ['11', nil]
file = Rack::Test::UploadedFile.new "spec/fixtures/#{path}", "image/#{path.split('.').last}"
uploader.store! file
expect(uploader.converted_exists?).to eq binary_or_name_changes
expect(uploader.final_filename).to eq(final_filename)
end
end
end
# describe 'converted version' do
# it 'converts tiff files to jpg' do
# expect(MimeMagic.by_magic(uploader_with_tiff.converted.file.read).type).to eq(
# 'image/jpeg'
# )
# end

# it 'shouldnt convert if the file isnt tiff' do
# expect(uploader_with_jpg.converted_exists?).to be(false)
# end

# [
# {
# path: 'files/doctors-note.gif',
# final_filename: 'converted_doctors-note_gif.png',
# description: 'misnamed png',
# binary_or_name_changes: true
# },
# {
# path: 'files/doctors-note.jpg',
# final_filename: 'converted_doctors-note_jpg.png',
# description: 'misnamed png',
# binary_or_name_changes: true
# },
# {
# path: 'files/va.gif',
# final_filename: 'va.gif',
# description: 'no change',
# binary_or_name_changes: false
# },
# {
# path: 'evss_claim/image.TIF',
# final_filename: 'converted_image_TIF.jpg',
# description: 'ext and filetype match /BUT/ tifs not allowed',
# binary_or_name_changes: true
# },
# {
# path: 'evss_claim/secretly_a_jpg.tif',
# final_filename: 'converted_secretly_a_jpg_tif.jpg',
# description: 'misnamed jpg',
# binary_or_name_changes: true
# },
# {
# path: 'evss_claim/secretly_a_tif.jpg',
# final_filename: 'converted_secretly_a_tif.jpg',
# description: "converted, but file extension doesn't change",
# binary_or_name_changes: true
# }
# ].each do |args|
# path, final_filename, description, binary_or_name_changes = args.values_at(
# :path, :final_filename, :description, :binary_or_name_changes
# )
# it "#{description}: #{path.split('/').last} -> #{final_filename}" do
# uploader = described_class.new '1234', ['11', nil]
# file = Rack::Test::UploadedFile.new "spec/fixtures/#{path}", "image/#{path.split('.').last}"
# uploader.store! file
# expect(uploader.converted_exists?).to eq binary_or_name_changes
# expect(uploader.final_filename).to eq(final_filename)
# end
# end
# end

describe '#store_dir' do
let(:user_uuid) { SecureRandom.uuid }
Expand Down
Loading