Skip to content

Commit

Permalink
make new method public in s3 client and add rspec coverage for new me…
Browse files Browse the repository at this point in the history
…thod
  • Loading branch information
pennja committed Nov 15, 2024
1 parent c8a062f commit 90941a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def upload
config.handle_error("Failed #{upload_type} upload: #{id}", e)
end

def retrieve_presigned_url
archive = config.submission_archive_class.new(config:, id:, type: upload_type)
@archive_path, @manifest_row = archive.retrieval_data
generate_presigned_url(type: upload_type)
end

private

attr_reader :archive_path, :config, :id, :manifest_row, :parent_dir, :temp_directory_path, :upload_type
Expand Down Expand Up @@ -117,12 +123,6 @@ def generate_presigned_url(type: upload_type)
s3_uploader.get_s3_link(s3_upload_file_path(type))
end

def retrieve_presigned_url
archive = config.submission_archive_class.new(config:, id:, type: upload_type)
@archive_path, @manifest_row = archive.retrieval_data
generate_presigned_url(type: upload_type)
end

def s3_upload_file_path(type)
extension = File.extname(archive_path)
ext = type == :submission ? '.pdf' : '.zip'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@
allow(CarrierWave::SanitizedFile).to receive(:new).with(file_double).and_return(carrier_wave_file)
allow(CSV).to receive(:open).and_return(true)
allow(SimpleFormsApi::FormRemediation::SubmissionArchive).to(receive(:new).and_return(submission_archive_double))
allow(submission_archive_double).to receive(:build!).and_return([local_archive_path, manifest_entry])
allow(submission_archive_double).to receive_messages(
build!: [local_archive_path, manifest_entry],
retrieval_data: [local_archive_path, manifest_entry]
)
allow(SimpleFormsApi::FormRemediation::Uploader).to receive_messages(new: uploader)
allow(uploader).to receive(:get_s3_link).with(s3_archive_path).and_return('/s3_url/stuff.pdf')
allow(uploader).to receive_messages(get_s3_file: s3_file, store!: carrier_wave_file)
Expand All @@ -84,6 +87,11 @@
let(:type) { archive_type }

describe '.fetch_presigned_url' do
subject(:fetch_presigned_url) { described_class.fetch_presigned_url(benefits_intake_uuid, config:, type:) }

it 'returns the s3 link' do
expect(fetch_presigned_url).to eq('/s3_url/stuff.pdf')
end
end

describe '#initialize' do
Expand Down

0 comments on commit 90941a6

Please sign in to comment.