mirror of
https://github.com/kikobar/mastodon.git
synced 2024-11-17 12:42:35 +00:00
Retoot count increases without reason (#5363)
* Retoot count increases without reason -The store_uri method for Statuses was being called on after_create and causing reblogs to be incremented twice. -This calls it when the transaction is finished by using after_create_commit. -Fixes #4916. * Added test case for after_create_commit callback for checking reblog count. * Rewrote test to keep original, but added one for only the after_create_commit callback.
This commit is contained in:
parent
d37305c628
commit
b8bae96647
|
@ -134,7 +134,7 @@ class Status < ApplicationRecord
|
||||||
CustomEmoji.from_text([spoiler_text, text].join(' '), account.domain)
|
CustomEmoji.from_text([spoiler_text, text].join(' '), account.domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
after_create :store_uri, if: :local?
|
after_create_commit :store_uri, if: :local?
|
||||||
|
|
||||||
around_create Mastodon::Snowflake::Callbacks
|
around_create Mastodon::Snowflake::Callbacks
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,12 @@ RSpec.describe ReblogService do
|
||||||
expect(status.reblogs.count).to eq 1
|
expect(status.reblogs.count).to eq 1
|
||||||
end
|
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
|
it 'distributes to followers' do
|
||||||
expect(ActivityPub::DistributionWorker).to have_received(:perform_async)
|
expect(ActivityPub::DistributionWorker).to have_received(:perform_async)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue