]> cat aescling's git repositories - mastodon.git/commitdiff
Add test for reblog race condition fix (#17732)
authorClaire <claire.github-309c@sitedethib.com>
Wed, 9 Mar 2022 23:11:49 +0000 (00:11 +0100)
committerGitHub <noreply@github.com>
Wed, 9 Mar 2022 23:11:49 +0000 (00:11 +0100)
Follow-up to #17693

spec/services/reblog_service_spec.rb

index e2077f282a2d04483a57899f1f732f88f573b0c5..c0ae5eedcc166b963efe2d8218d336c0702c6b5d 100644 (file)
@@ -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) }