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
5 changes: 3 additions & 2 deletions app/decorators/user_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ def identity_verified?(service_provider: nil)
end

def reproof_for_irs?(service_provider:)
service_provider&.irs_attempts_api_enabled &&
!user.active_profile&.initiating_service_provider&.irs_attempts_api_enabled
return false unless user.active_profile.present?
return false unless service_provider&.irs_attempts_api_enabled
!user.active_profile.initiating_service_provider&.irs_attempts_api_enabled
end

def active_profile_newer_than_pending_profile?
Expand Down
34 changes: 34 additions & 0 deletions spec/decorators/user_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,38 @@
expect(user.decorate.second_last_signed_in_at).to eq(event2.reload.created_at)
end
end

describe '#reproof_for_irs?' do
let(:service_provider) { create(:service_provider) }

it 'returns false if the service provider is not an attempts API service provider' do
user = create(:user, :proofed)

expect(user.decorate.reproof_for_irs?(service_provider: service_provider)).to be_falsy
end

context 'an attempts API service provider' do
let(:service_provider) { create(:service_provider, :irs) }
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 hadn't seen the :irs factory bit, neat!


it 'returns false if the user has not proofed before' do
user = create(:user)

expect(user.decorate.reproof_for_irs?(service_provider: service_provider)).to be_falsy
end

it 'returns false if the active profile initiating SP was an attempts API SP' do
user = create(:user, :proofed)

user.active_profile.update!(initiating_service_provider: service_provider)

expect(user.decorate.reproof_for_irs?(service_provider: service_provider)).to be_falsy
end

it 'returns true if the active profile initiating SP was not an attempts API SP' do
user = create(:user, :proofed)

expect(user.decorate.reproof_for_irs?(service_provider: service_provider)).to be_truthy
end
end
end
end