2019-01-05 12:43:28 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 07:12:25 +02:00
|
|
|
RSpec.describe PublishScheduledStatusWorker do
|
2019-01-05 12:43:28 +01:00
|
|
|
subject { described_class.new }
|
|
|
|
|
|
|
|
let(:scheduled_status) { Fabricate(:scheduled_status, params: { text: 'Hello world, future!' }) }
|
|
|
|
|
|
|
|
describe 'perform' do
|
|
|
|
before do
|
|
|
|
subject.perform(scheduled_status.id)
|
|
|
|
end
|
|
|
|
|
2024-11-20 20:06:41 +01:00
|
|
|
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
|
2019-01-05 12:43:28 +01:00
|
|
|
end
|
|
|
|
|
2024-11-20 20:06:41 +01:00
|
|
|
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
|
2019-01-05 12:43:28 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|