Skip to content

Commit

Permalink
changed NJ intake to has_many analytics (#5554)
Browse files Browse the repository at this point in the history
* changed NJ intake to has_many analytics

* tweaks how StateFileNjAnalytics object is created and associated to the source intake in the analytic-making background job

* Added test for multiple submissions on one intake

---------

Co-authored-by: jey <[email protected]>
  • Loading branch information
jachan and jnf authored Feb 11, 2025
1 parent eff711d commit c75ad16
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/jobs/state_file/create_nj_analytics_record_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module StateFile
class CreateNjAnalyticsRecordJob < ApplicationJob
def perform(submission_id)
submission = EfileSubmission.find(submission_id)
nj_analytics = submission.data_source.create_state_file_nj_analytics!
nj_analytics = StateFileNjAnalytics.create(state_file_nj_intake: submission.data_source)
nj_analytics&.update(nj_analytics.calculated_fields)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/state_file_nj_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
class StateFileNjIntake < StateFileBaseIntake
self.ignored_columns += ["primary_signature_pin", "spouse_signature_pin"]
encrypts :account_number, :routing_number, :raw_direct_file_data, :raw_direct_file_intake_data
has_one :state_file_nj_analytics
has_many :state_file_nj_analytics

enum household_rent_own: { unfilled: 0, rent: 1, own: 2, neither: 3, both: 4 }, _prefix: :household_rent_own

Expand Down
11 changes: 11 additions & 0 deletions spec/jobs/state_file/create_nj_analytics_record_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,16 @@
submitted_intake.reload
expect(submitted_intake.state_file_nj_analytics).to be_present
end

context "when multiple submissions exist" do
let!(:submission_2) { create :efile_submission, :for_state, data_source: submitted_intake }
it "allows multiple NJ analytics records to be attached to one intake" do
expect(submitted_intake.state_file_nj_analytics).not_to be_present
described_class.perform_now(submission.id)
submitted_intake.reload
described_class.perform_now(submission_2.id)
expect(submitted_intake.state_file_nj_analytics.size).to eq 2
end
end
end
end

0 comments on commit c75ad16

Please sign in to comment.