diff options
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/resolve_remote_account_service_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/services/resolve_remote_account_service_spec.rb b/spec/services/resolve_remote_account_service_spec.rb index ad4d436ba..c51588210 100644 --- a/spec/services/resolve_remote_account_service_spec.rb +++ b/spec/services/resolve_remote_account_service_spec.rb @@ -68,4 +68,27 @@ RSpec.describe ResolveRemoteAccountService do expect(account.domain).to eq 'localdomain.com' expect(account.remote_url).to eq 'https://webdomain.com/users/foo.atom' end + + it 'processes one remote account at a time using locks' do + wait_for_start = true + fail_occurred = false + return_values = [] + + threads = Array.new(5) do + Thread.new do + true while wait_for_start + begin + return_values << subject.call('foo@localdomain.com') + rescue ActiveRecord::RecordNotUnique + fail_occurred = true + end + end + end + + wait_for_start = false + threads.each(&:join) + + expect(fail_occurred).to be false + expect(return_values).to_not include(nil) + end end |