-
Notifications
You must be signed in to change notification settings - Fork 166
LG-13577 Save Sponsor ID on new Enrollments #10859
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
Changes from all commits
7c49014
e8bdc8b
6fed24e
9347f9c
a159529
c553ff7
39b487a
93c0b38
7baef31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| end | ||
| let(:proofer) { UspsInPersonProofing::Mock::Proofer.new } | ||
| let(:is_enhanced_ipp) { false } | ||
| let(:usps_ipp_sponsor_id) { '2718281828' } | ||
|
|
||
| before(:each) do | ||
| stub_request_token | ||
|
|
@@ -38,6 +39,7 @@ | |
| allow(subject).to receive(:analytics).and_return(subject_analytics) | ||
| allow(IdentityConfig.store).to receive(:usps_ipp_transliteration_enabled). | ||
| and_return(usps_ipp_transliteration_enabled) | ||
| allow(IdentityConfig.store).to receive(:usps_ipp_sponsor_id).and_return(usps_ipp_sponsor_id) | ||
| end | ||
|
|
||
| describe '#schedule_in_person_enrollment' do | ||
|
|
@@ -179,10 +181,14 @@ | |
| end | ||
| end | ||
|
|
||
| it 'sets enrollment status to pending and sets established at date and unique id' do | ||
| it <<~STR.squish do | ||
| sets enrollment status to pending, sponsor_id to usps_ipp_sponsor_id, | ||
| and sets established at date and unique id | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if to clean this up instead of having a multi-line description you break it out into multiple it blocks by wrapping this into a context. Maybe something like this? context 'when the in person enrollment is not enhanced ipp' do
before do
subject.schedule_in_person_enrollment(user:, pii:, is_enhanced_ipp:)
end
it 'sets enrollment status to pending' do
expect(user.in_person_enrollments.first.status).to eq(InPersonEnrollment::STATUS_PENDING)
end
it 'sets sponsor_id to usps_ipp_sponsor_id' do
expect(user.in_person_enrollments.first.sponsor_id).to eq(usps_ipp_sponsor_id)
end
it 'sets established at date' do
expect(user.in_person_enrollments.first.enrollment_established_at).to_not be_nil
end
it 'sets unique id' do
expect(user.in_person_enrollments.first.unique_id).to_not be_nil
end
endThis does however slightly increases the speed of the tests by 0.25 seconds, but I do think it helps with readability.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shanechesnutt-ft this is good suggestion. I think I will keep the existing pattern and thus speed over readability. If others have strong opinions in preference over readability, we can rework at a later time. I appreciate your feedback though. 🙏
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tend to agree with leaning towards the single test. I think the intent of each test is reflected well enough in the |
||
| STR | ||
| subject.schedule_in_person_enrollment(user:, pii:, is_enhanced_ipp:) | ||
|
|
||
| expect(user.in_person_enrollments.first.status).to eq(InPersonEnrollment::STATUS_PENDING) | ||
| expect(user.in_person_enrollments.first.sponsor_id).to eq(usps_ipp_sponsor_id) | ||
| expect(user.in_person_enrollments.first.enrollment_established_at).to_not be_nil | ||
| expect(user.in_person_enrollments.first.unique_id).to_not be_nil | ||
| end | ||
|
|
@@ -331,10 +337,26 @@ | |
| allow(proofer).to receive(:request_enroll).and_call_original | ||
| end | ||
| context 'when the user is going through enhanced ipp' do | ||
| let!(:enrollment) do | ||
| create( | ||
| :in_person_enrollment, | ||
| user: user, | ||
| service_provider: service_provider, | ||
| status: :establishing, | ||
| profile: nil, | ||
| ) | ||
| end | ||
|
|
||
| it 'creates an enhanced ipp enrollment' do | ||
| expect(proofer).to receive(:request_enroll).with(applicant, is_enhanced_ipp) | ||
| subject.create_usps_enrollment(enrollment, pii, is_enhanced_ipp) | ||
| end | ||
|
|
||
| it 'saves sponsor_id on the enrollment to the usps_eipp_sponsor_id' do | ||
| subject.schedule_in_person_enrollment(user:, pii:, is_enhanced_ipp:) | ||
|
|
||
| expect(user.in_person_enrollments.first.sponsor_id).to eq(usps_eipp_sponsor_id) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👏🏻 |
||
| end | ||
| end | ||
| end | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯