about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-03-10 00:11:49 +0100
committerGitHub <noreply@github.com>2022-03-10 00:11:49 +0100
commit5ccd6cbfda84463a90b55be077da13498e1cc293 (patch)
tree0cdab353db8dce6e6eb4ca4ae2d56c99e3456250
parent63c9d2bc2881391496d372cc5166afb1662b841a (diff)
Add test for reblog race condition fix (#17732)
Follow-up to #17693
-rw-r--r--spec/services/reblog_service_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/services/reblog_service_spec.rb b/spec/services/reblog_service_spec.rb
index e2077f282..c0ae5eedc 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) }