Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
success: true,
errors: {},
mfa_method_counts: { phone: 1 },
profile_idv_level: 'legacy_in_person',
profile_idv_level: 'in_person',
identity_verified: true,
account_age_in_days: 0,
account_confirmed_at: user.confirmed_at,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

context 'with enrollment' do
let(:user) { create(:user, :with_pending_in_person_enrollment) }
let(:profile) { create(:profile, :with_pii, user: user) }

it 'renders show template' do
expect(response).to render_template :show
Expand Down
9 changes: 2 additions & 7 deletions spec/controllers/idv/personal_key_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ def assert_personal_key_generated_for_profiles(*profile_pii_pairs)

let(:address_verification_mechanism) { 'phone' }

let(:in_person_enrollment) { nil }

let(:idv_session) { subject.idv_session }

let(:threatmetrix_review_status) { nil }
Expand Down Expand Up @@ -524,13 +522,10 @@ def assert_personal_key_generated_for_profiles(*profile_pii_pairs)
end

context 'with in person profile' do
let!(:in_person_enrollment) do
create(:in_person_enrollment, :pending, user: user).tap do
user.reload_pending_in_person_enrollment
end
end
let!(:profile) { create(:profile, :in_person_verification_pending, user: user) }

before do
user.reload_pending_in_person_enrollment
allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true)
end

Expand Down
7 changes: 6 additions & 1 deletion spec/factories/in_person_enrollments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
status { :pending }
status_updated_at { Time.zone.now }
profile do
association(:profile, :in_person_verification_pending, user: user)
association(
:profile,
:in_person_verification_pending,
user: user,
in_person_enrollment: instance,
)
end
end

Expand Down
15 changes: 14 additions & 1 deletion spec/factories/profiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,20 @@

trait :in_person_verification_pending do
in_person_verification_pending_at { 15.days.ago }
idv_level { :legacy_in_person }
idv_level { :in_person }
in_person_enrollment do
association(:in_person_enrollment, :pending, profile: instance, user:)
end
end

trait :in_person_verified do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this just not exist previously? 😮

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It did not.

verified_at { Time.zone.now }
activated_at { Time.zone.now }
idv_level { :in_person }
in_person_verification_pending_at { nil }
in_person_enrollment do
association(:in_person_enrollment, :passed, profile: instance, user:)
end
end

trait :fraud_pending_reason do
Expand Down
11 changes: 4 additions & 7 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,8 @@
end

trait :with_pending_in_person_enrollment do
after :build do |user|
profile = create(:profile, :with_pii, :in_person_verification_pending, user: user)
create(:in_person_enrollment, :pending, user: user, profile: profile)
profiles do
[association(:profile, :with_pii, :in_person_verification_pending, user: instance)]
end
end

Expand Down Expand Up @@ -270,16 +269,14 @@
confirmed_at { Time.zone.now.round }

after :build do |user|
profile = create(
create(
Comment on lines -273 to +272
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice if we could do this as a build() instead of a create() but I'm guessing we rely on DB associations and scopes for these, so easier to just always create

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you say more about the reason for preferring build() here? Is it because you’d expect build() to be faster than create()? Or is it about wanting to avoid calling create() inside of an after build hook?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. yes, build() should be faster than create() because build is in-memory only
  2. the other reason is that after_build means that if an upstream caller of this constructor only builds, intending to be in-memory only, now by calling create this will hit the DB, which may be unexpected and unintended

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried making the suggested change, but it broke a spec in the delete account controller spec. I am going to merge the PR as is.

:profile,
:with_pii,
:active,
:verified,
:in_person_verification_pending,
:in_person_verified,
user: user,
)
create(:in_person_enrollment, :passed, user: user, profile: profile)
profile.in_person_verification_pending_at = nil
end
end

Expand Down
3 changes: 0 additions & 3 deletions spec/models/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,6 @@
describe '#deactivate_due_to_encryption_error' do
context 'when the profile has a "pending" in_person_enrollment' do
subject { create(:profile, :in_person_verification_pending, user: user) }
let!(:enrollment) do
create(:in_person_enrollment, user: user, profile: subject, status: :pending)
end

before do
subject.deactivate_due_to_encryption_error
Expand Down
8 changes: 4 additions & 4 deletions spec/views/accounts/show.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
end

context 'when current user has ipp pending profile' do
let(:user) { build(:user, :with_pending_in_person_enrollment) }
let(:user) { create(:user, :with_pending_in_person_enrollment) }

it 'renders idv partial' do
expect(render).to render_template(partial: 'accounts/_identity_verification')
Expand All @@ -114,7 +114,7 @@
context 'when current user has an in_person_enrollment that was failed' do
let(:vtr) { ['Pe'] }
let(:sp_name) { 'sinatra-test-app' }
let(:user) { build(:user, :with_pending_in_person_enrollment) }
let(:user) { create(:user, :with_pending_in_person_enrollment) }

before do
# Make the in_person_enrollment and associated profile failed
Expand All @@ -132,7 +132,7 @@
context 'when current user has an in_person_enrollment that was cancelled' do
let(:vtr) { ['Pe'] }
let(:sp_name) { 'sinatra-test-app' }
let(:user) { build(:user, :with_pending_in_person_enrollment) }
let(:user) { create(:user, :with_pending_in_person_enrollment) }

before do
# Make the in_person_enrollment and associated profile cancelled
Expand All @@ -150,7 +150,7 @@
context 'when current user has an in_person_enrollment that expired' do
let(:vtr) { ['Pe'] }
let(:sp_name) { 'sinatra-test-app' }
let(:user) { build(:user, :with_pending_in_person_enrollment) }
let(:user) { create(:user, :with_pending_in_person_enrollment) }

before do
# Expire the in_person_enrollment and associated profile
Expand Down