Commit 061feb63 authored by ThibG's avatar ThibG Committed by Eugen Rochko

Fix scheduled toot with media immediately creating a toot (#9894)

* Add test for not persisting status when attaching media to scheduled toot

* Prevent status used for validation from being persisted to the database

Fixes #9893

Thanks to tateisu for the help investigating this.
parent dd8a00a3
......@@ -66,7 +66,10 @@ class PostStatusService < BaseService
def schedule_status!
status_for_validation =
if status_for_validation.valid?
# The following transaction block is needed to wrap the UPDATEs to
# the media attachments when the scheduled status is created
......@@ -36,6 +36,20 @@ RSpec.describe PostStatusService, type: :service do
expect(status.params['text']).to eq 'Hi future!'
it 'does not immediately create a status when scheduling a status' do
account = Fabricate(:account)
media = Fabricate(:media_attachment)
future = + 2.hours
status =, text: 'Hi future!', media_ids: [], scheduled_at: future)
expect(status).to be_a ScheduledStatus
expect(status.scheduled_at).to eq future
expect(status.params['text']).to eq 'Hi future!'
expect(media.reload.status).to be_nil
expect(Status.where(text: 'Hi future!').exists?).to be_falsey
it 'creates response to the original status of boost' do
boosted_status = Fabricate(:status)
in_reply_to_status = Fabricate(:status, reblog: boosted_status)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment