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
4 changes: 2 additions & 2 deletions app/controllers/concerns/idv/doc_auth_vendor_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def socure_user_set

def add_user_to_socure_set
uuid = current_user&.uuid
if uuid.nil? && is_defined?(document_capture_user)
uuid = document_capture_user.uuid
if uuid.nil? && defined?(document_capture_user)
uuid = document_capture_user&.uuid
end

if uuid
Expand Down
30 changes: 26 additions & 4 deletions spec/controllers/concerns/idv/doc_auth_vendor_concern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

RSpec.describe Idv::DocAuthVendorConcern, :controller do
let(:user) { create(:user) }
let(:document_capture_session) do
create(:document_capture_session, user: user)
end
let(:socure_user_set) { Idv::SocureUserSet.new }
let(:bucket) { :mock }

Expand Down Expand Up @@ -42,12 +45,31 @@
context 'bucket is Socure' do
let(:bucket) { :socure }

it 'returns socure as the vendor' do
expect(controller.doc_auth_vendor).to eq(Idp::Constants::Vendors::SOCURE)
context 'current user is undefined so use document_capture_session user' do
before do
allow(DocumentCaptureSession).to receive(:find_by).and_return(document_capture_session)
allow(User).to receive(:find_by).and_return(user)
allow(controller).to receive(:current_user).and_return(nil)
allow(controller).to receive(:document_capture_user).and_return(user)
end

it 'returns socure as the vendor' do
expect(controller.doc_auth_vendor).to eq(Idp::Constants::Vendors::SOCURE)
end

it 'adds a user to the socure redis set' do
expect { controller.doc_auth_vendor }.to change { socure_user_set.count }.by(1)
end
end

it 'adds a user to the socure redis set' do
expect { controller.doc_auth_vendor }.to change { socure_user_set.count }.by(1)
context 'current user is defined' do
it 'returns socure as the vendor' do
expect(controller.doc_auth_vendor).to eq(Idp::Constants::Vendors::SOCURE)
end

it 'adds a user to the socure redis set' do
expect { controller.doc_auth_vendor }.to change { socure_user_set.count }.by(1)
end
end
end

Expand Down