From c49a7369ddef62d7fa380079745584a88c61ea94 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 10 Mar 2022 00:11:49 +0100 Subject: [PATCH] Add test for reblog race condition fix (#17732) Follow-up to #17693 --- spec/services/reblog_service_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/services/reblog_service_spec.rb b/spec/services/reblog_service_spec.rb index e2077f282a..c0ae5eedcc 100644 --- a/spec/services/reblog_service_spec.rb +++ b/spec/services/reblog_service_spec.rb @@ -32,6 +32,18 @@ RSpec.describe ReblogService, type: :service do end end + context 'when the reblogged status is discarded in the meantime' do + let(:status) { Fabricate(:status, account: alice, visibility: :public) } + + before do + status.discard + end + + it 'raises an exception' do + expect { subject.call(alice, status) }.to raise_error ActiveRecord::ActiveRecordError + end + end + context 'ActivityPub' do let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') } let(:status) { Fabricate(:status, account: bob) }