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
10 changes: 7 additions & 3 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ def activate(reason_deactivated: nil)
end
# rubocop:enable Rails/SkipsModelValidations

def confirm_that_profile_can_be_activated!
def reason_not_to_activate
if pending_reasons.any?
raise "Attempting to activate profile with pending reasons: #{pending_reasons.join(',')}"
"Attempting to activate profile with pending reasons: #{pending_reasons.join(',')}"
elsif deactivation_reason.present?
raise "Attempting to activate profile with deactivation reason: #{deactivation_reason}"
"Attempting to activate profile with deactivation reason: #{deactivation_reason}"
end
end

Expand Down Expand Up @@ -218,6 +218,10 @@ def irs_attempts_api_tracker

private

def confirm_that_profile_can_be_activated!
raise reason_not_to_activate if reason_not_to_activate
end

def track_fraud_review_adjudication(decision:)
if IdentityConfig.store.irs_attempt_api_track_idv_fraud_review
fraud_review_request = user.fraud_review_requests.last
Expand Down
2 changes: 0 additions & 2 deletions app/services/idv/profile_maker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def initialize(applicant:, user:, user_password:, initiating_service_provider: n
end

def save_profile(
active:,
fraud_review_needed:,
gpo_verification_needed:,
deactivation_reason: nil
Expand All @@ -20,7 +19,6 @@ def save_profile(
profile.encrypt_pii(pii_attributes, user_password)
profile.proofing_components = current_proofing_components
profile.save!
profile.activate if active
profile.deactivate_for_gpo_verification if gpo_verification_needed
profile.deactivate_for_fraud_review if fraud_review_needed
profile
Expand Down
4 changes: 3 additions & 1 deletion app/services/idv/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ def respond_to_missing?(method_sym, include_private)
def create_profile_from_applicant_with_password(user_password)
profile_maker = build_profile_maker(user_password)
profile = profile_maker.save_profile(
active: deactivation_reason.nil?,
deactivation_reason: deactivation_reason,
fraud_review_needed: threatmetrix_failed_and_needs_review?,
gpo_verification_needed: gpo_verification_needed?,
)

profile.activate unless profile.reason_not_to_activate

self.pii = profile_maker.pii_attributes
self.profile_id = profile.id
self.personal_key = profile.personal_key
Expand Down
1 change: 0 additions & 1 deletion spec/controllers/idv/personal_key_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def stub_idv_session
user_password: password,
)
profile = profile_maker.save_profile(
active: false,
fraud_review_needed: false,
gpo_verification_needed: false,
)
Expand Down
8 changes: 1 addition & 7 deletions spec/services/idv/profile_maker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
it 'creates an inactive Profile with encrypted PII' do
proofing_component = ProofingComponent.create(user_id: user.id, document_check: 'acuant')
profile = subject.save_profile(
active: false,
fraud_review_needed: false,
gpo_verification_needed: false,
)
Expand All @@ -41,7 +40,6 @@
context 'with deactivation reason' do
it 'creates an inactive profile with deactivation reason' do
profile = subject.save_profile(
active: false,
fraud_review_needed: false,
gpo_verification_needed: false,
deactivation_reason: :encryption_error,
Expand All @@ -55,7 +53,6 @@
context 'with fraud review needed' do
it 'deactivates a profile for fraud review' do
profile = subject.save_profile(
active: false,
fraud_review_needed: true,
gpo_verification_needed: false,
deactivation_reason: nil,
Expand All @@ -69,7 +66,6 @@
context 'with gpo_verification_needed' do
it 'deactivates a profile for gpo verification' do
profile = subject.save_profile(
active: false,
fraud_review_needed: false,
gpo_verification_needed: true,
deactivation_reason: nil,
Expand All @@ -83,13 +79,12 @@
context 'as active' do
it 'creates an active profile' do
profile = subject.save_profile(
active: true,
fraud_review_needed: false,
gpo_verification_needed: false,
deactivation_reason: nil,
)

expect(profile.active).to eq true
expect(profile.active).to eq false
expect(profile.deactivation_reason).to be_nil
end
end
Expand All @@ -99,7 +94,6 @@

it 'creates a profile with the initiating sp recorded' do
profile = subject.save_profile(
active: true,
fraud_review_needed: false,
gpo_verification_needed: false,
deactivation_reason: nil,
Expand Down