Skip to content

Commit

Permalink
added addtional fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mpidcock committed Jan 8, 2025
1 parent 30c22fa commit a92fec4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
9 changes: 6 additions & 3 deletions app/services/state_file/ty23_archiver_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ def archive_batch
archived_intake = StateFileArchivedIntake.new(intake.attributes.slice(*archive_attributes))
# TODO: pull mailing address details off the intake; populate relevant fields on the archived intake record
if intake.submission_pdf.attached?
pdf = intake.submission_pdf
archived_intake.submission_pdf.attach(
io: StringIO.new(intake.submission_pdf.download),
filename: intake.submission_pdf.filename.to_s,
content_type: intake.submission_pdf.content_type,
io: StringIO.new(pdf.download),
filename: pdf.filename.to_s,
content_type: pdf.content_type,
)
else
Rails.logger.error("No submission pdf attached for record #{record}. Continuing with batch.")
end
archived_intake.state_code = @state_code
archived_intake.tax_year = @tax_year
archived_intake.save!
archived_ids << intake.id
rescue StandardError => e
Expand Down
17 changes: 15 additions & 2 deletions spec/services/state_file/ty23_archiver_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@
%w[az ny].each do |state_code|
context 'when there is a current batch to archive' do
let(:archiver) { described_class.new(state_code: state_code) }
let!(:intake) { create("state_file_#{state_code}_intake".to_sym, created_at: Date.parse("1/5/23"), hashed_ssn: "fake hashed ssn") }
let(:email_address) { "[email protected]"}
let!(:intake) {
create(
"state_file_#{state_code}_intake".to_sym,
created_at: Date.parse("1/5/23"),
hashed_ssn: "fake hashed ssn",
email_address: email_address,
)
}
let!(:submission) { create(:efile_submission, :for_state, :accepted, data_source: intake, created_at: Date.parse("1/5/23")) }
let!(:mock_batch) { [submission] }
let(:test_pdf) { Rails.root.join("spec", "fixtures", "files", "document_bundle.pdf") }
Expand All @@ -68,7 +76,12 @@
archived_ids = archiver.archive_batch
expect(archived_ids.count).to eq 1
archived_ids.each do |id|
expect(StateFileArchivedIntake.find(id).submission_pdf.attached?).to be true
archived_intake = StateFileArchivedIntake.find(id)
expect(archived_intake.hashed_ssn).to eq(intake.hashed_ssn)
expect(archived_intake.email_address).to eq(intake.email_address)
expect(archived_intake.tax_year).to eq(2023)
expect(archived_intake.state_code).to eq(state_code)
expect(archived_intake.submission_pdf.attached?).to be true
end
end
end
Expand Down

0 comments on commit a92fec4

Please sign in to comment.