2023-03-04 16:56:09 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 07:12:25 +02:00
|
|
|
RSpec.describe ResolveAccountWorker do
|
2023-03-04 16:56:09 +01:00
|
|
|
let(:worker) { described_class.new }
|
2024-10-23 09:50:20 +02:00
|
|
|
let(:service) { instance_double(ResolveAccountService, call: true) }
|
2023-03-04 16:56:09 +01:00
|
|
|
|
|
|
|
describe 'perform' do
|
2024-10-23 09:50:20 +02:00
|
|
|
context 'with missing values' do
|
|
|
|
it 'runs without error' do
|
|
|
|
expect { worker.perform(nil) }
|
|
|
|
.to_not raise_error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a URI' do
|
|
|
|
before { stub_service }
|
|
|
|
|
|
|
|
let(:uri) { 'https://host/path/value' }
|
|
|
|
|
|
|
|
it 'initiates account resolution' do
|
|
|
|
worker.perform(uri)
|
|
|
|
|
|
|
|
expect(service)
|
|
|
|
.to have_received(:call)
|
|
|
|
.with(uri)
|
|
|
|
end
|
|
|
|
|
|
|
|
def stub_service
|
|
|
|
allow(ResolveAccountService)
|
|
|
|
.to receive(:new)
|
|
|
|
.and_return(service)
|
|
|
|
end
|
2023-03-04 16:56:09 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|