From 2526b32ad3cb1142edc6e2cfb272a9e3cef19060 Mon Sep 17 00:00:00 2001 From: Paulo Vilarinho <33267902+PauloVilarinho@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:06:41 -0300 Subject: [PATCH] block scheduled status from frozen users (#30729) --- .../publish_scheduled_status_worker.rb | 2 ++ .../publish_scheduled_status_worker_spec.rb | 22 +++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/workers/publish_scheduled_status_worker.rb b/app/workers/publish_scheduled_status_worker.rb index aa5c4a834a..0ec081de91 100644 --- a/app/workers/publish_scheduled_status_worker.rb +++ b/app/workers/publish_scheduled_status_worker.rb @@ -9,6 +9,8 @@ class PublishScheduledStatusWorker scheduled_status = ScheduledStatus.find(scheduled_status_id) scheduled_status.destroy! + return true if scheduled_status.account.user.disabled? + PostStatusService.new.call( scheduled_status.account, options_with_objects(scheduled_status.params.with_indifferent_access) diff --git a/spec/workers/publish_scheduled_status_worker_spec.rb b/spec/workers/publish_scheduled_status_worker_spec.rb index 35e510d253..9365e8a4bc 100644 --- a/spec/workers/publish_scheduled_status_worker_spec.rb +++ b/spec/workers/publish_scheduled_status_worker_spec.rb @@ -12,12 +12,26 @@ RSpec.describe PublishScheduledStatusWorker do subject.perform(scheduled_status.id) end - it 'creates a status' do - expect(scheduled_status.account.statuses.first.text).to eq 'Hello world, future!' + context 'when the account is not disabled' do + it 'creates a status' do + expect(scheduled_status.account.statuses.first.text).to eq 'Hello world, future!' + end + + it 'removes the scheduled status' do + expect(ScheduledStatus.find_by(id: scheduled_status.id)).to be_nil + end end - it 'removes the scheduled status' do - expect(ScheduledStatus.find_by(id: scheduled_status.id)).to be_nil + context 'when the account is disabled' do + let(:scheduled_status) { Fabricate(:scheduled_status, account: Fabricate(:account, user: Fabricate(:user, disabled: true))) } + + it 'does not create a status' do + expect(Status.count).to eq 0 + end + + it 'removes the scheduled status' do + expect(ScheduledStatus.find_by(id: scheduled_status.id)).to be_nil + end end end end