about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/models/status.rb2
-rw-r--r--spec/services/reblog_service_spec.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 0d249244f..6db1f2a4c 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -134,7 +134,7 @@ class Status < ApplicationRecord
     CustomEmoji.from_text([spoiler_text, text].join(' '), account.domain)
   end
 
-  after_create :store_uri, if: :local?
+  after_create_commit :store_uri, if: :local?
 
   around_create Mastodon::Snowflake::Callbacks
 
diff --git a/spec/services/reblog_service_spec.rb b/spec/services/reblog_service_spec.rb
index 0ad5c5f6b..19d3bb6cb 100644
--- a/spec/services/reblog_service_spec.rb
+++ b/spec/services/reblog_service_spec.rb
@@ -39,6 +39,12 @@ RSpec.describe ReblogService do
       expect(status.reblogs.count).to eq 1
     end
 
+    describe 'after_create_commit :store_uri' do
+      it 'keeps consistent reblog count' do
+        expect(status.reblogs.count).to eq 1
+      end
+    end
+
     it 'distributes to followers' do
       expect(ActivityPub::DistributionWorker).to have_received(:perform_async)
     end